diff options
Diffstat (limited to 'src/DSUtil')
32 files changed, 7094 insertions, 8418 deletions
diff --git a/src/DSUtil/DSMPropertyBag.cpp b/src/DSUtil/DSMPropertyBag.cpp index ca1198c6b..841e7c3b8 100644 --- a/src/DSUtil/DSMPropertyBag.cpp +++ b/src/DSUtil/DSMPropertyBag.cpp @@ -18,104 +18,104 @@ IDSMPropertyBagImpl::~IDSMPropertyBagImpl() STDMETHODIMP IDSMPropertyBagImpl::Read(LPCOLESTR pszPropName, VARIANT* pVar, IErrorLog* pErrorLog)
{
- CheckPointer(pVar, E_POINTER);
- if(pVar->vt != VT_EMPTY) return E_INVALIDARG;
- CStringW value = Lookup(pszPropName);
- if(value.IsEmpty()) return E_FAIL;
- CComVariant(value).Detach(pVar);
- return S_OK;
+ CheckPointer(pVar, E_POINTER);
+ if(pVar->vt != VT_EMPTY) return E_INVALIDARG;
+ CStringW value = Lookup(pszPropName);
+ if(value.IsEmpty()) return E_FAIL;
+ CComVariant(value).Detach(pVar);
+ return S_OK;
}
STDMETHODIMP IDSMPropertyBagImpl::Write(LPCOLESTR pszPropName, VARIANT* pVar)
{
- return SetProperty(pszPropName, pVar);
+ return SetProperty(pszPropName, pVar);
}
// IPropertyBag2
STDMETHODIMP IDSMPropertyBagImpl::Read(ULONG cProperties, PROPBAG2* pPropBag, IErrorLog* pErrLog, VARIANT* pvarValue, HRESULT* phrError)
{
- CheckPointer(pPropBag, E_POINTER);
- CheckPointer(pvarValue, E_POINTER);
- CheckPointer(phrError, E_POINTER);
- for(ULONG i = 0; i < cProperties; phrError[i] = S_OK, i++)
- CComVariant(Lookup(pPropBag[i].pstrName)).Detach(pvarValue);
- return S_OK;
+ CheckPointer(pPropBag, E_POINTER);
+ CheckPointer(pvarValue, E_POINTER);
+ CheckPointer(phrError, E_POINTER);
+ for(ULONG i = 0; i < cProperties; phrError[i] = S_OK, i++)
+ CComVariant(Lookup(pPropBag[i].pstrName)).Detach(pvarValue);
+ return S_OK;
}
STDMETHODIMP IDSMPropertyBagImpl::Write(ULONG cProperties, PROPBAG2* pPropBag, VARIANT* pvarValue)
{
- CheckPointer(pPropBag, E_POINTER);
- CheckPointer(pvarValue, E_POINTER);
- for(ULONG i = 0; i < cProperties; i++)
- SetProperty(pPropBag[i].pstrName, &pvarValue[i]);
- return S_OK;
+ CheckPointer(pPropBag, E_POINTER);
+ CheckPointer(pvarValue, E_POINTER);
+ for(ULONG i = 0; i < cProperties; i++)
+ SetProperty(pPropBag[i].pstrName, &pvarValue[i]);
+ return S_OK;
}
STDMETHODIMP IDSMPropertyBagImpl::CountProperties(ULONG* pcProperties)
{
- CheckPointer(pcProperties, E_POINTER);
- *pcProperties = GetSize();
- return S_OK;
+ CheckPointer(pcProperties, E_POINTER);
+ *pcProperties = GetSize();
+ return S_OK;
}
STDMETHODIMP IDSMPropertyBagImpl::GetPropertyInfo(ULONG iProperty, ULONG cProperties, PROPBAG2* pPropBag, ULONG* pcProperties)
{
- CheckPointer(pPropBag, E_POINTER);
- CheckPointer(pcProperties, E_POINTER);
- for(ULONG i = 0; i < cProperties; i++, iProperty++, (*pcProperties)++)
- {
- CStringW key = GetKeyAt(iProperty);
- pPropBag[i].pstrName = (BSTR)CoTaskMemAlloc((key.GetLength() + 1) * sizeof(WCHAR));
- if(!pPropBag[i].pstrName) return E_FAIL;
- wcscpy_s(pPropBag[i].pstrName, key.GetLength() + 1, key);
- }
- return S_OK;
+ CheckPointer(pPropBag, E_POINTER);
+ CheckPointer(pcProperties, E_POINTER);
+ for(ULONG i = 0; i < cProperties; i++, iProperty++, (*pcProperties)++)
+ {
+ CStringW key = GetKeyAt(iProperty);
+ pPropBag[i].pstrName = (BSTR)CoTaskMemAlloc((key.GetLength()+1)*sizeof(WCHAR));
+ if(!pPropBag[i].pstrName) return E_FAIL;
+ wcscpy_s(pPropBag[i].pstrName, key.GetLength()+1, key);
+ }
+ return S_OK;
}
STDMETHODIMP IDSMPropertyBagImpl::LoadObject(LPCOLESTR pstrName, DWORD dwHint, IUnknown* pUnkObject, IErrorLog* pErrLog)
{
- return E_NOTIMPL;
+ return E_NOTIMPL;
}
// IDSMProperyBag
HRESULT IDSMPropertyBagImpl::SetProperty(LPCWSTR key, LPCWSTR value)
{
- CheckPointer(key, E_POINTER);
- CheckPointer(value, E_POINTER);
- if(!Lookup(key).IsEmpty()) SetAt(key, value);
- else Add(key, value);
- return S_OK;
+ CheckPointer(key, E_POINTER);
+ CheckPointer(value, E_POINTER);
+ if(!Lookup(key).IsEmpty()) SetAt(key, value);
+ else Add(key, value);
+ return S_OK;
}
HRESULT IDSMPropertyBagImpl::SetProperty(LPCWSTR key, VARIANT* var)
{
- CheckPointer(key, E_POINTER);
- CheckPointer(var, E_POINTER);
- if((var->vt & (VT_BSTR | VT_BYREF)) != VT_BSTR) return E_INVALIDARG;
- return SetProperty(key, var->bstrVal);
+ CheckPointer(key, E_POINTER);
+ CheckPointer(var, E_POINTER);
+ if((var->vt & (VT_BSTR | VT_BYREF)) != VT_BSTR) return E_INVALIDARG;
+ return SetProperty(key, var->bstrVal);
}
HRESULT IDSMPropertyBagImpl::GetProperty(LPCWSTR key, BSTR* value)
{
- CheckPointer(key, E_POINTER);
- CheckPointer(value, E_POINTER);
- int i = FindKey(key);
- if(i < 0) return E_FAIL;
- *value = GetValueAt(i).AllocSysString();
- return S_OK;
+ CheckPointer(key, E_POINTER);
+ CheckPointer(value, E_POINTER);
+ int i = FindKey(key);
+ if(i < 0) return E_FAIL;
+ *value = GetValueAt(i).AllocSysString();
+ return S_OK;
}
HRESULT IDSMPropertyBagImpl::DelAllProperties()
{
- RemoveAll();
- return S_OK;
+ RemoveAll();
+ return S_OK;
}
HRESULT IDSMPropertyBagImpl::DelProperty(LPCWSTR key)
{
- return Remove(key) ? S_OK : S_FALSE;
+ return Remove(key) ? S_OK : S_FALSE;
}
//
@@ -125,52 +125,51 @@ HRESULT IDSMPropertyBagImpl::DelProperty(LPCWSTR key) CCritSec CDSMResource::m_csResources;
CAtlMap<DWORD, CDSMResource*> CDSMResource::m_resources;
-CDSMResource::CDSMResource()
- : mime(_T("application/octet-stream"))
- , tag(0)
+CDSMResource::CDSMResource()
+ : mime(_T("application/octet-stream"))
+ , tag(0)
{
- CAutoLock cAutoLock(&m_csResources);
- m_resources.SetAt((DWORD)this, this);
+ CAutoLock cAutoLock(&m_csResources);
+ m_resources.SetAt((DWORD)this, this);
}
CDSMResource::CDSMResource(const CDSMResource& r)
{
- *this = r;
+ *this = r;
- CAutoLock cAutoLock(&m_csResources);
- m_resources.SetAt((DWORD)this, this);
+ CAutoLock cAutoLock(&m_csResources);
+ m_resources.SetAt((DWORD)this, this);
}
CDSMResource::CDSMResource(LPCWSTR name, LPCWSTR desc, LPCWSTR mime, BYTE* pData, int len, DWORD_PTR tag)
{
- this->name = name;
- this->desc = desc;
- this->mime = mime;
- data.SetCount(len);
- memcpy(data.GetData(), pData, data.GetCount());
- this->tag = tag;
+ this->name = name;
+ this->desc = desc;
+ this->mime = mime;
+ data.SetCount(len);
+ memcpy(data.GetData(), pData, data.GetCount());
+ this->tag = tag;
- CAutoLock cAutoLock(&m_csResources);
- m_resources.SetAt((DWORD)this, this);
+ CAutoLock cAutoLock(&m_csResources);
+ m_resources.SetAt((DWORD)this, this);
}
CDSMResource::~CDSMResource()
{
- CAutoLock cAutoLock(&m_csResources);
- m_resources.RemoveKey((DWORD)this);
+ CAutoLock cAutoLock(&m_csResources);
+ m_resources.RemoveKey((DWORD)this);
}
CDSMResource& CDSMResource::operator = (const CDSMResource& r)
{
- if(this != &r)
- {
- tag = r.tag;
- name = r.name;
- desc = r.desc;
- mime = r.mime;
- data.Copy(r.data);
- }
- return *this;
+ if( this != &r ) {
+ tag = r.tag;
+ name = r.name;
+ desc = r.desc;
+ mime = r.mime;
+ data.Copy(r.data);
+ }
+ return *this;
}
//
@@ -185,80 +184,72 @@ IDSMResourceBagImpl::IDSMResourceBagImpl() STDMETHODIMP_(DWORD) IDSMResourceBagImpl::ResGetCount()
{
- return m_resources.GetCount();
+ return m_resources.GetCount();
}
STDMETHODIMP IDSMResourceBagImpl::ResGet(DWORD iIndex, BSTR* ppName, BSTR* ppDesc, BSTR* ppMime, BYTE** ppData, DWORD* pDataLen, DWORD_PTR* pTag)
{
- if(ppData) CheckPointer(pDataLen, E_POINTER);
+ if(ppData) CheckPointer(pDataLen, E_POINTER);
- if((INT_PTR)iIndex >= m_resources.GetCount())
- return E_INVALIDARG;
+ if((INT_PTR)iIndex >= m_resources.GetCount())
+ return E_INVALIDARG;
- CDSMResource& r = m_resources[iIndex];
+ CDSMResource& r = m_resources[iIndex];
- if(ppName) *ppName = r.name.AllocSysString();
- if(ppDesc) *ppDesc = r.desc.AllocSysString();
- if(ppMime) *ppMime = r.mime.AllocSysString();
- if(ppData)
- {
- *pDataLen = r.data.GetCount();
- memcpy(*ppData = (BYTE*)CoTaskMemAlloc(*pDataLen), r.data.GetData(), *pDataLen);
- }
- if(pTag) *pTag = r.tag;
+ if(ppName) *ppName = r.name.AllocSysString();
+ if(ppDesc) *ppDesc = r.desc.AllocSysString();
+ if(ppMime) *ppMime = r.mime.AllocSysString();
+ if(ppData) {*pDataLen = r.data.GetCount(); memcpy(*ppData = (BYTE*)CoTaskMemAlloc(*pDataLen), r.data.GetData(), *pDataLen);}
+ if(pTag) *pTag = r.tag;
- return S_OK;
+ return S_OK;
}
STDMETHODIMP IDSMResourceBagImpl::ResSet(DWORD iIndex, LPCWSTR pName, LPCWSTR pDesc, LPCWSTR pMime, BYTE* pData, DWORD len, DWORD_PTR tag)
{
- if((INT_PTR)iIndex >= m_resources.GetCount())
- return E_INVALIDARG;
+ if((INT_PTR)iIndex >= m_resources.GetCount())
+ return E_INVALIDARG;
- CDSMResource& r = m_resources[iIndex];
+ CDSMResource& r = m_resources[iIndex];
- if(pName) r.name = pName;
- if(pDesc) r.desc = pDesc;
- if(pMime) r.mime = pMime;
- if(pData || len == 0)
- {
- r.data.SetCount(len);
- if(pData) memcpy(r.data.GetData(), pData, r.data.GetCount());
- }
- r.tag = tag;
+ if(pName) r.name = pName;
+ if(pDesc) r.desc = pDesc;
+ if(pMime) r.mime = pMime;
+ if(pData || len == 0) {r.data.SetCount(len); if(pData) memcpy(r.data.GetData(), pData, r.data.GetCount());}
+ r.tag = tag;
- return S_OK;
+ return S_OK;
}
STDMETHODIMP IDSMResourceBagImpl::ResAppend(LPCWSTR pName, LPCWSTR pDesc, LPCWSTR pMime, BYTE* pData, DWORD len, DWORD_PTR tag)
{
- return ResSet(m_resources.Add(CDSMResource()), pName, pDesc, pMime, pData, len, tag);
+ return ResSet(m_resources.Add(CDSMResource()), pName, pDesc, pMime, pData, len, tag);
}
STDMETHODIMP IDSMResourceBagImpl::ResRemoveAt(DWORD iIndex)
{
- if((INT_PTR)iIndex >= m_resources.GetCount())
- return E_INVALIDARG;
+ if((INT_PTR)iIndex >= m_resources.GetCount())
+ return E_INVALIDARG;
- m_resources.RemoveAt(iIndex);
+ m_resources.RemoveAt(iIndex);
- return S_OK;
+ return S_OK;
}
STDMETHODIMP IDSMResourceBagImpl::ResRemoveAll(DWORD_PTR tag)
{
- if(tag)
- {
- for(ptrdiff_t i = m_resources.GetCount() - 1; i >= 0; i--)
- if(m_resources[i].tag == tag)
- m_resources.RemoveAt(i);
- }
- else
- {
- m_resources.RemoveAll();
- }
+ if(tag)
+ {
+ for(ptrdiff_t i = m_resources.GetCount() - 1; i >= 0; i--)
+ if(m_resources[i].tag == tag)
+ m_resources.RemoveAt(i);
+ }
+ else
+ {
+ m_resources.RemoveAll();
+ }
- return S_OK;
+ return S_OK;
}
//
@@ -267,39 +258,38 @@ STDMETHODIMP IDSMResourceBagImpl::ResRemoveAll(DWORD_PTR tag) CDSMChapter::CDSMChapter()
{
- order = counter++;
- rt = 0;
+ order = counter++;
+ rt = 0;
}
CDSMChapter::CDSMChapter(REFERENCE_TIME rt, LPCWSTR name)
{
- order = counter++;
- this->rt = rt;
- this->name = name;
+ order = counter++;
+ this->rt = rt;
+ this->name = name;
}
CDSMChapter& CDSMChapter::operator = (const CDSMChapter& c)
{
- if(this != &c)
- {
- order = c.counter;
- rt = c.rt;
- name = c.name;
- }
- return *this;
+ if( this != &c ) {
+ order = c.counter;
+ rt = c.rt;
+ name = c.name;
+ }
+ return *this;
}
int CDSMChapter::counter = 0;
int CDSMChapter::Compare(const void* a, const void* b)
{
- const CDSMChapter* ca = static_cast<const CDSMChapter*>(a);
- const CDSMChapter* cb = static_cast<const CDSMChapter*>(b);
+ const CDSMChapter* ca = static_cast<const CDSMChapter*>(a);
+ const CDSMChapter* cb = static_cast<const CDSMChapter*>(b);
- if(ca->rt > cb->rt) return 1;
- else if(ca->rt < cb->rt) return -1;
+ if(ca->rt > cb->rt) return 1;
+ else if(ca->rt < cb->rt) return -1;
- return ca->order - cb->order;
+ return ca->order - cb->order;
}
//
@@ -308,97 +298,97 @@ int CDSMChapter::Compare(const void* a, const void* b) IDSMChapterBagImpl::IDSMChapterBagImpl()
{
- m_fSorted = false;
+ m_fSorted = false;
}
// IDSMRChapterBag
STDMETHODIMP_(DWORD) IDSMChapterBagImpl::ChapGetCount()
{
- return m_chapters.GetCount();
+ return m_chapters.GetCount();
}
STDMETHODIMP IDSMChapterBagImpl::ChapGet(DWORD iIndex, REFERENCE_TIME* prt, BSTR* ppName)
{
- if((INT_PTR)iIndex >= m_chapters.GetCount())
- return E_INVALIDARG;
+ if((INT_PTR)iIndex >= m_chapters.GetCount())
+ return E_INVALIDARG;
- CDSMChapter& c = m_chapters[iIndex];
+ CDSMChapter& c = m_chapters[iIndex];
- if(prt) *prt = c.rt;
- if(ppName) *ppName = c.name.AllocSysString();
+ if(prt) *prt = c.rt;
+ if(ppName) *ppName = c.name.AllocSysString();
- return S_OK;
+ return S_OK;
}
STDMETHODIMP IDSMChapterBagImpl::ChapSet(DWORD iIndex, REFERENCE_TIME rt, LPCWSTR pName)
{
- if((INT_PTR)iIndex >= m_chapters.GetCount())
- return E_INVALIDARG;
+ if((INT_PTR)iIndex >= m_chapters.GetCount())
+ return E_INVALIDARG;
- CDSMChapter& c = m_chapters[iIndex];
+ CDSMChapter& c = m_chapters[iIndex];
- c.rt = rt;
- if(pName) c.name = pName;
+ c.rt = rt;
+ if(pName) c.name = pName;
- m_fSorted = false;
+ m_fSorted = false;
- return S_OK;
+ return S_OK;
}
STDMETHODIMP IDSMChapterBagImpl::ChapAppend(REFERENCE_TIME rt, LPCWSTR pName)
{
- return ChapSet(m_chapters.Add(CDSMChapter()), rt, pName);
+ return ChapSet(m_chapters.Add(CDSMChapter()), rt, pName);
}
STDMETHODIMP IDSMChapterBagImpl::ChapRemoveAt(DWORD iIndex)
{
- if((INT_PTR)iIndex >= m_chapters.GetCount())
- return E_INVALIDARG;
+ if((INT_PTR)iIndex >= m_chapters.GetCount())
+ return E_INVALIDARG;
- m_chapters.RemoveAt(iIndex);
+ m_chapters.RemoveAt(iIndex);
- return S_OK;
+ return S_OK;
}
STDMETHODIMP IDSMChapterBagImpl::ChapRemoveAll()
{
- m_chapters.RemoveAll();
+ m_chapters.RemoveAll();
- m_fSorted = false;
+ m_fSorted = false;
- return S_OK;
+ return S_OK;
}
STDMETHODIMP_(long) IDSMChapterBagImpl::ChapLookup(REFERENCE_TIME* prt, BSTR* ppName)
{
- CheckPointer(prt, -1);
+ CheckPointer(prt, -1);
- ChapSort();
+ ChapSort();
- int i = range_bsearch(m_chapters, *prt);
- if(i < 0) return -1;
+ int i = range_bsearch(m_chapters, *prt);
+ if(i < 0) return -1;
- *prt = m_chapters[i].rt;
- if(ppName) *ppName = m_chapters[i].name.AllocSysString();
+ *prt = m_chapters[i].rt;
+ if(ppName) *ppName = m_chapters[i].name.AllocSysString();
- return i;
+ return i;
}
STDMETHODIMP IDSMChapterBagImpl::ChapSort()
{
- if(m_fSorted) return S_FALSE;
- qsort(m_chapters.GetData(), m_chapters.GetCount(), sizeof(CDSMChapter), CDSMChapter::Compare);
- m_fSorted = true;
- return S_OK;
+ if(m_fSorted) return S_FALSE;
+ qsort(m_chapters.GetData(), m_chapters.GetCount(), sizeof(CDSMChapter), CDSMChapter::Compare);
+ m_fSorted = true;
+ return S_OK;
}
//
// CDSMChapterBag
//
-CDSMChapterBag::CDSMChapterBag(LPUNKNOWN pUnk, HRESULT* phr)
- : CUnknown(_T("CDSMChapterBag"), NULL)
+CDSMChapterBag::CDSMChapterBag(LPUNKNOWN pUnk, HRESULT* phr)
+ : CUnknown(_T("CDSMChapterBag"), NULL)
{
}
@@ -406,7 +396,7 @@ STDMETHODIMP CDSMChapterBag::NonDelegatingQueryInterface(REFIID riid, void** ppv {
CheckPointer(ppv, E_POINTER);
- return
- QI(IDSMChapterBag)
- __super::NonDelegatingQueryInterface(riid, ppv);
+ return
+ QI(IDSMChapterBag)
+ __super::NonDelegatingQueryInterface(riid, ppv);
}
diff --git a/src/DSUtil/DSMPropertyBag.h b/src/DSUtil/DSMPropertyBag.h index 4b32c975a..0eeb11751 100644 --- a/src/DSUtil/DSMPropertyBag.h +++ b/src/DSUtil/DSMPropertyBag.h @@ -5,199 +5,169 @@ // IDSMPropertyBag
[uuid("232FD5D2-4954-41E7-BF9B-09E1257B1A95")]
-interface IDSMPropertyBag :
-public IPropertyBag2
+interface IDSMPropertyBag : public IPropertyBag2
{
- STDMETHOD(SetProperty)(LPCWSTR key, LPCWSTR value) = 0;
- STDMETHOD(SetProperty)(LPCWSTR key, VARIANT* var) = 0;
- STDMETHOD(GetProperty)(LPCWSTR key, BSTR* value) = 0;
- STDMETHOD(DelAllProperties)() = 0;
- STDMETHOD(DelProperty)(LPCWSTR key) = 0;
+ STDMETHOD(SetProperty) (LPCWSTR key, LPCWSTR value) = 0;
+ STDMETHOD(SetProperty) (LPCWSTR key, VARIANT* var) = 0;
+ STDMETHOD(GetProperty) (LPCWSTR key, BSTR* value) = 0;
+ STDMETHOD(DelAllProperties) () = 0;
+ STDMETHOD(DelProperty) (LPCWSTR key) = 0;
};
class IDSMPropertyBagImpl : public ATL::CSimpleMap<CStringW, CStringW>, public IDSMPropertyBag, public IPropertyBag
{
- BOOL Add(const CStringW& key, const CStringW& val)
- {
- return __super::Add(key, val);
- }
- BOOL SetAt(const CStringW& key, const CStringW& val)
- {
- return __super::SetAt(key, val);
- }
+ BOOL Add(const CStringW& key, const CStringW& val) {return __super::Add(key, val);}
+ BOOL SetAt(const CStringW& key, const CStringW& val) {return __super::SetAt(key, val);}
public:
- IDSMPropertyBagImpl();
- virtual ~IDSMPropertyBagImpl();
+ IDSMPropertyBagImpl();
+ virtual ~IDSMPropertyBagImpl();
- // IPropertyBag
+ // IPropertyBag
STDMETHODIMP Read(LPCOLESTR pszPropName, VARIANT* pVar, IErrorLog* pErrorLog);
STDMETHODIMP Write(LPCOLESTR pszPropName, VARIANT* pVar);
- // IPropertyBag2
+ // IPropertyBag2
- STDMETHODIMP Read(ULONG cProperties, PROPBAG2* pPropBag, IErrorLog* pErrLog, VARIANT* pvarValue, HRESULT* phrError);
- STDMETHODIMP Write(ULONG cProperties, PROPBAG2* pPropBag, VARIANT* pvarValue);
- STDMETHODIMP CountProperties(ULONG* pcProperties);
- STDMETHODIMP GetPropertyInfo(ULONG iProperty, ULONG cProperties, PROPBAG2* pPropBag, ULONG* pcProperties);
- STDMETHODIMP LoadObject(LPCOLESTR pstrName, DWORD dwHint, IUnknown* pUnkObject, IErrorLog* pErrLog);
+ STDMETHODIMP Read(ULONG cProperties, PROPBAG2* pPropBag, IErrorLog* pErrLog, VARIANT* pvarValue, HRESULT* phrError);
+ STDMETHODIMP Write(ULONG cProperties, PROPBAG2* pPropBag, VARIANT* pvarValue);
+ STDMETHODIMP CountProperties(ULONG* pcProperties);
+ STDMETHODIMP GetPropertyInfo(ULONG iProperty, ULONG cProperties, PROPBAG2* pPropBag, ULONG* pcProperties);
+ STDMETHODIMP LoadObject(LPCOLESTR pstrName, DWORD dwHint, IUnknown* pUnkObject, IErrorLog* pErrLog);
- // IDSMPropertyBag
+ // IDSMPropertyBag
- STDMETHODIMP SetProperty(LPCWSTR key, LPCWSTR value);
- STDMETHODIMP SetProperty(LPCWSTR key, VARIANT* var);
- STDMETHODIMP GetProperty(LPCWSTR key, BSTR* value);
- STDMETHODIMP DelAllProperties();
- STDMETHODIMP DelProperty(LPCWSTR key);
+ STDMETHODIMP SetProperty(LPCWSTR key, LPCWSTR value);
+ STDMETHODIMP SetProperty(LPCWSTR key, VARIANT* var);
+ STDMETHODIMP GetProperty(LPCWSTR key, BSTR* value);
+ STDMETHODIMP DelAllProperties();
+ STDMETHODIMP DelProperty(LPCWSTR key);
};
// IDSMResourceBag
[uuid("EBAFBCBE-BDE0-489A-9789-05D5692E3A93")]
-interface IDSMResourceBag :
-public IUnknown
+interface IDSMResourceBag : public IUnknown
{
- STDMETHOD_(DWORD, ResGetCount)() = 0;
- STDMETHOD(ResGet)(DWORD iIndex, BSTR* ppName, BSTR* ppDesc, BSTR* ppMime, BYTE** ppData, DWORD* pDataLen, DWORD_PTR* pTag) = 0;
- STDMETHOD(ResSet)(DWORD iIndex, LPCWSTR pName, LPCWSTR pDesc, LPCWSTR pMime, BYTE* pData, DWORD len, DWORD_PTR tag) = 0;
- STDMETHOD(ResAppend)(LPCWSTR pName, LPCWSTR pDesc, LPCWSTR pMime, BYTE* pData, DWORD len, DWORD_PTR tag) = 0;
- STDMETHOD(ResRemoveAt)(DWORD iIndex) = 0;
- STDMETHOD(ResRemoveAll)(DWORD_PTR tag) = 0;
+ STDMETHOD_(DWORD, ResGetCount) () = 0;
+ STDMETHOD(ResGet) (DWORD iIndex, BSTR* ppName, BSTR* ppDesc, BSTR* ppMime, BYTE** ppData, DWORD* pDataLen, DWORD_PTR* pTag) = 0;
+ STDMETHOD(ResSet) (DWORD iIndex, LPCWSTR pName, LPCWSTR pDesc, LPCWSTR pMime, BYTE* pData, DWORD len, DWORD_PTR tag) = 0;
+ STDMETHOD(ResAppend) (LPCWSTR pName, LPCWSTR pDesc, LPCWSTR pMime, BYTE* pData, DWORD len, DWORD_PTR tag) = 0;
+ STDMETHOD(ResRemoveAt) (DWORD iIndex) = 0;
+ STDMETHOD(ResRemoveAll) (DWORD_PTR tag) = 0;
};
class CDSMResource
{
public:
- DWORD_PTR tag;
- CStringW name, desc, mime;
- CAtlArray<BYTE> data;
- CDSMResource();
- CDSMResource(const CDSMResource& r);
- CDSMResource(LPCWSTR name, LPCWSTR desc, LPCWSTR mime, BYTE* pData, int len, DWORD_PTR tag = 0);
- virtual ~CDSMResource();
- CDSMResource& operator = (const CDSMResource& r);
-
- // global access to all resources
- static CCritSec m_csResources;
- static CAtlMap<DWORD, CDSMResource*> m_resources;
+ DWORD_PTR tag;
+ CStringW name, desc, mime;
+ CAtlArray<BYTE> data;
+ CDSMResource();
+ CDSMResource(const CDSMResource& r);
+ CDSMResource(LPCWSTR name, LPCWSTR desc, LPCWSTR mime, BYTE* pData, int len, DWORD_PTR tag = 0);
+ virtual ~CDSMResource();
+ CDSMResource& operator = (const CDSMResource& r);
+
+ // global access to all resources
+ static CCritSec m_csResources;
+ static CAtlMap<DWORD, CDSMResource*> m_resources;
};
class IDSMResourceBagImpl : public IDSMResourceBag
{
protected:
- CAtlArray<CDSMResource> m_resources;
+ CAtlArray<CDSMResource> m_resources;
public:
- IDSMResourceBagImpl();
+ IDSMResourceBagImpl();
- void operator += (const CDSMResource& r)
- {
- m_resources.Add(r);
- }
+ void operator += (const CDSMResource& r) {m_resources.Add(r);}
- // IDSMResourceBag
+ // IDSMResourceBag
- STDMETHODIMP_(DWORD) ResGetCount();
- STDMETHODIMP ResGet(DWORD iIndex, BSTR* ppName, BSTR* ppDesc, BSTR* ppMime, BYTE** ppData, DWORD* pDataLen, DWORD_PTR* pTag = NULL);
- STDMETHODIMP ResSet(DWORD iIndex, LPCWSTR pName, LPCWSTR pDesc, LPCWSTR pMime, BYTE* pData, DWORD len, DWORD_PTR tag = 0);
- STDMETHODIMP ResAppend(LPCWSTR pName, LPCWSTR pDesc, LPCWSTR pMime, BYTE* pData, DWORD len, DWORD_PTR tag = 0);
- STDMETHODIMP ResRemoveAt(DWORD iIndex);
- STDMETHODIMP ResRemoveAll(DWORD_PTR tag = 0);
+ STDMETHODIMP_(DWORD) ResGetCount();
+ STDMETHODIMP ResGet(DWORD iIndex, BSTR* ppName, BSTR* ppDesc, BSTR* ppMime, BYTE** ppData, DWORD* pDataLen, DWORD_PTR* pTag = NULL);
+ STDMETHODIMP ResSet(DWORD iIndex, LPCWSTR pName, LPCWSTR pDesc, LPCWSTR pMime, BYTE* pData, DWORD len, DWORD_PTR tag = 0);
+ STDMETHODIMP ResAppend(LPCWSTR pName, LPCWSTR pDesc, LPCWSTR pMime, BYTE* pData, DWORD len, DWORD_PTR tag = 0);
+ STDMETHODIMP ResRemoveAt(DWORD iIndex);
+ STDMETHODIMP ResRemoveAll(DWORD_PTR tag = 0);
};
// IDSMChapterBag
[uuid("2D0EBE73-BA82-4E90-859B-C7C48ED3650F")]
-interface IDSMChapterBag :
-public IUnknown
+interface IDSMChapterBag : public IUnknown
{
- STDMETHOD_(DWORD, ChapGetCount)() = 0;
- STDMETHOD(ChapGet)(DWORD iIndex, REFERENCE_TIME* prt, BSTR* ppName) = 0;
- STDMETHOD(ChapSet)(DWORD iIndex, REFERENCE_TIME rt, LPCWSTR pName) = 0;
- STDMETHOD(ChapAppend)(REFERENCE_TIME rt, LPCWSTR pName) = 0;
- STDMETHOD(ChapRemoveAt)(DWORD iIndex) = 0;
- STDMETHOD(ChapRemoveAll)() = 0;
- STDMETHOD_(long, ChapLookup)(REFERENCE_TIME* prt, BSTR* ppName) = 0;
- STDMETHOD(ChapSort)() = 0;
+ STDMETHOD_(DWORD, ChapGetCount) () = 0;
+ STDMETHOD(ChapGet) (DWORD iIndex, REFERENCE_TIME* prt, BSTR* ppName) = 0;
+ STDMETHOD(ChapSet) (DWORD iIndex, REFERENCE_TIME rt, LPCWSTR pName) = 0;
+ STDMETHOD(ChapAppend) (REFERENCE_TIME rt, LPCWSTR pName) = 0;
+ STDMETHOD(ChapRemoveAt) (DWORD iIndex) = 0;
+ STDMETHOD(ChapRemoveAll) () = 0;
+ STDMETHOD_(long, ChapLookup) (REFERENCE_TIME* prt, BSTR* ppName) = 0;
+ STDMETHOD(ChapSort) () = 0;
};
class CDSMChapter
{
- static int counter;
- int order;
+ static int counter;
+ int order;
public:
- REFERENCE_TIME rt;
- CStringW name;
- CDSMChapter();
- CDSMChapter(REFERENCE_TIME rt, LPCWSTR name);
- CDSMChapter& operator = (const CDSMChapter& c);
- static int Compare(const void* a, const void* b);
+ REFERENCE_TIME rt;
+ CStringW name;
+ CDSMChapter();
+ CDSMChapter(REFERENCE_TIME rt, LPCWSTR name);
+ CDSMChapter& operator = (const CDSMChapter& c);
+ static int Compare(const void* a, const void* b);
};
class IDSMChapterBagImpl : public IDSMChapterBag
{
protected:
- CAtlArray<CDSMChapter> m_chapters;
- bool m_fSorted;
+ CAtlArray<CDSMChapter> m_chapters;
+ bool m_fSorted;
public:
- IDSMChapterBagImpl();
-
- void operator += (const CDSMChapter& c)
- {
- m_chapters.Add(c);
- m_fSorted = false;
- }
-
- // IDSMChapterBag
-
- STDMETHODIMP_(DWORD) ChapGetCount();
- STDMETHODIMP ChapGet(DWORD iIndex, REFERENCE_TIME* prt, BSTR* ppName = NULL);
- STDMETHODIMP ChapSet(DWORD iIndex, REFERENCE_TIME rt, LPCWSTR pName);
- STDMETHODIMP ChapAppend(REFERENCE_TIME rt, LPCWSTR pName);
- STDMETHODIMP ChapRemoveAt(DWORD iIndex);
- STDMETHODIMP ChapRemoveAll();
- STDMETHODIMP_(long) ChapLookup(REFERENCE_TIME* prt, BSTR* ppName = NULL);
- STDMETHODIMP ChapSort();
+ IDSMChapterBagImpl();
+
+ void operator += (const CDSMChapter& c) {m_chapters.Add(c); m_fSorted = false;}
+
+ // IDSMChapterBag
+
+ STDMETHODIMP_(DWORD) ChapGetCount();
+ STDMETHODIMP ChapGet(DWORD iIndex, REFERENCE_TIME* prt, BSTR* ppName = NULL);
+ STDMETHODIMP ChapSet(DWORD iIndex, REFERENCE_TIME rt, LPCWSTR pName);
+ STDMETHODIMP ChapAppend(REFERENCE_TIME rt, LPCWSTR pName);
+ STDMETHODIMP ChapRemoveAt(DWORD iIndex);
+ STDMETHODIMP ChapRemoveAll();
+ STDMETHODIMP_(long) ChapLookup(REFERENCE_TIME* prt, BSTR* ppName = NULL);
+ STDMETHODIMP ChapSort();
};
class CDSMChapterBag : public CUnknown, public IDSMChapterBagImpl
{
public:
- CDSMChapterBag(LPUNKNOWN pUnk, HRESULT* phr);
+ CDSMChapterBag(LPUNKNOWN pUnk, HRESULT* phr);
- DECLARE_IUNKNOWN;
- STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
+ DECLARE_IUNKNOWN;
+ STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
};
template<class T>
int range_bsearch(const CAtlArray<T>& array, REFERENCE_TIME rt)
{
- int i = 0, j = array.GetCount() - 1, ret = -1;
- if(j >= 0 && rt >= array[j].rt) return j;
- while(i < j)
- {
- int mid = (i + j) >> 1;
- REFERENCE_TIME midrt = array[mid].rt;
- if(rt == midrt)
- {
- ret = mid;
- break;
- }
- else if(rt < midrt)
- {
- ret = -1;
- if(j == mid) mid--;
- j = mid;
- }
- else if(rt > midrt)
- {
- ret = mid;
- if(i == mid) mid++;
- i = mid;
- }
- }
- return ret;
+ int i = 0, j = array.GetCount() - 1, ret = -1;
+ if(j >= 0 && rt >= array[j].rt) return j;
+ while(i < j)
+ {
+ int mid = (i + j) >> 1;
+ REFERENCE_TIME midrt = array[mid].rt;
+ if(rt == midrt) {ret = mid; break;}
+ else if(rt < midrt) {ret = -1; if(j == mid) mid--; j = mid;}
+ else if(rt > midrt) {ret = mid; if(i == mid) mid++; i = mid;}
+ }
+ return ret;
}
diff --git a/src/DSUtil/DSUtil.cpp b/src/DSUtil/DSUtil.cpp index 2b5dd882d..d43328924 100644 --- a/src/DSUtil/DSUtil.cpp +++ b/src/DSUtil/DSUtil.cpp @@ -1,4 +1,4 @@ -/*
+/*
* Copyright (C) 2003-2006 Gabest
* http://www.gabest.org
*
@@ -6,15 +6,15 @@ * it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
- *
+ *
* This Program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with GNU Make; see the file COPYING. If not, write to
- * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
+ * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
* http://www.gnu.org/copyleft/gpl.html
*
*/
@@ -34,2451 +34,2390 @@ void DumpStreamConfig(TCHAR* fn, IAMStreamConfig* pAMVSCCap)
{
- CString s;
- CStdioFile f;
- if(!f.Open(fn, CFile::modeCreate | CFile::modeWrite | CFile::typeText))
- return;
-
- int cnt = 0, size = 0;
- if(FAILED(pAMVSCCap->GetNumberOfCapabilities(&cnt, &size)))
- return;
-
- s.Empty();
- s.Format(_T("cnt %d, size %d\n"), cnt, size);
- f.WriteString(s);
-
- if(size == sizeof(VIDEO_STREAM_CONFIG_CAPS))
- {
- CString ss;
- for(ptrdiff_t i = 0; i < cnt; i++)
- {
- AM_MEDIA_TYPE* pmt = NULL;
-
- VIDEO_STREAM_CONFIG_CAPS caps;
- memset(&caps, 0, sizeof(caps));
-
- s.Empty();
- ss.Format(_T("%d\n"), i);
- s += ss;
- f.WriteString(s);
-
- if(FAILED(pAMVSCCap->GetStreamCaps(i, &pmt, (BYTE*)&caps)))
- continue;
-
- {
- s.Empty();
- ss.Format(_T("VIDEO_STREAM_CONFIG_CAPS\n"));
- s += ss;
- ss.Format(_T("\tVideoStandard 0x%08x\n"), caps.VideoStandard);
- s += ss;
- ss.Format(_T("\tInputSize %dx%d\n"), caps.InputSize);
- s += ss;
- ss.Format(_T("\tCroppingSize %dx%d - %dx%d\n"), caps.MinCroppingSize, caps.MaxCroppingSize);
- s += ss;
- ss.Format(_T("\tCropGranularity %d, %d\n"), caps.CropGranularityX, caps.CropGranularityY);
- s += ss;
- ss.Format(_T("\tCropAlign %d, %d\n"), caps.CropAlignX, caps.CropAlignY);
- s += ss;
- ss.Format(_T("\tOutputSize %dx%d - %dx%d\n"), caps.MinOutputSize, caps.MaxOutputSize);
- s += ss;
- ss.Format(_T("\tOutputGranularity %d, %d\n"), caps.OutputGranularityX, caps.OutputGranularityY);
- s += ss;
- ss.Format(_T("\tStretchTaps %d, %d\n"), caps.StretchTapsX, caps.StretchTapsY);
- s += ss;
- ss.Format(_T("\tShrinkTaps %d, %d\n"), caps.ShrinkTapsX, caps.ShrinkTapsY);
- s += ss;
- ss.Format(_T("\tFrameInterval %I64d, %I64d (%.4f, %.4f)\n"),
- caps.MinFrameInterval, caps.MaxFrameInterval,
- (float)10000000 / caps.MinFrameInterval, (float)10000000 / caps.MaxFrameInterval);
- s += ss;
- ss.Format(_T("\tBitsPerSecond %d - %d\n"), caps.MinBitsPerSecond, caps.MaxBitsPerSecond);
- s += ss;
- f.WriteString(s);
- }
-
- BITMAPINFOHEADER* pbh;
- if(pmt->formattype == FORMAT_VideoInfo)
- {
- VIDEOINFOHEADER* vih = (VIDEOINFOHEADER*)pmt->pbFormat;
- pbh = &vih->bmiHeader;
-
- s.Empty();
- ss.Format(_T("FORMAT_VideoInfo\n"));
- s += ss;
- ss.Format(_T("\tAvgTimePerFrame %I64d, %.4f\n"), vih->AvgTimePerFrame, (float)10000000 / vih->AvgTimePerFrame);
- s += ss;
- ss.Format(_T("\trcSource %d,%d,%d,%d\n"), vih->rcSource);
- s += ss;
- ss.Format(_T("\trcTarget %d,%d,%d,%d\n"), vih->rcTarget);
- s += ss;
- f.WriteString(s);
- }
- else if(pmt->formattype == FORMAT_VideoInfo2)
- {
- VIDEOINFOHEADER2* vih = (VIDEOINFOHEADER2*)pmt->pbFormat;
- pbh = &vih->bmiHeader;
-
- s.Empty();
- ss.Format(_T("FORMAT_VideoInfo2\n"));
- s += ss;
- ss.Format(_T("\tAvgTimePerFrame %I64d, %.4f\n"), vih->AvgTimePerFrame, (float)10000000 / vih->AvgTimePerFrame);
- s += ss;
- ss.Format(_T("\trcSource %d,%d,%d,%d\n"), vih->rcSource);
- s += ss;
- ss.Format(_T("\trcTarget %d,%d,%d,%d\n"), vih->rcTarget);
- s += ss;
- ss.Format(_T("\tdwInterlaceFlags 0x%x\n"), vih->dwInterlaceFlags);
- s += ss;
- ss.Format(_T("\tdwPictAspectRatio %d:%d\n"), vih->dwPictAspectRatioX, vih->dwPictAspectRatioY);
- s += ss;
- f.WriteString(s);
- }
- else
- {
- DeleteMediaType(pmt);
- continue;
- }
-
- s.Empty();
- ss.Format(_T("BITMAPINFOHEADER\n"));
- s += ss;
- ss.Format(_T("\tbiCompression %x\n"), pbh->biCompression);
- s += ss;
- ss.Format(_T("\tbiWidth %d\n"), pbh->biWidth);
- s += ss;
- ss.Format(_T("\tbiHeight %d\n"), pbh->biHeight);
- s += ss;
- ss.Format(_T("\tbiBitCount %d\n"), pbh->biBitCount);
- s += ss;
- ss.Format(_T("\tbiPlanes %d\n"), pbh->biPlanes);
- s += ss;
- ss.Format(_T("\tbiSizeImage %d\n"), pbh->biSizeImage);
- s += ss;
- f.WriteString(s);
-
- DeleteMediaType(pmt);
- }
- }
- else if(size == sizeof(AUDIO_STREAM_CONFIG_CAPS))
- {
- // TODO
- }
+ CString s;
+ CStdioFile f;
+ if(!f.Open(fn, CFile::modeCreate|CFile::modeWrite|CFile::typeText))
+ return;
+
+ int cnt = 0, size = 0;
+ if(FAILED(pAMVSCCap->GetNumberOfCapabilities(&cnt, &size)))
+ return;
+
+ s.Empty();
+ s.Format(_T("cnt %d, size %d\n"), cnt, size);
+ f.WriteString(s);
+
+ if(size == sizeof(VIDEO_STREAM_CONFIG_CAPS))
+ {
+ CString ss;
+ for(ptrdiff_t i = 0; i < cnt; i++)
+ {
+ AM_MEDIA_TYPE* pmt = NULL;
+
+ VIDEO_STREAM_CONFIG_CAPS caps;
+ memset(&caps, 0, sizeof(caps));
+
+ s.Empty();
+ ss.Format(_T("%d\n"), i); s += ss;
+ f.WriteString(s);
+
+ if(FAILED(pAMVSCCap->GetStreamCaps(i, &pmt, (BYTE*)&caps)))
+ continue;
+
+ {
+ s.Empty();
+ ss.Format(_T("VIDEO_STREAM_CONFIG_CAPS\n")); s += ss;
+ ss.Format(_T("\tVideoStandard 0x%08x\n"), caps.VideoStandard); s += ss;
+ ss.Format(_T("\tInputSize %dx%d\n"), caps.InputSize); s += ss;
+ ss.Format(_T("\tCroppingSize %dx%d - %dx%d\n"), caps.MinCroppingSize, caps.MaxCroppingSize); s += ss;
+ ss.Format(_T("\tCropGranularity %d, %d\n"), caps.CropGranularityX, caps.CropGranularityY); s += ss;
+ ss.Format(_T("\tCropAlign %d, %d\n"), caps.CropAlignX, caps.CropAlignY); s += ss;
+ ss.Format(_T("\tOutputSize %dx%d - %dx%d\n"), caps.MinOutputSize, caps.MaxOutputSize); s += ss;
+ ss.Format(_T("\tOutputGranularity %d, %d\n"), caps.OutputGranularityX, caps.OutputGranularityY); s += ss;
+ ss.Format(_T("\tStretchTaps %d, %d\n"), caps.StretchTapsX, caps.StretchTapsY); s += ss;
+ ss.Format(_T("\tShrinkTaps %d, %d\n"), caps.ShrinkTapsX, caps.ShrinkTapsY); s += ss;
+ ss.Format(_T("\tFrameInterval %I64d, %I64d (%.4f, %.4f)\n"),
+ caps.MinFrameInterval, caps.MaxFrameInterval,
+ (float)10000000/caps.MinFrameInterval, (float)10000000/caps.MaxFrameInterval); s += ss;
+ ss.Format(_T("\tBitsPerSecond %d - %d\n"), caps.MinBitsPerSecond, caps.MaxBitsPerSecond); s += ss;
+ f.WriteString(s);
+ }
+
+ BITMAPINFOHEADER* pbh;
+ if(pmt->formattype == FORMAT_VideoInfo)
+ {
+ VIDEOINFOHEADER* vih = (VIDEOINFOHEADER*)pmt->pbFormat;
+ pbh = &vih->bmiHeader;
+
+ s.Empty();
+ ss.Format(_T("FORMAT_VideoInfo\n")); s += ss;
+ ss.Format(_T("\tAvgTimePerFrame %I64d, %.4f\n"), vih->AvgTimePerFrame, (float)10000000/vih->AvgTimePerFrame); s += ss;
+ ss.Format(_T("\trcSource %d,%d,%d,%d\n"), vih->rcSource); s += ss;
+ ss.Format(_T("\trcTarget %d,%d,%d,%d\n"), vih->rcTarget); s += ss;
+ f.WriteString(s);
+ }
+ else if(pmt->formattype == FORMAT_VideoInfo2)
+ {
+ VIDEOINFOHEADER2* vih = (VIDEOINFOHEADER2*)pmt->pbFormat;
+ pbh = &vih->bmiHeader;
+
+ s.Empty();
+ ss.Format(_T("FORMAT_VideoInfo2\n")); s += ss;
+ ss.Format(_T("\tAvgTimePerFrame %I64d, %.4f\n"), vih->AvgTimePerFrame, (float)10000000/vih->AvgTimePerFrame); s += ss;
+ ss.Format(_T("\trcSource %d,%d,%d,%d\n"), vih->rcSource); s += ss;
+ ss.Format(_T("\trcTarget %d,%d,%d,%d\n"), vih->rcTarget); s += ss;
+ ss.Format(_T("\tdwInterlaceFlags 0x%x\n"), vih->dwInterlaceFlags); s += ss;
+ ss.Format(_T("\tdwPictAspectRatio %d:%d\n"), vih->dwPictAspectRatioX, vih->dwPictAspectRatioY); s += ss;
+ f.WriteString(s);
+ }
+ else
+ {
+ DeleteMediaType(pmt);
+ continue;
+ }
+
+ s.Empty();
+ ss.Format(_T("BITMAPINFOHEADER\n")); s += ss;
+ ss.Format(_T("\tbiCompression %x\n"), pbh->biCompression); s += ss;
+ ss.Format(_T("\tbiWidth %d\n"), pbh->biWidth); s += ss;
+ ss.Format(_T("\tbiHeight %d\n"), pbh->biHeight); s += ss;
+ ss.Format(_T("\tbiBitCount %d\n"), pbh->biBitCount); s += ss;
+ ss.Format(_T("\tbiPlanes %d\n"), pbh->biPlanes); s += ss;
+ ss.Format(_T("\tbiSizeImage %d\n"), pbh->biSizeImage); s += ss;
+ f.WriteString(s);
+
+ DeleteMediaType(pmt);
+ }
+ }
+ else if(size == sizeof(AUDIO_STREAM_CONFIG_CAPS))
+ {
+ // TODO
+ }
}
int CountPins(IBaseFilter* pBF, int& nIn, int& nOut, int& nInC, int& nOutC)
{
- nIn = nOut = 0;
- nInC = nOutC = 0;
+ nIn = nOut = 0;
+ nInC = nOutC = 0;
- BeginEnumPins(pBF, pEP, pPin)
- {
- PIN_DIRECTION dir;
- if(SUCCEEDED(pPin->QueryDirection(&dir)))
- {
- CComPtr<IPin> pPinConnectedTo;
- pPin->ConnectedTo(&pPinConnectedTo);
+ BeginEnumPins(pBF, pEP, pPin)
+ {
+ PIN_DIRECTION dir;
+ if(SUCCEEDED(pPin->QueryDirection(&dir)))
+ {
+ CComPtr<IPin> pPinConnectedTo;
+ pPin->ConnectedTo(&pPinConnectedTo);
- if(dir == PINDIR_INPUT)
- {
- nIn++;
- if(pPinConnectedTo) nInC++;
- }
- else if(dir == PINDIR_OUTPUT)
- {
- nOut++;
- if(pPinConnectedTo) nOutC++;
- }
- }
- }
- EndEnumPins
+ if(dir == PINDIR_INPUT) {nIn++; if(pPinConnectedTo) nInC++;}
+ else if(dir == PINDIR_OUTPUT) {nOut++; if(pPinConnectedTo) nOutC++;}
+ }
+ }
+ EndEnumPins
- return(nIn + nOut);
+ return(nIn+nOut);
}
bool IsSplitter(IBaseFilter* pBF, bool fCountConnectedOnly)
{
- int nIn, nOut, nInC, nOutC;
- CountPins(pBF, nIn, nOut, nInC, nOutC);
- return(fCountConnectedOnly ? nOutC > 1 : nOut > 1);
+ int nIn, nOut, nInC, nOutC;
+ CountPins(pBF, nIn, nOut, nInC, nOutC);
+ return(fCountConnectedOnly ? nOutC > 1 : nOut > 1);
}
bool IsMultiplexer(IBaseFilter* pBF, bool fCountConnectedOnly)
{
- int nIn, nOut, nInC, nOutC;
- CountPins(pBF, nIn, nOut, nInC, nOutC);
- return(fCountConnectedOnly ? nInC > 1 : nIn > 1);
+ int nIn, nOut, nInC, nOutC;
+ CountPins(pBF, nIn, nOut, nInC, nOutC);
+ return(fCountConnectedOnly ? nInC > 1 : nIn > 1);
}
bool IsStreamStart(IBaseFilter* pBF)
{
- CComQIPtr<IAMFilterMiscFlags> pAMMF(pBF);
- if(pAMMF && pAMMF->GetMiscFlags()&AM_FILTER_MISC_FLAGS_IS_SOURCE)
- return(true);
+ CComQIPtr<IAMFilterMiscFlags> pAMMF(pBF);
+ if(pAMMF && pAMMF->GetMiscFlags()&AM_FILTER_MISC_FLAGS_IS_SOURCE)
+ return(true);
- int nIn, nOut, nInC, nOutC;
- CountPins(pBF, nIn, nOut, nInC, nOutC);
- AM_MEDIA_TYPE mt;
- CComPtr<IPin> pIn = GetFirstPin(pBF);
- return((nOut > 1)
- || (nOut > 0 && nIn == 1 && pIn && SUCCEEDED(pIn->ConnectionMediaType(&mt)) && mt.majortype == MEDIATYPE_Stream));
+ int nIn, nOut, nInC, nOutC;
+ CountPins(pBF, nIn, nOut, nInC, nOutC);
+ AM_MEDIA_TYPE mt;
+ CComPtr<IPin> pIn = GetFirstPin(pBF);
+ return((nOut > 1)
+ || (nOut > 0 && nIn == 1 && pIn && SUCCEEDED(pIn->ConnectionMediaType(&mt)) && mt.majortype == MEDIATYPE_Stream));
}
bool IsStreamEnd(IBaseFilter* pBF)
{
- int nIn, nOut, nInC, nOutC;
- CountPins(pBF, nIn, nOut, nInC, nOutC);
- return(nOut == 0);
+ int nIn, nOut, nInC, nOutC;
+ CountPins(pBF, nIn, nOut, nInC, nOutC);
+ return(nOut == 0);
}
bool IsVideoRenderer(IBaseFilter* pBF)
{
- int nIn, nOut, nInC, nOutC;
- CountPins(pBF, nIn, nOut, nInC, nOutC);
+ int nIn, nOut, nInC, nOutC;
+ CountPins(pBF, nIn, nOut, nInC, nOutC);
- if(nInC > 0 && nOut == 0)
- {
- BeginEnumPins(pBF, pEP, pPin)
- {
- AM_MEDIA_TYPE mt;
- if(S_OK != pPin->ConnectionMediaType(&mt))
- continue;
+ if(nInC > 0 && nOut == 0)
+ {
+ BeginEnumPins(pBF, pEP, pPin)
+ {
+ AM_MEDIA_TYPE mt;
+ if(S_OK != pPin->ConnectionMediaType(&mt))
+ continue;
- FreeMediaType(mt);
+ FreeMediaType(mt);
- return(!!(mt.majortype == MEDIATYPE_Video));
- /*&& (mt.formattype == FORMAT_VideoInfo || mt.formattype == FORMAT_VideoInfo2));*/
- }
- EndEnumPins
- }
+ return(!!(mt.majortype == MEDIATYPE_Video));
+ /*&& (mt.formattype == FORMAT_VideoInfo || mt.formattype == FORMAT_VideoInfo2));*/
+ }
+ EndEnumPins
+ }
- CLSID clsid;
- memcpy(&clsid, &GUID_NULL, sizeof(clsid));
- pBF->GetClassID(&clsid);
+ CLSID clsid;
+ memcpy(&clsid, &GUID_NULL, sizeof(clsid));
+ pBF->GetClassID(&clsid);
- return(clsid == CLSID_VideoRenderer || clsid == CLSID_VideoRendererDefault);
+ return(clsid == CLSID_VideoRenderer || clsid == CLSID_VideoRendererDefault);
}
#include <initguid.h>
-DEFINE_GUID(CLSID_ReClock,
- 0x9dc15360, 0x914c, 0x46b8, 0xb9, 0xdf, 0xbf, 0xe6, 0x7f, 0xd3, 0x6c, 0x6a);
+DEFINE_GUID(CLSID_ReClock,
+0x9dc15360, 0x914c, 0x46b8, 0xb9, 0xdf, 0xbf, 0xe6, 0x7f, 0xd3, 0x6c, 0x6a);
bool IsAudioWaveRenderer(IBaseFilter* pBF)
{
- int nIn, nOut, nInC, nOutC;
- CountPins(pBF, nIn, nOut, nInC, nOutC);
+ int nIn, nOut, nInC, nOutC;
+ CountPins(pBF, nIn, nOut, nInC, nOutC);
- if(nInC > 0 && nOut == 0 && CComQIPtr<IBasicAudio>(pBF))
- {
- BeginEnumPins(pBF, pEP, pPin)
- {
- AM_MEDIA_TYPE mt;
- if(S_OK != pPin->ConnectionMediaType(&mt))
- continue;
+ if(nInC > 0 && nOut == 0 && CComQIPtr<IBasicAudio>(pBF))
+ {
+ BeginEnumPins(pBF, pEP, pPin)
+ {
+ AM_MEDIA_TYPE mt;
+ if(S_OK != pPin->ConnectionMediaType(&mt))
+ continue;
- FreeMediaType(mt);
+ FreeMediaType(mt);
- return(!!(mt.majortype == MEDIATYPE_Audio)
- /*&& mt.formattype == FORMAT_WaveFormatEx*/);
- }
- EndEnumPins
- }
+ return(!!(mt.majortype == MEDIATYPE_Audio)
+ /*&& mt.formattype == FORMAT_WaveFormatEx*/);
+ }
+ EndEnumPins
+ }
- CLSID clsid;
- memcpy(&clsid, &GUID_NULL, sizeof(clsid));
- pBF->GetClassID(&clsid);
+ CLSID clsid;
+ memcpy(&clsid, &GUID_NULL, sizeof(clsid));
+ pBF->GetClassID(&clsid);
- return(clsid == CLSID_DSoundRender || clsid == CLSID_AudioRender || clsid == CLSID_ReClock
- || clsid == __uuidof(CNullAudioRenderer) || clsid == __uuidof(CNullUAudioRenderer));
+ return(clsid == CLSID_DSoundRender || clsid == CLSID_AudioRender || clsid == CLSID_ReClock
+ || clsid == __uuidof(CNullAudioRenderer) || clsid == __uuidof(CNullUAudioRenderer));
}
IBaseFilter* GetUpStreamFilter(IBaseFilter* pBF, IPin* pInputPin)
{
- return GetFilterFromPin(GetUpStreamPin(pBF, pInputPin));
+ return GetFilterFromPin(GetUpStreamPin(pBF, pInputPin));
}
IPin* GetUpStreamPin(IBaseFilter* pBF, IPin* pInputPin)
{
- BeginEnumPins(pBF, pEP, pPin)
- {
- if(pInputPin && pInputPin != pPin) continue;
+ BeginEnumPins(pBF, pEP, pPin)
+ {
+ if(pInputPin && pInputPin != pPin) continue;
- PIN_DIRECTION dir;
- CComPtr<IPin> pPinConnectedTo;
- if(SUCCEEDED(pPin->QueryDirection(&dir)) && dir == PINDIR_INPUT
- && SUCCEEDED(pPin->ConnectedTo(&pPinConnectedTo)))
- {
- IPin* pRet = pPinConnectedTo.Detach();
- pRet->Release();
- return(pRet);
- }
- }
- EndEnumPins
+ PIN_DIRECTION dir;
+ CComPtr<IPin> pPinConnectedTo;
+ if(SUCCEEDED(pPin->QueryDirection(&dir)) && dir == PINDIR_INPUT
+ && SUCCEEDED(pPin->ConnectedTo(&pPinConnectedTo)))
+ {
+ IPin* pRet = pPinConnectedTo.Detach();
+ pRet->Release();
+ return(pRet);
+ }
+ }
+ EndEnumPins
- return(NULL);
+ return(NULL);
}
IPin* GetFirstPin(IBaseFilter* pBF, PIN_DIRECTION dir)
{
- if(!pBF) return(NULL);
+ if(!pBF) return(NULL);
- BeginEnumPins(pBF, pEP, pPin)
- {
- PIN_DIRECTION dir2;
- pPin->QueryDirection(&dir2);
- if(dir == dir2)
- {
- IPin* pRet = pPin.Detach();
- pRet->Release();
- return(pRet);
- }
- }
- EndEnumPins
+ BeginEnumPins(pBF, pEP, pPin)
+ {
+ PIN_DIRECTION dir2;
+ pPin->QueryDirection(&dir2);
+ if(dir == dir2)
+ {
+ IPin* pRet = pPin.Detach();
+ pRet->Release();
+ return(pRet);
+ }
+ }
+ EndEnumPins
- return(NULL);
+ return(NULL);
}
IPin* GetFirstDisconnectedPin(IBaseFilter* pBF, PIN_DIRECTION dir)
{
- if(!pBF) return(NULL);
+ if(!pBF) return(NULL);
- BeginEnumPins(pBF, pEP, pPin)
- {
- PIN_DIRECTION dir2;
- pPin->QueryDirection(&dir2);
- CComPtr<IPin> pPinTo;
- if(dir == dir2 && (S_OK != pPin->ConnectedTo(&pPinTo)))
- {
- IPin* pRet = pPin.Detach();
- pRet->Release();
- return(pRet);
- }
- }
- EndEnumPins
+ BeginEnumPins(pBF, pEP, pPin)
+ {
+ PIN_DIRECTION dir2;
+ pPin->QueryDirection(&dir2);
+ CComPtr<IPin> pPinTo;
+ if(dir == dir2 && (S_OK != pPin->ConnectedTo(&pPinTo)))
+ {
+ IPin* pRet = pPin.Detach();
+ pRet->Release();
+ return(pRet);
+ }
+ }
+ EndEnumPins
- return(NULL);
+ return(NULL);
}
IBaseFilter* FindFilter(LPCWSTR clsid, IFilterGraph* pFG)
{
- CLSID clsid2;
- CLSIDFromString(CComBSTR(clsid), &clsid2);
- return(FindFilter(clsid2, pFG));
+ CLSID clsid2;
+ CLSIDFromString(CComBSTR(clsid), &clsid2);
+ return(FindFilter(clsid2, pFG));
}
IBaseFilter* FindFilter(const CLSID& clsid, IFilterGraph* pFG)
{
- BeginEnumFilters(pFG, pEF, pBF)
- {
- CLSID clsid2;
- if(SUCCEEDED(pBF->GetClassID(&clsid2)) && clsid == clsid2)
- return(pBF);
- }
- EndEnumFilters
+ BeginEnumFilters(pFG, pEF, pBF)
+ {
+ CLSID clsid2;
+ if(SUCCEEDED(pBF->GetClassID(&clsid2)) && clsid == clsid2)
+ return(pBF);
+ }
+ EndEnumFilters
- return NULL;
+ return NULL;
}
IPin* FindPin(IBaseFilter* pBF, PIN_DIRECTION direction, const AM_MEDIA_TYPE* pRequestedMT)
{
- PIN_DIRECTION pindir;
- BeginEnumPins(pBF, pEP, pPin)
- {
- CComPtr<IPin> pFellow;
-
- if(SUCCEEDED(pPin->QueryDirection(&pindir)) &&
- pindir == direction &&
- pPin->ConnectedTo(&pFellow) == VFW_E_NOT_CONNECTED)
- {
- BeginEnumMediaTypes(pPin, pEM, pmt)
- {
- if(pmt->majortype == pRequestedMT->majortype && pmt->subtype == pRequestedMT->subtype)
- {
- return (pPin);
- }
- }
- EndEnumMediaTypes(pmt)
- }
- }
- EndEnumPins
- return NULL;
+ PIN_DIRECTION pindir;
+ BeginEnumPins(pBF, pEP, pPin)
+ {
+ CComPtr<IPin> pFellow;
+
+ if (SUCCEEDED (pPin->QueryDirection(&pindir)) &&
+ pindir == direction &&
+ pPin->ConnectedTo(&pFellow) == VFW_E_NOT_CONNECTED)
+ {
+ BeginEnumMediaTypes(pPin, pEM, pmt)
+ {
+ if (pmt->majortype == pRequestedMT->majortype && pmt->subtype == pRequestedMT->subtype)
+ {
+ return (pPin);
+ }
+ }
+ EndEnumMediaTypes(pmt)
+ }
+ }
+ EndEnumPins
+ return NULL;
}
CStringW GetFilterName(IBaseFilter* pBF)
{
- CStringW name;
- CFilterInfo fi;
- if(pBF && SUCCEEDED(pBF->QueryFilterInfo(&fi)))
- name = fi.achName;
- return(name);
+ CStringW name;
+ CFilterInfo fi;
+ if(pBF && SUCCEEDED(pBF->QueryFilterInfo(&fi)))
+ name = fi.achName;
+ return(name);
}
CStringW GetPinName(IPin* pPin)
{
- CStringW name;
- CPinInfo pi;
- if(pPin && SUCCEEDED(pPin->QueryPinInfo(&pi)))
- name = pi.achName;
- if(!name.Find(_T("Apple"))) name.Delete(0, 1);
+ CStringW name;
+ CPinInfo pi;
+ if(pPin && SUCCEEDED(pPin->QueryPinInfo(&pi)))
+ name = pi.achName;
+ if(!name.Find(_T("Apple"))) name.Delete(0,1);
- return(name);
+ return(name);
}
IFilterGraph* GetGraphFromFilter(IBaseFilter* pBF)
{
- if(!pBF) return NULL;
- IFilterGraph* pGraph = NULL;
- CFilterInfo fi;
- if(pBF && SUCCEEDED(pBF->QueryFilterInfo(&fi)))
- pGraph = fi.pGraph;
- return(pGraph);
+ if(!pBF) return NULL;
+ IFilterGraph* pGraph = NULL;
+ CFilterInfo fi;
+ if(pBF && SUCCEEDED(pBF->QueryFilterInfo(&fi)))
+ pGraph = fi.pGraph;
+ return(pGraph);
}
IBaseFilter* GetFilterFromPin(IPin* pPin)
{
- if(!pPin) return NULL;
- IBaseFilter* pBF = NULL;
- CPinInfo pi;
- if(pPin && SUCCEEDED(pPin->QueryPinInfo(&pi)))
- pBF = pi.pFilter;
- return(pBF);
+ if(!pPin) return NULL;
+ IBaseFilter* pBF = NULL;
+ CPinInfo pi;
+ if(pPin && SUCCEEDED(pPin->QueryPinInfo(&pi)))
+ pBF = pi.pFilter;
+ return(pBF);
}
IPin* AppendFilter(IPin* pPin, CString DisplayName, IGraphBuilder* pGB)
{
- IPin* pRet = pPin;
-
- CInterfaceList<IBaseFilter> pFilters;
-
- do
- {
- if(!pPin || DisplayName.IsEmpty() || !pGB)
- break;
-
- CComPtr<IPin> pPinTo;
- PIN_DIRECTION dir;
- if(FAILED(pPin->QueryDirection(&dir)) || dir != PINDIR_OUTPUT || SUCCEEDED(pPin->ConnectedTo(&pPinTo)))
- break;
-
- CComPtr<IBindCtx> pBindCtx;
- CreateBindCtx(0, &pBindCtx);
-
- CComPtr<IMoniker> pMoniker;
- ULONG chEaten;
- if(S_OK != MkParseDisplayName(pBindCtx, CComBSTR(DisplayName), &chEaten, &pMoniker))
- break;
-
- CComPtr<IBaseFilter> pBF;
- if(FAILED(pMoniker->BindToObject(pBindCtx, 0, IID_IBaseFilter, (void**)&pBF)) || !pBF)
- break;
-
- CComPtr<IPropertyBag> pPB;
- if(FAILED(pMoniker->BindToStorage(pBindCtx, 0, IID_IPropertyBag, (void**)&pPB)))
- break;
-
- CComVariant var;
- if(FAILED(pPB->Read(CComBSTR(_T("FriendlyName")), &var, NULL)))
- break;
-
- pFilters.AddTail(pBF);
- BeginEnumFilters(pGB, pEnum, pBF2)
- pFilters.AddTail(pBF2);
- EndEnumFilters
-
- if(FAILED(pGB->AddFilter(pBF, CStringW(var.bstrVal))))
- break;
-
- BeginEnumFilters(pGB, pEnum, pBF2)
- if(!pFilters.Find(pBF2) && SUCCEEDED(pGB->RemoveFilter(pBF2)))
- pEnum->Reset();
- EndEnumFilters
-
- pPinTo = GetFirstPin(pBF, PINDIR_INPUT);
- if(!pPinTo)
- {
- pGB->RemoveFilter(pBF);
- break;
- }
-
- HRESULT hr;
- if(FAILED(hr = pGB->ConnectDirect(pPin, pPinTo, NULL)))
- {
- hr = pGB->Connect(pPin, pPinTo);
- pGB->RemoveFilter(pBF);
- break;
- }
-
- BeginEnumFilters(pGB, pEnum, pBF2)
- if(!pFilters.Find(pBF2) && SUCCEEDED(pGB->RemoveFilter(pBF2)))
- pEnum->Reset();
- EndEnumFilters
-
- pRet = GetFirstPin(pBF, PINDIR_OUTPUT);
- if(!pRet)
- {
- pRet = pPin;
- pGB->RemoveFilter(pBF);
- break;
- }
- }
- while(false);
-
- return(pRet);
+ IPin* pRet = pPin;
+
+ CInterfaceList<IBaseFilter> pFilters;
+
+ do
+ {
+ if(!pPin || DisplayName.IsEmpty() || !pGB)
+ break;
+
+ CComPtr<IPin> pPinTo;
+ PIN_DIRECTION dir;
+ if(FAILED(pPin->QueryDirection(&dir)) || dir != PINDIR_OUTPUT || SUCCEEDED(pPin->ConnectedTo(&pPinTo)))
+ break;
+
+ CComPtr<IBindCtx> pBindCtx;
+ CreateBindCtx(0, &pBindCtx);
+
+ CComPtr<IMoniker> pMoniker;
+ ULONG chEaten;
+ if(S_OK != MkParseDisplayName(pBindCtx, CComBSTR(DisplayName), &chEaten, &pMoniker))
+ break;
+
+ CComPtr<IBaseFilter> pBF;
+ if(FAILED(pMoniker->BindToObject(pBindCtx, 0, IID_IBaseFilter, (void**)&pBF)) || !pBF)
+ break;
+
+ CComPtr<IPropertyBag> pPB;
+ if(FAILED(pMoniker->BindToStorage(pBindCtx, 0, IID_IPropertyBag, (void**)&pPB)))
+ break;
+
+ CComVariant var;
+ if(FAILED(pPB->Read(CComBSTR(_T("FriendlyName")), &var, NULL)))
+ break;
+
+ pFilters.AddTail(pBF);
+ BeginEnumFilters(pGB, pEnum, pBF2)
+ pFilters.AddTail(pBF2);
+ EndEnumFilters
+
+ if(FAILED(pGB->AddFilter(pBF, CStringW(var.bstrVal))))
+ break;
+
+ BeginEnumFilters(pGB, pEnum, pBF2)
+ if(!pFilters.Find(pBF2) && SUCCEEDED(pGB->RemoveFilter(pBF2)))
+ pEnum->Reset();
+ EndEnumFilters
+
+ pPinTo = GetFirstPin(pBF, PINDIR_INPUT);
+ if(!pPinTo)
+ {
+ pGB->RemoveFilter(pBF);
+ break;
+ }
+
+ HRESULT hr;
+ if(FAILED(hr = pGB->ConnectDirect(pPin, pPinTo, NULL)))
+ {
+ hr = pGB->Connect(pPin, pPinTo);
+ pGB->RemoveFilter(pBF);
+ break;
+ }
+
+ BeginEnumFilters(pGB, pEnum, pBF2)
+ if(!pFilters.Find(pBF2) && SUCCEEDED(pGB->RemoveFilter(pBF2)))
+ pEnum->Reset();
+ EndEnumFilters
+
+ pRet = GetFirstPin(pBF, PINDIR_OUTPUT);
+ if(!pRet)
+ {
+ pRet = pPin;
+ pGB->RemoveFilter(pBF);
+ break;
+ }
+ }
+ while(false);
+
+ return(pRet);
}
IPin* InsertFilter(IPin* pPin, CString DisplayName, IGraphBuilder* pGB)
{
- do
- {
- if(!pPin || DisplayName.IsEmpty() || !pGB)
- break;
-
- PIN_DIRECTION dir;
- if(FAILED(pPin->QueryDirection(&dir)))
- break;
-
- CComPtr<IPin> pFrom, pTo;
-
- if(dir == PINDIR_INPUT)
- {
- pPin->ConnectedTo(&pFrom);
- pTo = pPin;
- }
- else if(dir == PINDIR_OUTPUT)
- {
- pFrom = pPin;
- pPin->ConnectedTo(&pTo);
- }
-
- if(!pFrom || !pTo)
- break;
-
- CComPtr<IBindCtx> pBindCtx;
- CreateBindCtx(0, &pBindCtx);
-
- CComPtr<IMoniker> pMoniker;
- ULONG chEaten;
- if(S_OK != MkParseDisplayName(pBindCtx, CComBSTR(DisplayName), &chEaten, &pMoniker))
- break;
-
- CComPtr<IBaseFilter> pBF;
- if(FAILED(pMoniker->BindToObject(pBindCtx, 0, IID_IBaseFilter, (void**)&pBF)) || !pBF)
- break;
-
- CComPtr<IPropertyBag> pPB;
- if(FAILED(pMoniker->BindToStorage(pBindCtx, 0, IID_IPropertyBag, (void**)&pPB)))
- break;
-
- CComVariant var;
- if(FAILED(pPB->Read(CComBSTR(_T("FriendlyName")), &var, NULL)))
- break;
-
- if(FAILED(pGB->AddFilter(pBF, CStringW(var.bstrVal))))
- break;
-
- CComPtr<IPin> pFromTo = GetFirstPin(pBF, PINDIR_INPUT);
- if(!pFromTo)
- {
- pGB->RemoveFilter(pBF);
- break;
- }
-
- if(FAILED(pGB->Disconnect(pFrom)) || FAILED(pGB->Disconnect(pTo)))
- {
- pGB->RemoveFilter(pBF);
- pGB->ConnectDirect(pFrom, pTo, NULL);
- break;
- }
-
- HRESULT hr;
- if(FAILED(hr = pGB->ConnectDirect(pFrom, pFromTo, NULL)))
- {
- pGB->RemoveFilter(pBF);
- pGB->ConnectDirect(pFrom, pTo, NULL);
- break;
- }
-
- CComPtr<IPin> pToFrom = GetFirstPin(pBF, PINDIR_OUTPUT);
- if(!pToFrom)
- {
- pGB->RemoveFilter(pBF);
- pGB->ConnectDirect(pFrom, pTo, NULL);
- break;
- }
-
- if(FAILED(pGB->ConnectDirect(pToFrom, pTo, NULL)))
- {
- pGB->RemoveFilter(pBF);
- pGB->ConnectDirect(pFrom, pTo, NULL);
- break;
- }
-
- pPin = pToFrom;
- }
- while(false);
-
- return(pPin);
+ do
+ {
+ if(!pPin || DisplayName.IsEmpty() || !pGB)
+ break;
+
+ PIN_DIRECTION dir;
+ if(FAILED(pPin->QueryDirection(&dir)))
+ break;
+
+ CComPtr<IPin> pFrom, pTo;
+
+ if(dir == PINDIR_INPUT)
+ {
+ pPin->ConnectedTo(&pFrom);
+ pTo = pPin;
+ }
+ else if(dir == PINDIR_OUTPUT)
+ {
+ pFrom = pPin;
+ pPin->ConnectedTo(&pTo);
+ }
+
+ if(!pFrom || !pTo)
+ break;
+
+ CComPtr<IBindCtx> pBindCtx;
+ CreateBindCtx(0, &pBindCtx);
+
+ CComPtr<IMoniker> pMoniker;
+ ULONG chEaten;
+ if(S_OK != MkParseDisplayName(pBindCtx, CComBSTR(DisplayName), &chEaten, &pMoniker))
+ break;
+
+ CComPtr<IBaseFilter> pBF;
+ if(FAILED(pMoniker->BindToObject(pBindCtx, 0, IID_IBaseFilter, (void**)&pBF)) || !pBF)
+ break;
+
+ CComPtr<IPropertyBag> pPB;
+ if(FAILED(pMoniker->BindToStorage(pBindCtx, 0, IID_IPropertyBag, (void**)&pPB)))
+ break;
+
+ CComVariant var;
+ if(FAILED(pPB->Read(CComBSTR(_T("FriendlyName")), &var, NULL)))
+ break;
+
+ if(FAILED(pGB->AddFilter(pBF, CStringW(var.bstrVal))))
+ break;
+
+ CComPtr<IPin> pFromTo = GetFirstPin(pBF, PINDIR_INPUT);
+ if(!pFromTo)
+ {
+ pGB->RemoveFilter(pBF);
+ break;
+ }
+
+ if(FAILED(pGB->Disconnect(pFrom)) || FAILED(pGB->Disconnect(pTo)))
+ {
+ pGB->RemoveFilter(pBF);
+ pGB->ConnectDirect(pFrom, pTo, NULL);
+ break;
+ }
+
+ HRESULT hr;
+ if(FAILED(hr = pGB->ConnectDirect(pFrom, pFromTo, NULL)))
+ {
+ pGB->RemoveFilter(pBF);
+ pGB->ConnectDirect(pFrom, pTo, NULL);
+ break;
+ }
+
+ CComPtr<IPin> pToFrom = GetFirstPin(pBF, PINDIR_OUTPUT);
+ if(!pToFrom)
+ {
+ pGB->RemoveFilter(pBF);
+ pGB->ConnectDirect(pFrom, pTo, NULL);
+ break;
+ }
+
+ if(FAILED(pGB->ConnectDirect(pToFrom, pTo, NULL)))
+ {
+ pGB->RemoveFilter(pBF);
+ pGB->ConnectDirect(pFrom, pTo, NULL);
+ break;
+ }
+
+ pPin = pToFrom;
+ }
+ while(false);
+
+ return(pPin);
}
void ExtractMediaTypes(IPin* pPin, CAtlArray<GUID>& types)
{
- types.RemoveAll();
+ types.RemoveAll();
BeginEnumMediaTypes(pPin, pEM, pmt)
- {
- bool fFound = false;
+ {
+ bool fFound = false;
- for(ptrdiff_t i = 0; !fFound && i < (int)types.GetCount(); i += 2)
- {
- if(types[i] == pmt->majortype && types[i+1] == pmt->subtype)
- fFound = true;
- }
+ for(ptrdiff_t i = 0; !fFound && i < (int)types.GetCount(); i += 2)
+ {
+ if(types[i] == pmt->majortype && types[i+1] == pmt->subtype)
+ fFound = true;
+ }
- if(!fFound)
- {
- types.Add(pmt->majortype);
- types.Add(pmt->subtype);
- }
- }
- EndEnumMediaTypes(pmt)
+ if(!fFound)
+ {
+ types.Add(pmt->majortype);
+ types.Add(pmt->subtype);
+ }
+ }
+ EndEnumMediaTypes(pmt)
}
void ExtractMediaTypes(IPin* pPin, CAtlList<CMediaType>& mts)
{
- mts.RemoveAll();
+ mts.RemoveAll();
BeginEnumMediaTypes(pPin, pEM, pmt)
- {
- bool fFound = false;
+ {
+ bool fFound = false;
- POSITION pos = mts.GetHeadPosition();
- while(!fFound && pos)
- {
- CMediaType& mt = mts.GetNext(pos);
- if(mt.majortype == pmt->majortype && mt.subtype == pmt->subtype)
- fFound = true;
- }
+ POSITION pos = mts.GetHeadPosition();
+ while(!fFound && pos)
+ {
+ CMediaType& mt = mts.GetNext(pos);
+ if(mt.majortype == pmt->majortype && mt.subtype == pmt->subtype)
+ fFound = true;
+ }
- if(!fFound)
- {
- mts.AddTail(CMediaType(*pmt));
- }
- }
- EndEnumMediaTypes(pmt)
+ if(!fFound)
+ {
+ mts.AddTail(CMediaType(*pmt));
+ }
+ }
+ EndEnumMediaTypes(pmt)
}
int Eval_Exception(int n_except)
{
if(n_except == STATUS_ACCESS_VIOLATION)
- {
- AfxMessageBox(_T("The property page of this filter has just caused a\nmemory access violation. The application will gently die now :)"));
- }
+ {
+ AfxMessageBox(_T("The property page of this filter has just caused a\nmemory access violation. The application will gently die now :)"));
+ }
- return EXCEPTION_CONTINUE_SEARCH;
+ return EXCEPTION_CONTINUE_SEARCH;
}
void MyOleCreatePropertyFrame(HWND hwndOwner, UINT x, UINT y, LPCOLESTR lpszCaption, ULONG cObjects, LPUNKNOWN FAR* lplpUnk, ULONG cPages, LPCLSID lpPageClsID, LCID lcid, DWORD dwReserved, LPVOID lpvReserved)
{
- __try
- {
- OleCreatePropertyFrame(hwndOwner, x, y, lpszCaption, cObjects, lplpUnk, cPages, lpPageClsID, lcid, dwReserved, lpvReserved);
- }
- __except(Eval_Exception(GetExceptionCode()))
- {
- // No code; this block never executed.
- }
+ __try
+ {
+ OleCreatePropertyFrame(hwndOwner, x, y, lpszCaption, cObjects, lplpUnk, cPages, lpPageClsID, lcid, dwReserved, lpvReserved);
+ }
+ __except(Eval_Exception(GetExceptionCode()))
+ {
+ // No code; this block never executed.
+ }
}
void ShowPPage(CString DisplayName, HWND hParentWnd)
{
- CComPtr<IBindCtx> pBindCtx;
- CreateBindCtx(0, &pBindCtx);
+ CComPtr<IBindCtx> pBindCtx;
+ CreateBindCtx(0, &pBindCtx);
- CComPtr<IMoniker> pMoniker;
- ULONG chEaten;
- if(S_OK != MkParseDisplayName(pBindCtx, CStringW(DisplayName), &chEaten, &pMoniker))
- return;
+ CComPtr<IMoniker> pMoniker;
+ ULONG chEaten;
+ if(S_OK != MkParseDisplayName(pBindCtx, CStringW(DisplayName), &chEaten, &pMoniker))
+ return;
- CComPtr<IBaseFilter> pBF;
- if(FAILED(pMoniker->BindToObject(pBindCtx, 0, IID_IBaseFilter, (void**)&pBF)) || !pBF)
- return;
+ CComPtr<IBaseFilter> pBF;
+ if(FAILED(pMoniker->BindToObject(pBindCtx, 0, IID_IBaseFilter, (void**)&pBF)) || !pBF)
+ return;
- ShowPPage(pBF, hParentWnd);
+ ShowPPage(pBF, hParentWnd);
}
void ShowPPage(IUnknown* pUnk, HWND hParentWnd)
{
- CComQIPtr<ISpecifyPropertyPages> pSPP = pUnk;
- if(!pSPP) return;
-
- CString str;
-
- CComQIPtr<IBaseFilter> pBF = pSPP;
- CFilterInfo fi;
- CComQIPtr<IPin> pPin = pSPP;
- CPinInfo pi;
- if(pBF && SUCCEEDED(pBF->QueryFilterInfo(&fi)))
- str = fi.achName;
- else if(pPin && SUCCEEDED(pPin->QueryPinInfo(&pi)))
- str = pi.achName;
-
- CAUUID caGUID;
- caGUID.pElems = NULL;
- if(SUCCEEDED(pSPP->GetPages(&caGUID)))
- {
- IUnknown* lpUnk = NULL;
- pSPP.QueryInterface(&lpUnk);
- MyOleCreatePropertyFrame(
- hParentWnd, 0, 0, CStringW(str),
- 1, (IUnknown**)&lpUnk,
- caGUID.cElems, caGUID.pElems,
- 0, 0, NULL);
- lpUnk->Release();
-
- if(caGUID.pElems) CoTaskMemFree(caGUID.pElems);
- }
+ CComQIPtr<ISpecifyPropertyPages> pSPP = pUnk;
+ if(!pSPP) return;
+
+ CString str;
+
+ CComQIPtr<IBaseFilter> pBF = pSPP;
+ CFilterInfo fi;
+ CComQIPtr<IPin> pPin = pSPP;
+ CPinInfo pi;
+ if(pBF && SUCCEEDED(pBF->QueryFilterInfo(&fi)))
+ str = fi.achName;
+ else if(pPin && SUCCEEDED(pPin->QueryPinInfo(&pi)))
+ str = pi.achName;
+
+ CAUUID caGUID;
+ caGUID.pElems = NULL;
+ if(SUCCEEDED(pSPP->GetPages(&caGUID)))
+ {
+ IUnknown* lpUnk = NULL;
+ pSPP.QueryInterface(&lpUnk);
+ MyOleCreatePropertyFrame(
+ hParentWnd, 0, 0, CStringW(str),
+ 1, (IUnknown**)&lpUnk,
+ caGUID.cElems, caGUID.pElems,
+ 0, 0, NULL);
+ lpUnk->Release();
+
+ if(caGUID.pElems) CoTaskMemFree(caGUID.pElems);
+ }
}
CLSID GetCLSID(IBaseFilter* pBF)
{
- CLSID clsid = GUID_NULL;
- if(pBF) pBF->GetClassID(&clsid);
- return(clsid);
+ CLSID clsid = GUID_NULL;
+ if(pBF) pBF->GetClassID(&clsid);
+ return(clsid);
}
CLSID GetCLSID(IPin* pPin)
{
- return(GetCLSID(GetFilterFromPin(pPin)));
+ return(GetCLSID(GetFilterFromPin(pPin)));
}
bool IsCLSIDRegistered(LPCTSTR clsid)
{
- CString rootkey1(_T("CLSID\\"));
- CString rootkey2(_T("CLSID\\{083863F1-70DE-11d0-BD40-00A0C911CE86}\\Instance\\"));
+ CString rootkey1(_T("CLSID\\"));
+ CString rootkey2(_T("CLSID\\{083863F1-70DE-11d0-BD40-00A0C911CE86}\\Instance\\"));
- return ERROR_SUCCESS == CRegKey().Open(HKEY_CLASSES_ROOT, rootkey1 + clsid, KEY_READ)
- || ERROR_SUCCESS == CRegKey().Open(HKEY_CLASSES_ROOT, rootkey2 + clsid, KEY_READ);
+ return ERROR_SUCCESS == CRegKey().Open(HKEY_CLASSES_ROOT, rootkey1 + clsid, KEY_READ)
+ || ERROR_SUCCESS == CRegKey().Open(HKEY_CLASSES_ROOT, rootkey2 + clsid, KEY_READ);
}
bool IsCLSIDRegistered(const CLSID& clsid)
{
- bool fRet = false;
+ bool fRet = false;
- LPOLESTR pStr = NULL;
- if(S_OK == StringFromCLSID(clsid, &pStr) && pStr)
- {
- fRet = IsCLSIDRegistered(CString(pStr));
- CoTaskMemFree(pStr);
- }
+ LPOLESTR pStr = NULL;
+ if(S_OK == StringFromCLSID(clsid, &pStr) && pStr)
+ {
+ fRet = IsCLSIDRegistered(CString(pStr));
+ CoTaskMemFree(pStr);
+ }
- return(fRet);
+ return(fRet);
}
void CStringToBin(CString str, CAtlArray<BYTE>& data)
{
- str.Trim();
- ASSERT((str.GetLength() & 1) == 0);
- data.SetCount(str.GetLength() / 2);
-
- BYTE b = 0;
-
- str.MakeUpper();
- for(size_t i = 0, j = str.GetLength(); i < j; i++)
- {
- TCHAR c = str[i];
- if(c >= '0' && c <= '9')
- {
- if(!(i & 1)) b = ((char(c - '0') << 4) & 0xf0) | (b & 0x0f);
- else b = (char(c - '0') & 0x0f) | (b & 0xf0);
- }
- else if(c >= 'A' && c <= 'F')
- {
- if(!(i & 1)) b = ((char(c - 'A' + 10) << 4) & 0xf0) | (b & 0x0f);
- else b = (char(c - 'A' + 10) & 0x0f) | (b & 0xf0);
- }
- else break;
-
- if(i & 1)
- {
- data[i>>1] = b;
- b = 0;
- }
- }
+ str.Trim();
+ ASSERT((str.GetLength()&1) == 0);
+ data.SetCount(str.GetLength()/2);
+
+ BYTE b = 0;
+
+ str.MakeUpper();
+ for(size_t i = 0, j = str.GetLength(); i < j; i++)
+ {
+ TCHAR c = str[i];
+ if(c >= '0' && c <= '9')
+ {
+ if(!(i&1)) b = ((char(c-'0')<<4)&0xf0)|(b&0x0f);
+ else b = (char(c-'0')&0x0f)|(b&0xf0);
+ }
+ else if(c >= 'A' && c <= 'F')
+ {
+ if(!(i&1)) b = ((char(c-'A'+10)<<4)&0xf0)|(b&0x0f);
+ else b = (char(c-'A'+10)&0x0f)|(b&0xf0);
+ }
+ else break;
+
+ if(i&1)
+ {
+ data[i>>1] = b;
+ b = 0;
+ }
+ }
}
CString BinToCString(BYTE* ptr, int len)
{
- CString ret;
+ CString ret;
- while(len-- > 0)
- {
- TCHAR high, low;
- high = (*ptr >> 4) >= 10 ? (*ptr >> 4) - 10 + 'A' : (*ptr >> 4) + '0';
- low = (*ptr & 0xf) >= 10 ? (*ptr & 0xf) - 10 + 'A' : (*ptr & 0xf) + '0';
+ while(len-- > 0)
+ {
+ TCHAR high, low;
+ high = (*ptr>>4) >= 10 ? (*ptr>>4)-10 + 'A' : (*ptr>>4) + '0';
+ low = (*ptr&0xf) >= 10 ? (*ptr&0xf)-10 + 'A' : (*ptr&0xf) + '0';
- CString str;
- str.Format(_T("%c%c"), high, low);
- ret += str;
+ CString str;
+ str.Format(_T("%c%c"), high, low);
+ ret += str;
- ptr++;
- }
+ ptr++;
+ }
- return(ret);
+ return(ret);
}
static void FindFiles(CString fn, CAtlList<CString>& files)
{
- CString path = fn;
- path.Replace('/', '\\');
- path = path.Left(path.ReverseFind('\\') + 1);
+ CString path = fn;
+ path.Replace('/', '\\');
+ path = path.Left(path.ReverseFind('\\')+1);
- WIN32_FIND_DATA findData;
- HANDLE h = FindFirstFile(fn, &findData);
- if(h != INVALID_HANDLE_VALUE)
- {
- do
- {
- files.AddTail(path + findData.cFileName);
- }
- while(FindNextFile(h, &findData));
+ WIN32_FIND_DATA findData;
+ HANDLE h = FindFirstFile(fn, &findData);
+ if(h != INVALID_HANDLE_VALUE)
+ {
+ do {files.AddTail(path + findData.cFileName);}
+ while(FindNextFile(h, &findData));
- FindClose(h);
- }
+ FindClose(h);
+ }
}
cdrom_t GetCDROMType(TCHAR drive, CAtlList<CString>& files)
{
- files.RemoveAll();
-
- CString path;
- path.Format(_T("%c:"), drive);
-
- if(GetDriveType(path + _T("\\")) == DRIVE_CDROM)
- {
- // CDROM_VideoCD
- FindFiles(path + _T("\\mpegav\\avseq??.dat"), files);
- FindFiles(path + _T("\\mpegav\\avseq??.mpg"), files);
- FindFiles(path + _T("\\mpeg2\\avseq??.dat"), files);
- FindFiles(path + _T("\\mpeg2\\avseq??.mpg"), files);
- FindFiles(path + _T("\\mpegav\\music??.dat"), files);
- FindFiles(path + _T("\\mpegav\\music??.mpg"), files);
- FindFiles(path + _T("\\mpeg2\\music??.dat"), files);
- FindFiles(path + _T("\\mpeg2\\music??.mpg"), files);
- if(files.GetCount() > 0) return CDROM_VideoCD;
-
- // CDROM_DVDVideo
- FindFiles(path + _T("\\VIDEO_TS\\video_ts.ifo"), files);
- if(files.GetCount() > 0) return CDROM_DVDVideo;
-
- // CDROM_Audio
- if(!(GetVersion() & 0x80000000))
- {
- HANDLE hDrive = CreateFile(CString(_T("\\\\.\\")) + path, GENERIC_READ, FILE_SHARE_READ, NULL,
- OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, (HANDLE)NULL);
- if(hDrive != INVALID_HANDLE_VALUE)
- {
- DWORD BytesReturned;
- CDROM_TOC TOC;
- if(DeviceIoControl(hDrive, IOCTL_CDROM_READ_TOC, NULL, 0, &TOC, sizeof(TOC), &BytesReturned, 0))
- {
- for(ptrdiff_t i = TOC.FirstTrack; i <= TOC.LastTrack; i++)
- {
- // MMC-3 Draft Revision 10g: Table 222 – Q Sub-channel control field
- TOC.TrackData[i-1].Control &= 5;
- if(TOC.TrackData[i-1].Control == 0 || TOC.TrackData[i-1].Control == 1)
- {
- CString fn;
- fn.Format(_T("%s\\track%02d.cda"), path, i);
- files.AddTail(fn);
- }
- }
- }
-
- CloseHandle(hDrive);
- }
- }
- if(files.GetCount() > 0) return CDROM_Audio;
-
- // it is a cdrom but nothing special
- return CDROM_Unknown;
- }
-
- return CDROM_NotFound;
+ files.RemoveAll();
+
+ CString path;
+ path.Format(_T("%c:"), drive);
+
+ if(GetDriveType(path + _T("\\")) == DRIVE_CDROM)
+ {
+ // CDROM_VideoCD
+ FindFiles(path + _T("\\mpegav\\avseq??.dat"), files);
+ FindFiles(path + _T("\\mpegav\\avseq??.mpg"), files);
+ FindFiles(path + _T("\\mpeg2\\avseq??.dat"), files);
+ FindFiles(path + _T("\\mpeg2\\avseq??.mpg"), files);
+ FindFiles(path + _T("\\mpegav\\music??.dat"), files);
+ FindFiles(path + _T("\\mpegav\\music??.mpg"), files);
+ FindFiles(path + _T("\\mpeg2\\music??.dat"), files);
+ FindFiles(path + _T("\\mpeg2\\music??.mpg"), files);
+ if(files.GetCount() > 0) return CDROM_VideoCD;
+
+ // CDROM_DVDVideo
+ FindFiles(path + _T("\\VIDEO_TS\\video_ts.ifo"), files);
+ if(files.GetCount() > 0) return CDROM_DVDVideo;
+
+ // CDROM_Audio
+ if(!(GetVersion()&0x80000000))
+ {
+ HANDLE hDrive = CreateFile(CString(_T("\\\\.\\")) + path, GENERIC_READ, FILE_SHARE_READ, NULL,
+ OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, (HANDLE)NULL);
+ if(hDrive != INVALID_HANDLE_VALUE)
+ {
+ DWORD BytesReturned;
+ CDROM_TOC TOC;
+ if(DeviceIoControl(hDrive, IOCTL_CDROM_READ_TOC, NULL, 0, &TOC, sizeof(TOC), &BytesReturned, 0))
+ {
+ for(ptrdiff_t i = TOC.FirstTrack; i <= TOC.LastTrack; i++)
+ {
+ // MMC-3 Draft Revision 10g: Table 222 – Q Sub-channel control field
+ TOC.TrackData[i-1].Control &= 5;
+ if(TOC.TrackData[i-1].Control == 0 || TOC.TrackData[i-1].Control == 1)
+ {
+ CString fn;
+ fn.Format(_T("%s\\track%02d.cda"), path, i);
+ files.AddTail(fn);
+ }
+ }
+ }
+
+ CloseHandle(hDrive);
+ }
+ }
+ if(files.GetCount() > 0) return CDROM_Audio;
+
+ // it is a cdrom but nothing special
+ return CDROM_Unknown;
+ }
+
+ return CDROM_NotFound;
}
CString GetDriveLabel(TCHAR drive)
{
- CString label;
+ CString label;
- CString path;
- path.Format(_T("%c:\\"), drive);
- TCHAR VolumeNameBuffer[_MAX_PATH], FileSystemNameBuffer[_MAX_PATH];
- DWORD VolumeSerialNumber, MaximumComponentLength, FileSystemFlags;
- if(GetVolumeInformation(path,
- VolumeNameBuffer, MAX_PATH, &VolumeSerialNumber, &MaximumComponentLength,
- &FileSystemFlags, FileSystemNameBuffer, MAX_PATH))
- {
- label = VolumeNameBuffer;
- }
+ CString path;
+ path.Format(_T("%c:\\"), drive);
+ TCHAR VolumeNameBuffer[_MAX_PATH], FileSystemNameBuffer[_MAX_PATH];
+ DWORD VolumeSerialNumber, MaximumComponentLength, FileSystemFlags;
+ if(GetVolumeInformation(path,
+ VolumeNameBuffer, MAX_PATH, &VolumeSerialNumber, &MaximumComponentLength,
+ &FileSystemFlags, FileSystemNameBuffer, MAX_PATH))
+ {
+ label = VolumeNameBuffer;
+ }
- return(label);
+ return(label);
}
bool GetKeyFrames(CString fn, CUIntArray& kfs)
{
- kfs.RemoveAll();
-
- CString fn2 = CString(fn).MakeLower();
- if(fn2.Mid(fn2.ReverseFind('.') + 1) == _T("avi"))
- {
- AVIFileInit();
-
- PAVIFILE pfile;
- if(AVIFileOpen(&pfile, fn, OF_SHARE_DENY_WRITE, 0L) == 0)
- {
- AVIFILEINFO afi;
- memset(&afi, 0, sizeof(afi));
- AVIFileInfo(pfile, &afi, sizeof(AVIFILEINFO));
-
- CComPtr<IAVIStream> pavi;
- if(AVIFileGetStream(pfile, &pavi, streamtypeVIDEO, 0) == AVIERR_OK)
- {
- AVISTREAMINFO si;
- AVIStreamInfo(pavi, &si, sizeof(si));
-
- if(afi.dwCaps & AVIFILECAPS_ALLKEYFRAMES)
- {
- kfs.SetSize(si.dwLength);
- for(ptrdiff_t kf = 0; kf < (int)si.dwLength; kf++) kfs[kf] = kf;
- }
- else
- {
- for(ptrdiff_t kf = 0; ; kf++)
- {
- kf = pavi->FindSample(kf, FIND_KEY | FIND_NEXT);
- if(kf < 0 || kfs.GetCount() > 0 && kfs[kfs.GetCount()-1] >= (UINT)kf) break;
- kfs.Add(kf);
- }
-
- if(kfs.GetCount() > 0 && kfs[kfs.GetCount()-1] < si.dwLength - 1)
- {
- kfs.Add(si.dwLength - 1);
- }
- }
- }
-
- AVIFileRelease(pfile);
- }
-
- AVIFileExit();
- }
-
- return(kfs.GetCount() > 0);
+ kfs.RemoveAll();
+
+ CString fn2 = CString(fn).MakeLower();
+ if(fn2.Mid(fn2.ReverseFind('.')+1) == _T("avi"))
+ {
+ AVIFileInit();
+
+ PAVIFILE pfile;
+ if(AVIFileOpen(&pfile, fn, OF_SHARE_DENY_WRITE, 0L) == 0)
+ {
+ AVIFILEINFO afi;
+ memset(&afi, 0, sizeof(afi));
+ AVIFileInfo(pfile, &afi, sizeof(AVIFILEINFO));
+
+ CComPtr<IAVIStream> pavi;
+ if(AVIFileGetStream(pfile, &pavi, streamtypeVIDEO, 0) == AVIERR_OK)
+ {
+ AVISTREAMINFO si;
+ AVIStreamInfo(pavi, &si, sizeof(si));
+
+ if(afi.dwCaps&AVIFILECAPS_ALLKEYFRAMES)
+ {
+ kfs.SetSize(si.dwLength);
+ for(ptrdiff_t kf = 0; kf < (int)si.dwLength; kf++) kfs[kf] = kf;
+ }
+ else
+ {
+ for(ptrdiff_t kf = 0; ; kf++)
+ {
+ kf = pavi->FindSample(kf, FIND_KEY|FIND_NEXT);
+ if(kf < 0 || kfs.GetCount() > 0 && kfs[kfs.GetCount()-1] >= (UINT)kf) break;
+ kfs.Add(kf);
+ }
+
+ if(kfs.GetCount() > 0 && kfs[kfs.GetCount()-1] < si.dwLength-1)
+ {
+ kfs.Add(si.dwLength-1);
+ }
+ }
+ }
+
+ AVIFileRelease(pfile);
+ }
+
+ AVIFileExit();
+ }
+
+ return(kfs.GetCount() > 0);
}
DVD_HMSF_TIMECODE RT2HMSF(REFERENCE_TIME rt, double fps)
{
- DVD_HMSF_TIMECODE hmsf =
- {
- (BYTE)((rt / 10000000 / 60 / 60)),
- (BYTE)((rt / 10000000 / 60) % 60),
- (BYTE)((rt / 10000000) % 60),
- (BYTE)(1.0 *((rt / 10000) % 1000) * fps / 1000)
- };
+ DVD_HMSF_TIMECODE hmsf =
+ {
+ (BYTE)((rt/10000000/60/60)),
+ (BYTE)((rt/10000000/60)%60),
+ (BYTE)((rt/10000000)%60),
+ (BYTE)(1.0*((rt/10000)%1000) * fps / 1000)
+ };
- return hmsf;
+ return hmsf;
}
REFERENCE_TIME HMSF2RT(DVD_HMSF_TIMECODE hmsf, double fps)
{
- if(fps == 0)
- {
- hmsf.bFrames = 0;
- fps = 1;
- }
- return (REFERENCE_TIME)((((REFERENCE_TIME)hmsf.bHours * 60 + hmsf.bMinutes) * 60 + hmsf.bSeconds) * 1000 + 1.0 * hmsf.bFrames * 1000 / fps) * 10000;
+ if(fps == 0) {hmsf.bFrames = 0; fps = 1;}
+ return (REFERENCE_TIME)((((REFERENCE_TIME)hmsf.bHours*60+hmsf.bMinutes)*60+hmsf.bSeconds)*1000+1.0*hmsf.bFrames*1000/fps)*10000;
}
void memsetd(void* dst, unsigned int c, int nbytes)
{
#ifdef _WIN64
- for(int i = 0; i < nbytes / sizeof(DWORD); i++)
- ((DWORD*)dst)[i] = c;
+ for (int i=0; i<nbytes/sizeof(DWORD); i++)
+ ((DWORD*)dst)[i] = c;
#else
- __asm
- {
- mov eax, c
- mov ecx, nbytes
- shr ecx, 2
- mov edi, dst
- cld
- rep stosd
- }
+ __asm
+ {
+ mov eax, c
+ mov ecx, nbytes
+ shr ecx, 2
+ mov edi, dst
+ cld
+ rep stosd
+ }
#endif
}
bool ExtractBIH(const AM_MEDIA_TYPE* pmt, BITMAPINFOHEADER* bih)
{
- if(pmt && bih)
- {
- memset(bih, 0, sizeof(*bih));
-
- if(pmt->formattype == FORMAT_VideoInfo)
- {
- VIDEOINFOHEADER* vih = (VIDEOINFOHEADER*)pmt->pbFormat;
- memcpy(bih, &vih->bmiHeader, sizeof(BITMAPINFOHEADER));
- return true;
- }
- else if(pmt->formattype == FORMAT_VideoInfo2)
- {
- VIDEOINFOHEADER2* vih = (VIDEOINFOHEADER2*)pmt->pbFormat;
- memcpy(bih, &vih->bmiHeader, sizeof(BITMAPINFOHEADER));
- return true;
- }
- else if(pmt->formattype == FORMAT_MPEGVideo)
- {
- VIDEOINFOHEADER* vih = &((MPEG1VIDEOINFO*)pmt->pbFormat)->hdr;
- memcpy(bih, &vih->bmiHeader, sizeof(BITMAPINFOHEADER));
- return true;
- }
- else if(pmt->formattype == FORMAT_MPEG2_VIDEO)
- {
- VIDEOINFOHEADER2* vih = &((MPEG2VIDEOINFO*)pmt->pbFormat)->hdr;
- memcpy(bih, &vih->bmiHeader, sizeof(BITMAPINFOHEADER));
- return true;
- }
- else if(pmt->formattype == FORMAT_DiracVideoInfo)
- {
- VIDEOINFOHEADER2* vih = &((DIRACINFOHEADER*)pmt->pbFormat)->hdr;
- memcpy(bih, &vih->bmiHeader, sizeof(BITMAPINFOHEADER));
- return true;
- }
- }
-
- return false;
+ if(pmt && bih)
+ {
+ memset(bih, 0, sizeof(*bih));
+
+ if(pmt->formattype == FORMAT_VideoInfo)
+ {
+ VIDEOINFOHEADER* vih = (VIDEOINFOHEADER*)pmt->pbFormat;
+ memcpy(bih, &vih->bmiHeader, sizeof(BITMAPINFOHEADER));
+ return true;
+ }
+ else if(pmt->formattype == FORMAT_VideoInfo2)
+ {
+ VIDEOINFOHEADER2* vih = (VIDEOINFOHEADER2*)pmt->pbFormat;
+ memcpy(bih, &vih->bmiHeader, sizeof(BITMAPINFOHEADER));
+ return true;
+ }
+ else if(pmt->formattype == FORMAT_MPEGVideo)
+ {
+ VIDEOINFOHEADER* vih = &((MPEG1VIDEOINFO*)pmt->pbFormat)->hdr;
+ memcpy(bih, &vih->bmiHeader, sizeof(BITMAPINFOHEADER));
+ return true;
+ }
+ else if(pmt->formattype == FORMAT_MPEG2_VIDEO)
+ {
+ VIDEOINFOHEADER2* vih = &((MPEG2VIDEOINFO*)pmt->pbFormat)->hdr;
+ memcpy(bih, &vih->bmiHeader, sizeof(BITMAPINFOHEADER));
+ return true;
+ }
+ else if(pmt->formattype == FORMAT_DiracVideoInfo)
+ {
+ VIDEOINFOHEADER2* vih = &((DIRACINFOHEADER*)pmt->pbFormat)->hdr;
+ memcpy(bih, &vih->bmiHeader, sizeof(BITMAPINFOHEADER));
+ return true;
+ }
+ }
+
+ return false;
}
bool ExtractAvgTimePerFrame(const AM_MEDIA_TYPE* pmt, REFERENCE_TIME& rtAvgTimePerFrame)
{
- if(pmt->formattype == FORMAT_VideoInfo)
- rtAvgTimePerFrame = ((VIDEOINFOHEADER*)pmt->pbFormat)->AvgTimePerFrame;
- else if(pmt->formattype == FORMAT_VideoInfo2)
- rtAvgTimePerFrame = ((VIDEOINFOHEADER2*)pmt->pbFormat)->AvgTimePerFrame;
- else if(pmt->formattype == FORMAT_MPEGVideo)
- rtAvgTimePerFrame = ((MPEG1VIDEOINFO*)pmt->pbFormat)->hdr.AvgTimePerFrame;
- else if(pmt->formattype == FORMAT_MPEG2Video)
- rtAvgTimePerFrame = ((MPEG2VIDEOINFO*)pmt->pbFormat)->hdr.AvgTimePerFrame;
- else
- return false;
+ if (pmt->formattype==FORMAT_VideoInfo)
+ rtAvgTimePerFrame = ((VIDEOINFOHEADER*)pmt->pbFormat)->AvgTimePerFrame;
+ else if (pmt->formattype==FORMAT_VideoInfo2)
+ rtAvgTimePerFrame = ((VIDEOINFOHEADER2*)pmt->pbFormat)->AvgTimePerFrame;
+ else if (pmt->formattype==FORMAT_MPEGVideo)
+ rtAvgTimePerFrame = ((MPEG1VIDEOINFO*)pmt->pbFormat)->hdr.AvgTimePerFrame;
+ else if (pmt->formattype==FORMAT_MPEG2Video)
+ rtAvgTimePerFrame = ((MPEG2VIDEOINFO*)pmt->pbFormat)->hdr.AvgTimePerFrame;
+ else
+ return false;
- return true;
+ return true;
}
bool ExtractBIH(IMediaSample* pMS, BITMAPINFOHEADER* bih)
{
- AM_MEDIA_TYPE* pmt = NULL;
- pMS->GetMediaType(&pmt);
- if(pmt)
- {
- bool fRet = ExtractBIH(pmt, bih);
- DeleteMediaType(pmt);
- return(fRet);
- }
-
- return(false);
+ AM_MEDIA_TYPE* pmt = NULL;
+ pMS->GetMediaType(&pmt);
+ if(pmt)
+ {
+ bool fRet = ExtractBIH(pmt, bih);
+ DeleteMediaType(pmt);
+ return(fRet);
+ }
+
+ return(false);
}
bool ExtractDim(const AM_MEDIA_TYPE* pmt, int& w, int& h, int& arx, int& ary)
{
- w = h = arx = ary = 0;
-
- if(pmt->formattype == FORMAT_VideoInfo || pmt->formattype == FORMAT_MPEGVideo)
- {
- VIDEOINFOHEADER* vih = (VIDEOINFOHEADER*)pmt->pbFormat;
- w = vih->bmiHeader.biWidth;
- h = abs(vih->bmiHeader.biHeight);
- arx = w * vih->bmiHeader.biYPelsPerMeter;
- ary = h * vih->bmiHeader.biXPelsPerMeter;
- }
- else if(pmt->formattype == FORMAT_VideoInfo2 || pmt->formattype == FORMAT_MPEG2_VIDEO || pmt->formattype == FORMAT_DiracVideoInfo)
- {
- VIDEOINFOHEADER2* vih = (VIDEOINFOHEADER2*)pmt->pbFormat;
- w = vih->bmiHeader.biWidth;
- h = abs(vih->bmiHeader.biHeight);
- arx = vih->dwPictAspectRatioX;
- ary = vih->dwPictAspectRatioY;
- }
- else
- {
- return(false);
- }
-
- if(!arx || !ary)
- {
- arx = w;
- ary = h;
- }
-
- BYTE* ptr = NULL;
- DWORD len = 0;
-
- if(pmt->formattype == FORMAT_MPEGVideo)
- {
- ptr = ((MPEG1VIDEOINFO*)pmt->pbFormat)->bSequenceHeader;
- len = ((MPEG1VIDEOINFO*)pmt->pbFormat)->cbSequenceHeader;
-
- if(ptr && len >= 8 && *(DWORD*)ptr == 0xb3010000)
- {
- w = (ptr[4] << 4) | (ptr[5] >> 4);
- h = ((ptr[5] & 0xf) << 8) | ptr[6];
- float ar[] =
- {
- 1.0000f, 1.0000f, 0.6735f, 0.7031f,
- 0.7615f, 0.8055f, 0.8437f, 0.8935f,
- 0.9157f, 0.9815f, 1.0255f, 1.0695f,
- 1.0950f, 1.1575f, 1.2015f, 1.0000f,
- };
- arx = (int)((float)w / ar[ptr[7] >> 4] + 0.5);
- ary = h;
- }
- }
- else if(pmt->formattype == FORMAT_MPEG2_VIDEO)
- {
- ptr = (BYTE*)((MPEG2VIDEOINFO*)pmt->pbFormat)->dwSequenceHeader;
- len = ((MPEG2VIDEOINFO*)pmt->pbFormat)->cbSequenceHeader;
-
- if(ptr && len >= 8 && *(DWORD*)ptr == 0xb3010000)
- {
- w = (ptr[4] << 4) | (ptr[5] >> 4);
- h = ((ptr[5] & 0xf) << 8) | ptr[6];
- struct
- {
- int x, y;
- } ar[] = {{w, h}, {4, 3}, {16, 9}, {221, 100}, {w, h}};
- int i = min(max(ptr[7] >> 4, 1), 5) - 1;
- arx = ar[i].x;
- ary = ar[i].y;
- }
- }
-
- if(ptr && len >= 8)
- {
-
- }
-
- DWORD a = arx, b = ary;
- while(a)
- {
- int tmp = a;
- a = b % tmp;
- b = tmp;
- }
- if(b) arx /= b, ary /= b;
-
- return(true);
+ w = h = arx = ary = 0;
+
+ if(pmt->formattype == FORMAT_VideoInfo || pmt->formattype == FORMAT_MPEGVideo)
+ {
+ VIDEOINFOHEADER* vih = (VIDEOINFOHEADER*)pmt->pbFormat;
+ w = vih->bmiHeader.biWidth;
+ h = abs(vih->bmiHeader.biHeight);
+ arx = w * vih->bmiHeader.biYPelsPerMeter;
+ ary = h * vih->bmiHeader.biXPelsPerMeter;
+ }
+ else if(pmt->formattype == FORMAT_VideoInfo2 || pmt->formattype == FORMAT_MPEG2_VIDEO || pmt->formattype == FORMAT_DiracVideoInfo)
+ {
+ VIDEOINFOHEADER2* vih = (VIDEOINFOHEADER2*)pmt->pbFormat;
+ w = vih->bmiHeader.biWidth;
+ h = abs(vih->bmiHeader.biHeight);
+ arx = vih->dwPictAspectRatioX;
+ ary = vih->dwPictAspectRatioY;
+ }
+ else
+ {
+ return(false);
+ }
+
+ if(!arx || !ary)
+ {
+ arx = w;
+ ary = h;
+ }
+
+ BYTE* ptr = NULL;
+ DWORD len = 0;
+
+ if(pmt->formattype == FORMAT_MPEGVideo)
+ {
+ ptr = ((MPEG1VIDEOINFO*)pmt->pbFormat)->bSequenceHeader;
+ len = ((MPEG1VIDEOINFO*)pmt->pbFormat)->cbSequenceHeader;
+
+ if(ptr && len >= 8 && *(DWORD*)ptr == 0xb3010000)
+ {
+ w = (ptr[4]<<4)|(ptr[5]>>4);
+ h = ((ptr[5]&0xf)<<8)|ptr[6];
+ float ar[] =
+ {
+ 1.0000f,1.0000f,0.6735f,0.7031f,
+ 0.7615f,0.8055f,0.8437f,0.8935f,
+ 0.9157f,0.9815f,1.0255f,1.0695f,
+ 1.0950f,1.1575f,1.2015f,1.0000f,
+ };
+ arx = (int)((float)w / ar[ptr[7]>>4] + 0.5);
+ ary = h;
+ }
+ }
+ else if(pmt->formattype == FORMAT_MPEG2_VIDEO)
+ {
+ ptr = (BYTE*)((MPEG2VIDEOINFO*)pmt->pbFormat)->dwSequenceHeader;
+ len = ((MPEG2VIDEOINFO*)pmt->pbFormat)->cbSequenceHeader;
+
+ if(ptr && len >= 8 && *(DWORD*)ptr == 0xb3010000)
+ {
+ w = (ptr[4]<<4)|(ptr[5]>>4);
+ h = ((ptr[5]&0xf)<<8)|ptr[6];
+ struct {int x, y;} ar[] = {{w,h},{4,3},{16,9},{221,100},{w,h}};
+ int i = min(max(ptr[7]>>4, 1), 5)-1;
+ arx = ar[i].x;
+ ary = ar[i].y;
+ }
+ }
+
+ if(ptr && len >= 8)
+ {
+
+ }
+
+ DWORD a = arx, b = ary;
+ while(a) {int tmp = a; a = b % tmp; b = tmp;}
+ if(b) arx /= b, ary /= b;
+
+ return(true);
}
bool MakeMPEG2MediaType(CMediaType& mt, BYTE* seqhdr, DWORD len, int w, int h)
{
- if(len < 4 || *(DWORD*)seqhdr != 0xb3010000) return false;
-
- BYTE* seqhdr_ext = NULL;
-
- BYTE* seqhdr_end = seqhdr + 11;
- if(seqhdr_end - seqhdr > (long)len) return false;
- if(*seqhdr_end & 0x02) seqhdr_end += 64;
- if(seqhdr_end - seqhdr > (long)len) return false;
- if(*seqhdr_end & 0x01) seqhdr_end += 64;
- if(seqhdr_end - seqhdr > (long)len) return false;
- seqhdr_end++;
- if(seqhdr_end - seqhdr > (long)len) return false;
- if(len - (seqhdr_end - seqhdr) > 4 && *(DWORD*)seqhdr_end == 0xb5010000)
- {
- seqhdr_ext = seqhdr_end;
- seqhdr_end += 10;
- }
- if(seqhdr_end - seqhdr > (long)len) return false;
-
- len = seqhdr_end - seqhdr;
-
- mt = CMediaType();
-
- mt.majortype = MEDIATYPE_Video;
- mt.subtype = MEDIASUBTYPE_MPEG2_VIDEO;
- mt.formattype = FORMAT_MPEG2Video;
-
- MPEG2VIDEOINFO* vih = (MPEG2VIDEOINFO*)mt.AllocFormatBuffer(FIELD_OFFSET(MPEG2VIDEOINFO, dwSequenceHeader) + len);
- memset(mt.Format(), 0, mt.FormatLength());
- vih->hdr.bmiHeader.biSize = sizeof(vih->hdr.bmiHeader);
- vih->hdr.bmiHeader.biWidth = w;
- vih->hdr.bmiHeader.biHeight = h;
-
- BYTE* pSequenceHeader = (BYTE*)vih->dwSequenceHeader;
- memcpy(pSequenceHeader, seqhdr, len);
- vih->cbSequenceHeader = len;
-
- static char profile[8] =
- {
- 0, AM_MPEG2Profile_High, AM_MPEG2Profile_SpatiallyScalable, AM_MPEG2Profile_SNRScalable,
- AM_MPEG2Profile_Main, AM_MPEG2Profile_Simple, 0, 0
- };
-
- static char level[16] =
- {
- 0, 0, 0, 0,
- AM_MPEG2Level_High, 0, AM_MPEG2Level_High1440, 0,
- AM_MPEG2Level_Main, 0, AM_MPEG2Level_Low, 0,
- 0, 0, 0, 0
- };
-
- if(seqhdr_ext && (seqhdr_ext[4] & 0xf0) == 0x10)
- {
- vih->dwProfile = profile[seqhdr_ext[4] & 0x07];
- vih->dwLevel = level[seqhdr_ext[5] >> 4];
- }
-
- return true;
+ if(len < 4 || *(DWORD*)seqhdr != 0xb3010000) return false;
+
+ BYTE* seqhdr_ext = NULL;
+
+ BYTE* seqhdr_end = seqhdr + 11;
+ if(seqhdr_end - seqhdr > (long)len) return false;
+ if(*seqhdr_end & 0x02) seqhdr_end += 64;
+ if(seqhdr_end - seqhdr > (long)len) return false;
+ if(*seqhdr_end & 0x01) seqhdr_end += 64;
+ if(seqhdr_end - seqhdr > (long)len) return false;
+ seqhdr_end++;
+ if(seqhdr_end - seqhdr > (long)len) return false;
+ if(len - (seqhdr_end - seqhdr) > 4 && *(DWORD*)seqhdr_end == 0xb5010000) {seqhdr_ext = seqhdr_end; seqhdr_end += 10;}
+ if(seqhdr_end - seqhdr > (long)len) return false;
+
+ len = seqhdr_end - seqhdr;
+
+ mt = CMediaType();
+
+ mt.majortype = MEDIATYPE_Video;
+ mt.subtype = MEDIASUBTYPE_MPEG2_VIDEO;
+ mt.formattype = FORMAT_MPEG2Video;
+
+ MPEG2VIDEOINFO* vih = (MPEG2VIDEOINFO*)mt.AllocFormatBuffer(FIELD_OFFSET(MPEG2VIDEOINFO, dwSequenceHeader) + len);
+ memset(mt.Format(), 0, mt.FormatLength());
+ vih->hdr.bmiHeader.biSize = sizeof(vih->hdr.bmiHeader);
+ vih->hdr.bmiHeader.biWidth = w;
+ vih->hdr.bmiHeader.biHeight = h;
+
+ BYTE* pSequenceHeader = (BYTE*)vih->dwSequenceHeader;
+ memcpy(pSequenceHeader, seqhdr, len);
+ vih->cbSequenceHeader = len;
+
+ static char profile[8] =
+ {
+ 0, AM_MPEG2Profile_High, AM_MPEG2Profile_SpatiallyScalable, AM_MPEG2Profile_SNRScalable,
+ AM_MPEG2Profile_Main, AM_MPEG2Profile_Simple, 0, 0
+ };
+
+ static char level[16] =
+ {
+ 0, 0, 0, 0,
+ AM_MPEG2Level_High, 0, AM_MPEG2Level_High1440, 0,
+ AM_MPEG2Level_Main, 0, AM_MPEG2Level_Low, 0,
+ 0, 0, 0, 0
+ };
+
+ if(seqhdr_ext && (seqhdr_ext[4] & 0xf0) == 0x10)
+ {
+ vih->dwProfile = profile[seqhdr_ext[4] & 0x07];
+ vih->dwLevel = level[seqhdr_ext[5] >> 4];
+ }
+
+ return true;
}
unsigned __int64 GetFileVersion(LPCTSTR fn)
{
- unsigned __int64 ret = 0;
-
- DWORD buff[4];
- VS_FIXEDFILEINFO* pvsf = (VS_FIXEDFILEINFO*)buff;
- DWORD d; // a variable that GetFileVersionInfoSize sets to zero (but why is it needed ?????????????????????????????? :)
- DWORD len = GetFileVersionInfoSize((TCHAR*)fn, &d);
-
- if(len)
- {
- TCHAR* b1 = DNew TCHAR[len];
- if(b1)
- {
+ unsigned __int64 ret = 0;
+
+ DWORD buff[4];
+ VS_FIXEDFILEINFO* pvsf = (VS_FIXEDFILEINFO*)buff;
+ DWORD d; // a variable that GetFileVersionInfoSize sets to zero (but why is it needed ?????????????????????????????? :)
+ DWORD len = GetFileVersionInfoSize((TCHAR*)fn, &d);
+
+ if(len)
+ {
+ TCHAR* b1 = DNew TCHAR[len];
+ if(b1)
+ {
UINT uLen;
if(GetFileVersionInfo((TCHAR*)fn, 0, len, b1) && VerQueryValue(b1, _T("\\"), (void**)&pvsf, &uLen))
{
- ret = ((unsigned __int64)pvsf->dwFileVersionMS << 32) | pvsf->dwFileVersionLS;
+ ret = ((unsigned __int64)pvsf->dwFileVersionMS<<32) | pvsf->dwFileVersionLS;
}
delete [] b1;
- }
- }
+ }
+ }
- return ret;
+ return ret;
}
bool CreateFilter(CStringW DisplayName, IBaseFilter** ppBF, CStringW& FriendlyName)
{
- if(!ppBF) return(false);
+ if(!ppBF) return(false);
- *ppBF = NULL;
- FriendlyName.Empty();
+ *ppBF = NULL;
+ FriendlyName.Empty();
- CComPtr<IBindCtx> pBindCtx;
- CreateBindCtx(0, &pBindCtx);
+ CComPtr<IBindCtx> pBindCtx;
+ CreateBindCtx(0, &pBindCtx);
- CComPtr<IMoniker> pMoniker;
- ULONG chEaten;
- if(S_OK != MkParseDisplayName(pBindCtx, CComBSTR(DisplayName), &chEaten, &pMoniker))
- return(false);
+ CComPtr<IMoniker> pMoniker;
+ ULONG chEaten;
+ if(S_OK != MkParseDisplayName(pBindCtx, CComBSTR(DisplayName), &chEaten, &pMoniker))
+ return(false);
- if(FAILED(pMoniker->BindToObject(pBindCtx, 0, IID_IBaseFilter, (void**)ppBF)) || !*ppBF)
- return(false);
+ if(FAILED(pMoniker->BindToObject(pBindCtx, 0, IID_IBaseFilter, (void**)ppBF)) || !*ppBF)
+ return(false);
- CComPtr<IPropertyBag> pPB;
- CComVariant var;
- if(SUCCEEDED(pMoniker->BindToStorage(pBindCtx, 0, IID_IPropertyBag, (void**)&pPB))
- && SUCCEEDED(pPB->Read(CComBSTR(_T("FriendlyName")), &var, NULL)))
- FriendlyName = var.bstrVal;
+ CComPtr<IPropertyBag> pPB;
+ CComVariant var;
+ if(SUCCEEDED(pMoniker->BindToStorage(pBindCtx, 0, IID_IPropertyBag, (void**)&pPB))
+ && SUCCEEDED(pPB->Read(CComBSTR(_T("FriendlyName")), &var, NULL)))
+ FriendlyName = var.bstrVal;
- return(true);
+ return(true);
}
IBaseFilter* AppendFilter(IPin* pPin, IMoniker* pMoniker, IGraphBuilder* pGB)
{
- do
- {
- if(!pPin || !pMoniker || !pGB)
- break;
+ do
+ {
+ if(!pPin || !pMoniker || !pGB)
+ break;
- CComPtr<IPin> pPinTo;
- PIN_DIRECTION dir;
- if(FAILED(pPin->QueryDirection(&dir)) || dir != PINDIR_OUTPUT || SUCCEEDED(pPin->ConnectedTo(&pPinTo)))
- break;
+ CComPtr<IPin> pPinTo;
+ PIN_DIRECTION dir;
+ if(FAILED(pPin->QueryDirection(&dir)) || dir != PINDIR_OUTPUT || SUCCEEDED(pPin->ConnectedTo(&pPinTo)))
+ break;
- CComPtr<IBindCtx> pBindCtx;
- CreateBindCtx(0, &pBindCtx);
+ CComPtr<IBindCtx> pBindCtx;
+ CreateBindCtx(0, &pBindCtx);
- CComPtr<IPropertyBag> pPB;
- if(FAILED(pMoniker->BindToStorage(pBindCtx, 0, IID_IPropertyBag, (void**)&pPB)))
- break;
+ CComPtr<IPropertyBag> pPB;
+ if(FAILED(pMoniker->BindToStorage(pBindCtx, 0, IID_IPropertyBag, (void**)&pPB)))
+ break;
- CComVariant var;
- if(FAILED(pPB->Read(CComBSTR(_T("FriendlyName")), &var, NULL)))
- break;
+ CComVariant var;
+ if(FAILED(pPB->Read(CComBSTR(_T("FriendlyName")), &var, NULL)))
+ break;
- CComPtr<IBaseFilter> pBF;
- if(FAILED(pMoniker->BindToObject(pBindCtx, 0, IID_IBaseFilter, (void**)&pBF)) || !pBF)
- break;
+ CComPtr<IBaseFilter> pBF;
+ if(FAILED(pMoniker->BindToObject(pBindCtx, 0, IID_IBaseFilter, (void**)&pBF)) || !pBF)
+ break;
- if(FAILED(pGB->AddFilter(pBF, CStringW(var.bstrVal))))
- break;
+ if(FAILED(pGB->AddFilter(pBF, CStringW(var.bstrVal))))
+ break;
- BeginEnumPins(pBF, pEP, pPinTo)
- {
- PIN_DIRECTION dir;
- if(FAILED(pPinTo->QueryDirection(&dir)) || dir != PINDIR_INPUT)
- continue;
+ BeginEnumPins(pBF, pEP, pPinTo)
+ {
+ PIN_DIRECTION dir;
+ if(FAILED(pPinTo->QueryDirection(&dir)) || dir != PINDIR_INPUT)
+ continue;
- if(SUCCEEDED(pGB->ConnectDirect(pPin, pPinTo, NULL)))
- return(pBF);
- }
- EndEnumFilters
+ if(SUCCEEDED(pGB->ConnectDirect(pPin, pPinTo, NULL)))
+ return(pBF);
+ }
+ EndEnumFilters
- pGB->RemoveFilter(pBF);
- }
- while(false);
+ pGB->RemoveFilter(pBF);
+ }
+ while(false);
- return(NULL);
+ return(NULL);
}
CStringW GetFriendlyName(CStringW DisplayName)
{
- CStringW FriendlyName;
+ CStringW FriendlyName;
- CComPtr<IBindCtx> pBindCtx;
- CreateBindCtx(0, &pBindCtx);
+ CComPtr<IBindCtx> pBindCtx;
+ CreateBindCtx(0, &pBindCtx);
- CComPtr<IMoniker> pMoniker;
- ULONG chEaten;
- if(S_OK != MkParseDisplayName(pBindCtx, CComBSTR(DisplayName), &chEaten, &pMoniker))
- return(false);
+ CComPtr<IMoniker> pMoniker;
+ ULONG chEaten;
+ if(S_OK != MkParseDisplayName(pBindCtx, CComBSTR(DisplayName), &chEaten, &pMoniker))
+ return(false);
- CComPtr<IPropertyBag> pPB;
- CComVariant var;
- if(SUCCEEDED(pMoniker->BindToStorage(pBindCtx, 0, IID_IPropertyBag, (void**)&pPB))
- && SUCCEEDED(pPB->Read(CComBSTR(_T("FriendlyName")), &var, NULL)))
- FriendlyName = var.bstrVal;
+ CComPtr<IPropertyBag> pPB;
+ CComVariant var;
+ if(SUCCEEDED(pMoniker->BindToStorage(pBindCtx, 0, IID_IPropertyBag, (void**)&pPB))
+ && SUCCEEDED(pPB->Read(CComBSTR(_T("FriendlyName")), &var, NULL)))
+ FriendlyName = var.bstrVal;
- return FriendlyName;
+ return FriendlyName;
}
typedef struct
{
- CString path;
- HINSTANCE hInst;
- CLSID clsid;
+ CString path;
+ HINSTANCE hInst;
+ CLSID clsid;
} ExternalObject;
static CAtlList<ExternalObject> s_extobjs;
HRESULT LoadExternalObject(LPCTSTR path, REFCLSID clsid, REFIID iid, void** ppv)
{
- CheckPointer(ppv, E_POINTER);
-
- CString fullpath = MakeFullPath(path);
-
- HINSTANCE hInst = NULL;
- bool fFound = false;
-
- POSITION pos = s_extobjs.GetHeadPosition();
- while(pos)
- {
- ExternalObject& eo = s_extobjs.GetNext(pos);
- if(!eo.path.CompareNoCase(fullpath))
- {
- hInst = eo.hInst;
- fFound = true;
- break;
- }
- }
-
- HRESULT hr = E_FAIL;
-
- if(hInst || (hInst = CoLoadLibrary(CComBSTR(fullpath), TRUE)))
- {
- typedef HRESULT(__stdcall * PDllGetClassObject)(REFCLSID rclsid, REFIID riid, LPVOID * ppv);
- PDllGetClassObject p = (PDllGetClassObject)GetProcAddress(hInst, "DllGetClassObject");
-
- if(p && FAILED(hr = p(clsid, iid, ppv)))
- {
- CComPtr<IClassFactory> pCF;
- if(SUCCEEDED(hr = p(clsid, __uuidof(IClassFactory), (void**)&pCF)))
- {
- hr = pCF->CreateInstance(NULL, iid, ppv);
- }
- }
- }
-
- if(FAILED(hr) && hInst && !fFound)
- {
- CoFreeLibrary(hInst);
- return hr;
- }
-
- if(hInst && !fFound)
- {
- ExternalObject eo;
- eo.path = fullpath;
- eo.hInst = hInst;
- eo.clsid = clsid;
- s_extobjs.AddTail(eo);
- }
-
- return hr;
+ CheckPointer(ppv, E_POINTER);
+
+ CString fullpath = MakeFullPath(path);
+
+ HINSTANCE hInst = NULL;
+ bool fFound = false;
+
+ POSITION pos = s_extobjs.GetHeadPosition();
+ while(pos)
+ {
+ ExternalObject& eo = s_extobjs.GetNext(pos);
+ if(!eo.path.CompareNoCase(fullpath))
+ {
+ hInst = eo.hInst;
+ fFound = true;
+ break;
+ }
+ }
+
+ HRESULT hr = E_FAIL;
+
+ if(hInst || (hInst = CoLoadLibrary(CComBSTR(fullpath), TRUE)))
+ {
+ typedef HRESULT (__stdcall * PDllGetClassObject)(REFCLSID rclsid, REFIID riid, LPVOID* ppv);
+ PDllGetClassObject p = (PDllGetClassObject)GetProcAddress(hInst, "DllGetClassObject");
+
+ if(p && FAILED(hr = p(clsid, iid, ppv)))
+ {
+ CComPtr<IClassFactory> pCF;
+ if(SUCCEEDED(hr = p(clsid, __uuidof(IClassFactory), (void**)&pCF)))
+ {
+ hr = pCF->CreateInstance(NULL, iid, ppv);
+ }
+ }
+ }
+
+ if(FAILED(hr) && hInst && !fFound)
+ {
+ CoFreeLibrary(hInst);
+ return hr;
+ }
+
+ if(hInst && !fFound)
+ {
+ ExternalObject eo;
+ eo.path = fullpath;
+ eo.hInst = hInst;
+ eo.clsid = clsid;
+ s_extobjs.AddTail(eo);
+ }
+
+ return hr;
}
HRESULT LoadExternalFilter(LPCTSTR path, REFCLSID clsid, IBaseFilter** ppBF)
{
- return LoadExternalObject(path, clsid, __uuidof(IBaseFilter), (void**)ppBF);
+ return LoadExternalObject(path, clsid, __uuidof(IBaseFilter), (void**)ppBF);
}
HRESULT LoadExternalPropertyPage(IPersist* pP, REFCLSID clsid, IPropertyPage** ppPP)
{
- CLSID clsid2 = GUID_NULL;
- if(FAILED(pP->GetClassID(&clsid2))) return E_FAIL;
+ CLSID clsid2 = GUID_NULL;
+ if(FAILED(pP->GetClassID(&clsid2))) return E_FAIL;
- POSITION pos = s_extobjs.GetHeadPosition();
- while(pos)
- {
- ExternalObject& eo = s_extobjs.GetNext(pos);
- if(eo.clsid == clsid2)
- {
- return LoadExternalObject(eo.path, clsid, __uuidof(IPropertyPage), (void**)ppPP);
- }
- }
+ POSITION pos = s_extobjs.GetHeadPosition();
+ while(pos)
+ {
+ ExternalObject& eo = s_extobjs.GetNext(pos);
+ if(eo.clsid == clsid2)
+ {
+ return LoadExternalObject(eo.path, clsid, __uuidof(IPropertyPage), (void**)ppPP);
+ }
+ }
- return E_FAIL;
+ return E_FAIL;
}
void UnloadExternalObjects()
{
- POSITION pos = s_extobjs.GetHeadPosition();
- while(pos)
- {
- ExternalObject& eo = s_extobjs.GetNext(pos);
- CoFreeLibrary(eo.hInst);
- }
- s_extobjs.RemoveAll();
+ POSITION pos = s_extobjs.GetHeadPosition();
+ while(pos)
+ {
+ ExternalObject& eo = s_extobjs.GetNext(pos);
+ CoFreeLibrary(eo.hInst);
+ }
+ s_extobjs.RemoveAll();
}
CString MakeFullPath(LPCTSTR path)
{
- CString full(path);
- full.Replace('/', '\\');
+ CString full(path);
+ full.Replace('/', '\\');
- CString fn;
- fn.ReleaseBuffer(GetModuleFileName(AfxGetInstanceHandle(), fn.GetBuffer(MAX_PATH), MAX_PATH));
- CPath p(fn);
+ CString fn;
+ fn.ReleaseBuffer(GetModuleFileName(AfxGetInstanceHandle(), fn.GetBuffer(MAX_PATH), MAX_PATH));
+ CPath p(fn);
- if(full.GetLength() >= 2 && full[0] == '\\' && full[1] != '\\')
- {
- p.StripToRoot();
- full = CString(p) + full.Mid(1);
- }
- else if(full.Find(_T(":\\")) < 0)
- {
- p.RemoveFileSpec();
- p.AddBackslash();
- full = CString(p) + full;
- }
+ if(full.GetLength() >= 2 && full[0] == '\\' && full[1] != '\\')
+ {
+ p.StripToRoot();
+ full = CString(p) + full.Mid(1);
+ }
+ else if(full.Find(_T(":\\")) < 0)
+ {
+ p.RemoveFileSpec();
+ p.AddBackslash();
+ full = CString(p) + full;
+ }
- CPath c(full);
- c.Canonicalize();
- return CString(c);
+ CPath c(full);
+ c.Canonicalize();
+ return CString(c);
}
//
CString GetMediaTypeName(const GUID& guid)
{
- CString ret = guid == GUID_NULL
- ? _T("Any type")
- : CString(GuidNames[guid]);
-
- if(ret == _T("FOURCC GUID"))
- {
- CString str;
- if(guid.Data1 >= 0x10000)
- str.Format(_T("Video: %c%c%c%c"), (guid.Data1 >> 0) & 0xff, (guid.Data1 >> 8) & 0xff, (guid.Data1 >> 16) & 0xff, (guid.Data1 >> 24) & 0xff);
- else
- str.Format(_T("Audio: 0x%08x"), guid.Data1);
- ret = str;
- }
- else if(ret == _T("Unknown GUID Name"))
- {
- WCHAR null[128] = {0}, buff[128];
- StringFromGUID2(GUID_NULL, null, 127);
- ret = CString(CStringW(StringFromGUID2(guid, buff, 127) ? buff : null));
- }
-
- return ret;
+ CString ret = guid == GUID_NULL
+ ? _T("Any type")
+ : CString(GuidNames[guid]);
+
+ if(ret == _T("FOURCC GUID"))
+ {
+ CString str;
+ if(guid.Data1 >= 0x10000)
+ str.Format(_T("Video: %c%c%c%c"), (guid.Data1>>0)&0xff, (guid.Data1>>8)&0xff, (guid.Data1>>16)&0xff, (guid.Data1>>24)&0xff);
+ else
+ str.Format(_T("Audio: 0x%08x"), guid.Data1);
+ ret = str;
+ }
+ else if(ret == _T("Unknown GUID Name"))
+ {
+ WCHAR null[128] = {0}, buff[128];
+ StringFromGUID2(GUID_NULL, null, 127);
+ ret = CString(CStringW(StringFromGUID2(guid, buff, 127) ? buff : null));
+ }
+
+ return ret;
}
GUID GUIDFromCString(CString str)
{
- GUID guid = GUID_NULL;
- HRESULT hr = CLSIDFromString(CComBSTR(str), &guid);
- ASSERT(SUCCEEDED(hr));
- return guid;
+ GUID guid = GUID_NULL;
+ HRESULT hr = CLSIDFromString(CComBSTR(str), &guid);
+ ASSERT(SUCCEEDED(hr));
+ return guid;
}
HRESULT GUIDFromCString(CString str, GUID& guid)
{
- guid = GUID_NULL;
- return CLSIDFromString(CComBSTR(str), &guid);
+ guid = GUID_NULL;
+ return CLSIDFromString(CComBSTR(str), &guid);
}
CString CStringFromGUID(const GUID& guid)
{
- WCHAR null[128] = {0}, buff[128];
- StringFromGUID2(GUID_NULL, null, 127);
- return CString(StringFromGUID2(guid, buff, 127) > 0 ? buff : null);
+ WCHAR null[128] = {0}, buff[128];
+ StringFromGUID2(GUID_NULL, null, 127);
+ return CString(StringFromGUID2(guid, buff, 127) > 0 ? buff : null);
}
CStringW UTF8To16(LPCSTR utf8)
{
- CStringW str;
- int n = MultiByteToWideChar(CP_UTF8, 0, utf8, -1, NULL, 0) - 1;
- if(n < 0) return str;
- str.ReleaseBuffer(MultiByteToWideChar(CP_UTF8, 0, utf8, -1, str.GetBuffer(n), n + 1) - 1);
- return str;
+ CStringW str;
+ int n = MultiByteToWideChar(CP_UTF8, 0, utf8, -1, NULL, 0)-1;
+ if(n < 0) return str;
+ str.ReleaseBuffer(MultiByteToWideChar(CP_UTF8, 0, utf8, -1, str.GetBuffer(n), n+1)-1);
+ return str;
}
CStringA UTF16To8(LPCWSTR utf16)
{
- CStringA str;
- int n = WideCharToMultiByte(CP_UTF8, 0, utf16, -1, NULL, 0, NULL, NULL) - 1;
- if(n < 0) return str;
- str.ReleaseBuffer(WideCharToMultiByte(CP_UTF8, 0, utf16, -1, str.GetBuffer(n), n + 1, NULL, NULL) - 1);
- return str;
-}
-
-static struct
-{
- LPCSTR name, iso6392, iso6391;
- LCID lcid;
-} s_isolangs[] = // TODO : fill LCID !!!
-{
- {"Abkhazian", "abk", "ab"},
- {"Achinese", "ace", ""},
- {"Acoli", "ach", ""},
- {"Adangme", "ada", ""},
- {"Afar", "aar", "aa"},
- {"Afrihili", "afh", ""},
- {"Afrikaans", "afr", "af", MAKELCID(MAKELANGID(LANG_AFRIKAANS, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Afro-Asiatic (Other)", "afa", ""},
- {"Akan", "aka", "ak"},
- {"Akkadian", "akk", ""},
- {"Albanian", "alb", "sq"},
- {"Albanian", "sqi", "sq", MAKELCID(MAKELANGID(LANG_ALBANIAN, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Aleut", "ale", ""},
- {"Algonquian languages", "alg", ""},
- {"Altaic (Other)", "tut", ""},
- {"Amharic", "amh", "am"},
- {"Apache languages", "apa", ""},
- {"Arabic", "ara", "ar", MAKELCID(MAKELANGID(LANG_ARABIC, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Aragonese", "arg", "an"},
- {"Aramaic", "arc", ""},
- {"Arapaho", "arp", ""},
- {"Araucanian", "arn", ""},
- {"Arawak", "arw", ""},
- {"Armenian", "arm", "hy", MAKELCID(MAKELANGID(LANG_ARMENIAN, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Armenian", "hye", "hy", MAKELCID(MAKELANGID(LANG_ARMENIAN, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Artificial (Other)", "art", ""},
- {"Assamese", "asm", "as", MAKELCID(MAKELANGID(LANG_ASSAMESE, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Asturian; Bable", "ast", ""},
- {"Athapascan languages", "ath", ""},
- {"Australian languages", "aus", ""},
- {"Austronesian (Other)", "map", ""},
- {"Avaric", "ava", "av"},
- {"Avestan", "ave", "ae"},
- {"Awadhi", "awa", ""},
- {"Aymara", "aym", "ay"},
- {"Azerbaijani", "aze", "az", MAKELCID(MAKELANGID(LANG_AZERI, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Bable; Asturian", "ast", ""},
- {"Balinese", "ban", ""},
- {"Baltic (Other)", "bat", ""},
- {"Baluchi", "bal", ""},
- {"Bambara", "bam", "bm"},
- {"Bamileke languages", "bai", ""},
- {"Banda", "bad", ""},
- {"Bantu (Other)", "bnt", ""},
- {"Basa", "bas", ""},
- {"Bashkir", "bak", "ba", MAKELCID(MAKELANGID(LANG_BASHKIR, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Basque", "baq", "eu", MAKELCID(MAKELANGID(LANG_BASQUE, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Basque", "eus", "eu", MAKELCID(MAKELANGID(LANG_BASQUE, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Batak (Indonesia)", "btk", ""},
- {"Beja", "bej", ""},
- {"Belarusian", "bel", "be", MAKELCID(MAKELANGID(LANG_BELARUSIAN, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Bemba", "bem", ""},
- {"Bengali", "ben", "bn", MAKELCID(MAKELANGID(LANG_BENGALI, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Berber (Other)", "ber", ""},
- {"Bhojpuri", "bho", ""},
- {"Bihari", "bih", "bh"},
- {"Bikol", "bik", ""},
- {"Bini", "bin", ""},
- {"Bislama", "bis", "bi"},
- {"Bokmål, Norwegian; Norwegian Bokmål", "nob", "nb"},
- {"Bosnian", "bos", "bs"},
- {"Braj", "bra", ""},
- {"Breton", "bre", "br", MAKELCID(MAKELANGID(LANG_BRETON, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Buginese", "bug", ""},
- {"Bulgarian", "bul", "bg", MAKELCID(MAKELANGID(LANG_BULGARIAN, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Buriat", "bua", ""},
- {"Burmese", "bur", "my"},
- {"Burmese", "mya", "my"},
- {"Caddo", "cad", ""},
- {"Carib", "car", ""},
- {"Spanish; Castilian", "spa", "es", MAKELCID(MAKELANGID(LANG_SPANISH, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Catalan", "cat", "ca", MAKELCID(MAKELANGID(LANG_CATALAN, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Caucasian (Other)", "cau", ""},
- {"Cebuano", "ceb", ""},
- {"Celtic (Other)", "cel", ""},
- {"Central American Indian (Other)", "cai", ""},
- {"Chagatai", "chg", ""},
- {"Chamic languages", "cmc", ""},
- {"Chamorro", "cha", "ch"},
- {"Chechen", "che", "ce"},
- {"Cherokee", "chr", ""},
- {"Chewa; Chichewa; Nyanja", "nya", "ny"},
- {"Cheyenne", "chy", ""},
- {"Chibcha", "chb", ""},
- {"Chichewa; Chewa; Nyanja", "nya", "ny"},
- {"Chinese", "chi", "zh", MAKELCID(MAKELANGID(LANG_CHINESE, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Chinese", "zho", "zh"},
- {"Chinook jargon", "chn", ""},
- {"Chipewyan", "chp", ""},
- {"Choctaw", "cho", ""},
- {"Chuang; Zhuang", "zha", "za"},
- {"Church Slavic; Old Church Slavonic", "chu", "cu"},
- {"Old Church Slavonic; Old Slavonic; ", "chu", "cu"},
- {"Church Slavonic; Old Bulgarian; Church Slavic;", "chu", "cu"},
- {"Old Slavonic; Church Slavonic; Old Bulgarian;", "chu", "cu"},
- {"Church Slavic; Old Church Slavonic", "chu", "cu"},
- {"Chuukese", "chk", ""},
- {"Chuvash", "chv", "cv"},
- {"Coptic", "cop", ""},
- {"Cornish", "cor", "kw"},
- {"Corsican", "cos", "co", MAKELCID(MAKELANGID(LANG_CORSICAN, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Cree", "cre", "cr"},
- {"Creek", "mus", ""},
- {"Creoles and pidgins (Other)", "crp", ""},
- {"Creoles and pidgins,", "cpe", ""},
- // {"English-based (Other)", "", ""},
- {"Creoles and pidgins,", "cpf", ""},
- // {"French-based (Other)", "", ""},
- {"Creoles and pidgins,", "cpp", ""},
- // {"Portuguese-based (Other)", "", ""},
- {"Croatian", "scr", "hr", MAKELCID(MAKELANGID(LANG_CROATIAN, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Croatian", "hrv", "hr", MAKELCID(MAKELANGID(LANG_CROATIAN, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Cushitic (Other)", "cus", ""},
- {"Czech", "cze", "cs", MAKELCID(MAKELANGID(LANG_CZECH, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Czech", "ces", "cs", MAKELCID(MAKELANGID(LANG_CZECH, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Dakota", "dak", ""},
- {"Danish", "dan", "da", MAKELCID(MAKELANGID(LANG_DANISH, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Dargwa", "dar", ""},
- {"Dayak", "day", ""},
- {"Delaware", "del", ""},
- {"Dinka", "din", ""},
- {"Divehi", "div", "dv", MAKELCID(MAKELANGID(LANG_DIVEHI, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Dogri", "doi", ""},
- {"Dogrib", "dgr", ""},
- {"Dravidian (Other)", "dra", ""},
- {"Duala", "dua", ""},
- {"Dutch; Flemish", "dut", "nl", MAKELCID(MAKELANGID(LANG_DUTCH, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Dutch; Flemish", "nld", "nl", MAKELCID(MAKELANGID(LANG_DUTCH, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Dutch, Middle (ca. 1050-1350)", "dum", ""},
- {"Dyula", "dyu", ""},
- {"Dzongkha", "dzo", "dz"},
- {"Efik", "efi", ""},
- {"Egyptian (Ancient)", "egy", ""},
- {"Ekajuk", "eka", ""},
- {"Elamite", "elx", ""},
- {"English", "eng", "en", MAKELCID(MAKELANGID(LANG_ENGLISH, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"English, Middle (1100-1500)", "enm", ""},
- {"English, Old (ca.450-1100)", "ang", ""},
- {"Esperanto", "epo", "eo"},
- {"Estonian", "est", "et", MAKELCID(MAKELANGID(LANG_ESTONIAN, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Ewe", "ewe", "ee"},
- {"Ewondo", "ewo", ""},
- {"Fang", "fan", ""},
- {"Fanti", "fat", ""},
- {"Faroese", "fao", "fo", MAKELCID(MAKELANGID(LANG_FAEROESE, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Fijian", "fij", "fj"},
- {"Finnish", "fin", "fi", MAKELCID(MAKELANGID(LANG_FINNISH, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Finno-Ugrian (Other)", "fiu", ""},
- {"Flemish; Dutch", "dut", "nl"},
- {"Flemish; Dutch", "nld", "nl"},
- {"Fon", "fon", ""},
- {"French", "fre", "fr", MAKELCID(MAKELANGID(LANG_FRENCH, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"French", "fra*", "fr", MAKELCID(MAKELANGID(LANG_FRENCH, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"French", "fra", "fr", MAKELCID(MAKELANGID(LANG_FRENCH, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"French, Middle (ca.1400-1600)", "frm", ""},
- {"French, Old (842-ca.1400)", "fro", ""},
- {"Frisian", "fry", "fy", MAKELCID(MAKELANGID(LANG_FRISIAN, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Friulian", "fur", ""},
- {"Fulah", "ful", "ff"},
- {"Ga", "gaa", ""},
- {"Gaelic; Scottish Gaelic", "gla", "gd", MAKELCID(MAKELANGID(LANG_GALICIAN, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Gallegan", "glg", "gl"},
- {"Ganda", "lug", "lg"},
- {"Gayo", "gay", ""},
- {"Gbaya", "gba", ""},
- {"Geez", "gez", ""},
- {"Georgian", "geo", "ka", MAKELCID(MAKELANGID(LANG_GEORGIAN, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Georgian", "kat", "ka", MAKELCID(MAKELANGID(LANG_GEORGIAN, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"German", "ger", "de", MAKELCID(MAKELANGID(LANG_GERMAN, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"German", "deu", "de", MAKELCID(MAKELANGID(LANG_GERMAN, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"German, Low; Saxon, Low; Low German; Low Saxon", "nds", ""},
- {"German, Middle High (ca.1050-1500)", "gmh", ""},
- {"German, Old High (ca.750-1050)", "goh", ""},
- {"Germanic (Other)", "gem", ""},
- {"Gikuyu; Kikuyu", "kik", "ki"},
- {"Gilbertese", "gil", ""},
- {"Gondi", "gon", ""},
- {"Gorontalo", "gor", ""},
- {"Gothic", "got", ""},
- {"Grebo", "grb", ""},
- {"Greek, Ancient (to 1453)", "grc", "", MAKELCID(MAKELANGID(LANG_GREEK, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Greek, Modern (1453-)", "gre", "el", MAKELCID(MAKELANGID(LANG_GREEK, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Greek, Modern (1453-)", "ell", "el", MAKELCID(MAKELANGID(LANG_GREEK, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Greenlandic; Kalaallisut", "kal", "kl", MAKELCID(MAKELANGID(LANG_GREENLANDIC, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Guarani", "grn", "gn"},
- {"Gujarati", "guj", "gu", MAKELCID(MAKELANGID(LANG_GUJARATI, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Gwich´in", "gwi", ""},
- {"Haida", "hai", ""},
- {"Hausa", "hau", "ha", MAKELCID(MAKELANGID(LANG_HAUSA, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Hawaiian", "haw", ""},
- {"Hebrew", "heb", "he", MAKELCID(MAKELANGID(LANG_HEBREW, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Herero", "her", "hz"},
- {"Hiligaynon", "hil", ""},
- {"Himachali", "him", ""},
- {"Hindi", "hin", "hi", MAKELCID(MAKELANGID(LANG_HINDI, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Hiri Motu", "hmo", "ho"},
- {"Hittite", "hit", ""},
- {"Hmong", "hmn", ""},
- {"Hungarian", "hun", "hu", MAKELCID(MAKELANGID(LANG_HUNGARIAN, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Hupa", "hup", ""},
- {"Iban", "iba", ""},
- {"Icelandic", "ice", "is", MAKELCID(MAKELANGID(LANG_ICELANDIC, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Icelandic", "isl", "is", MAKELCID(MAKELANGID(LANG_ICELANDIC, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Ido", "ido", "io"},
- {"Igbo", "ibo", "ig", MAKELCID(MAKELANGID(LANG_IGBO, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Ijo", "ijo", ""},
- {"Iloko", "ilo", ""},
- {"Inari Sami", "smn", ""},
- {"Indic (Other)", "inc", ""},
- {"Indo-European (Other)", "ine", ""},
- {"Indonesian", "ind", "id", MAKELCID(MAKELANGID(LANG_INDONESIAN, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Ingush", "inh", ""},
- {"Interlingua (International", "ina", "ia"},
- // {"Auxiliary Language Association)", "", ""},
- {"Interlingue", "ile", "ie"},
- {"Inuktitut", "iku", "iu", MAKELCID(MAKELANGID(LANG_INUKTITUT, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Inupiaq", "ipk", "ik"},
- {"Iranian (Other)", "ira", ""},
- {"Irish", "gle", "ga", MAKELCID(MAKELANGID(LANG_IRISH, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Irish, Middle (900-1200)", "mga", "", MAKELCID(MAKELANGID(LANG_IRISH, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Irish, Old (to 900)", "sga", "", MAKELCID(MAKELANGID(LANG_IRISH, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Iroquoian languages", "iro", ""},
- {"Italian", "ita", "it", MAKELCID(MAKELANGID(LANG_ITALIAN, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Japanese", "jpn", "ja", MAKELCID(MAKELANGID(LANG_JAPANESE, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Javanese", "jav", "jv"},
- {"Judeo-Arabic", "jrb", ""},
- {"Judeo-Persian", "jpr", ""},
- {"Kabardian", "kbd", ""},
- {"Kabyle", "kab", ""},
- {"Kachin", "kac", ""},
- {"Kalaallisut; Greenlandic", "kal", "kl"},
- {"Kamba", "kam", ""},
- {"Kannada", "kan", "kn", MAKELCID(MAKELANGID(LANG_KANNADA, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Kanuri", "kau", "kr"},
- {"Kara-Kalpak", "kaa", ""},
- {"Karen", "kar", ""},
- {"Kashmiri", "kas", "ks", MAKELCID(MAKELANGID(LANG_KASHMIRI, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Kawi", "kaw", ""},
- {"Kazakh", "kaz", "kk", MAKELCID(MAKELANGID(LANG_KAZAK, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Khasi", "kha", ""},
- {"Khmer", "khm", "km", MAKELCID(MAKELANGID(LANG_KHMER, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Khoisan (Other)", "khi", ""},
- {"Khotanese", "kho", ""},
- {"Kikuyu; Gikuyu", "kik", "ki"},
- {"Kimbundu", "kmb", ""},
- {"Kinyarwanda", "kin", "rw", MAKELCID(MAKELANGID(LANG_KINYARWANDA, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Kirghiz", "kir", "ky"},
- {"Komi", "kom", "kv"},
- {"Kongo", "kon", "kg"},
- {"Konkani", "kok", "", MAKELCID(MAKELANGID(LANG_KONKANI, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Korean", "kor", "ko", MAKELCID(MAKELANGID(LANG_KOREAN, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Kosraean", "kos", ""},
- {"Kpelle", "kpe", ""},
- {"Kru", "kro", ""},
- {"Kuanyama; Kwanyama", "kua", "kj"},
- {"Kumyk", "kum", ""},
- {"Kurdish", "kur", "ku"},
- {"Kurukh", "kru", ""},
- {"Kutenai", "kut", ""},
- {"Kwanyama, Kuanyama", "kua", "kj"},
- {"Ladino", "lad", ""},
- {"Lahnda", "lah", ""},
- {"Lamba", "lam", ""},
- {"Lao", "lao", "lo", MAKELCID(MAKELANGID(LANG_LAO, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Latin", "lat", "la"},
- {"Latvian", "lav", "lv", MAKELCID(MAKELANGID(LANG_LATVIAN, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Letzeburgesch; Luxembourgish", "ltz", "lb"},
- {"Lezghian", "lez", ""},
- {"Limburgan; Limburger; Limburgish", "lim", "li"},
- {"Limburger; Limburgan; Limburgish;", "lim", "li"},
- {"Limburgish; Limburger; Limburgan", "lim", "li"},
- {"Lingala", "lin", "ln"},
- {"Lithuanian", "lit", "lt", MAKELCID(MAKELANGID(LANG_LITHUANIAN, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Low German; Low Saxon; German, Low; Saxon, Low", "nds", ""},
- {"Low Saxon; Low German; Saxon, Low; German, Low", "nds", ""},
- {"Lozi", "loz", ""},
- {"Luba-Katanga", "lub", "lu"},
- {"Luba-Lulua", "lua", ""},
- {"Luiseno", "lui", ""},
- {"Lule Sami", "smj", ""},
- {"Lunda", "lun", ""},
- {"Luo (Kenya and Tanzania)", "luo", ""},
- {"Lushai", "lus", ""},
- {"Luxembourgish; Letzeburgesch", "ltz", "lb", MAKELCID(MAKELANGID(LANG_LUXEMBOURGISH, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Macedonian", "mac", "mk", MAKELCID(MAKELANGID(LANG_MACEDONIAN, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Macedonian", "mkd", "mk", MAKELCID(MAKELANGID(LANG_MACEDONIAN, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Madurese", "mad", ""},
- {"Magahi", "mag", ""},
- {"Maithili", "mai", ""},
- {"Makasar", "mak", ""},
- {"Malagasy", "mlg", "mg"},
- {"Malay", "may", "ms", MAKELCID(MAKELANGID(LANG_MALAY, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Malay", "msa", "ms", MAKELCID(MAKELANGID(LANG_MALAY, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Malayalam", "mal", "ml", MAKELCID(MAKELANGID(LANG_MALAYALAM, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Maltese", "mlt", "mt", MAKELCID(MAKELANGID(LANG_MALTESE, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Manchu", "mnc", ""},
- {"Mandar", "mdr", ""},
- {"Mandingo", "man", ""},
- {"Manipuri", "mni", "", MAKELCID(MAKELANGID(LANG_MANIPURI, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Manobo languages", "mno", ""},
- {"Manx", "glv", "gv"},
- {"Maori", "mao", "mi", MAKELCID(MAKELANGID(LANG_MAORI, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Maori", "mri", "mi", MAKELCID(MAKELANGID(LANG_MAORI, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Marathi", "mar", "mr", MAKELCID(MAKELANGID(LANG_MARATHI, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Mari", "chm", ""},
- {"Marshallese", "mah", "mh"},
- {"Marwari", "mwr", ""},
- {"Masai", "mas", ""},
- {"Mayan languages", "myn", ""},
- {"Mende", "men", ""},
- {"Micmac", "mic", ""},
- {"Minangkabau", "min", ""},
- {"Miscellaneous languages", "mis", ""},
- {"Mohawk", "moh", "", MAKELCID(MAKELANGID(LANG_MOHAWK, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Moldavian", "mol", "mo"},
- {"Mon-Khmer (Other)", "mkh", ""},
- {"Mongo", "lol", ""},
- {"Mongolian", "mon", "mn", MAKELCID(MAKELANGID(LANG_MONGOLIAN, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Mossi", "mos", ""},
- {"Multiple languages", "mul", ""},
- {"Munda languages", "mun", ""},
- {"Nahuatl", "nah", ""},
- {"Nauru", "nau", "na"},
- {"Navaho, Navajo", "nav", "nv"},
- {"Navajo; Navaho", "nav", "nv"},
- {"Ndebele, North", "nde", "nd"},
- {"Ndebele, South", "nbl", "nr"},
- {"Ndonga", "ndo", "ng"},
- {"Neapolitan", "nap", ""},
- {"Nepali", "nep", "ne", MAKELCID(MAKELANGID(LANG_NEPALI, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Newari", "new", ""},
- {"Nias", "nia", ""},
- {"Niger-Kordofanian (Other)", "nic", ""},
- {"Nilo-Saharan (Other)", "ssa", ""},
- {"Niuean", "niu", ""},
- {"Norse, Old", "non", ""},
- {"North American Indian (Other)", "nai", ""},
- {"Northern Sami", "sme", "se"},
- {"North Ndebele", "nde", "nd"},
- {"Norwegian", "nor", "no", MAKELCID(MAKELANGID(LANG_NORWEGIAN, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Norwegian Bokmål; Bokmål, Norwegian", "nob", "nb", MAKELCID(MAKELANGID(LANG_NORWEGIAN, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Norwegian Nynorsk; Nynorsk, Norwegian", "nno", "nn", MAKELCID(MAKELANGID(LANG_NORWEGIAN, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Nubian languages", "nub", ""},
- {"Nyamwezi", "nym", ""},
- {"Nyanja; Chichewa; Chewa", "nya", "ny"},
- {"Nyankole", "nyn", ""},
- {"Nynorsk, Norwegian; Norwegian Nynorsk", "nno", "nn"},
- {"Nyoro", "nyo", ""},
- {"Nzima", "nzi", ""},
- {"Occitan (post 1500},; Provençal", "oci", "oc", MAKELCID(MAKELANGID(LANG_OCCITAN, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Ojibwa", "oji", "oj"},
- {"Old Bulgarian; Old Slavonic; Church Slavonic;", "chu", "cu"},
- {"Oriya", "ori", "or"},
- {"Oromo", "orm", "om"},
- {"Osage", "osa", ""},
- {"Ossetian; Ossetic", "oss", "os"},
- {"Ossetic; Ossetian", "oss", "os"},
- {"Otomian languages", "oto", ""},
- {"Pahlavi", "pal", ""},
- {"Palauan", "pau", ""},
- {"Pali", "pli", "pi"},
- {"Pampanga", "pam", ""},
- {"Pangasinan", "pag", ""},
- {"Panjabi", "pan", "pa"},
- {"Papiamento", "pap", ""},
- {"Papuan (Other)", "paa", ""},
- {"Persian", "per", "fa", MAKELCID(MAKELANGID(LANG_PERSIAN, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Persian", "fas", "fa", MAKELCID(MAKELANGID(LANG_PERSIAN, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Persian, Old (ca.600-400 B.C.)", "peo", ""},
- {"Philippine (Other)", "phi", ""},
- {"Phoenician", "phn", ""},
- {"Pohnpeian", "pon", ""},
- {"Polish", "pol", "pl", MAKELCID(MAKELANGID(LANG_POLISH, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Portuguese", "por", "pt", MAKELCID(MAKELANGID(LANG_PORTUGUESE, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Prakrit languages", "pra", ""},
- {"Provençal; Occitan (post 1500)", "oci", "oc"},
- {"Provençal, Old (to 1500)", "pro", ""},
- {"Pushto", "pus", "ps"},
- {"Quechua", "que", "qu", MAKELCID(MAKELANGID(LANG_QUECHUA, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Raeto-Romance", "roh", "rm"},
- {"Rajasthani", "raj", ""},
- {"Rapanui", "rap", ""},
- {"Rarotongan", "rar", ""},
- {"Reserved for local use", "qaa-qtz", ""},
- {"Romance (Other)", "roa", ""},
- {"Romanian", "rum", "ro", MAKELCID(MAKELANGID(LANG_ROMANIAN, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Romanian", "ron", "ro", MAKELCID(MAKELANGID(LANG_ROMANIAN, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Romany", "rom", ""},
- {"Rundi", "run", "rn"},
- {"Russian", "rus", "ru", MAKELCID(MAKELANGID(LANG_RUSSIAN, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Salishan languages", "sal", ""},
- {"Samaritan Aramaic", "sam", ""},
- {"Sami languages (Other)", "smi", ""},
- {"Samoan", "smo", "sm"},
- {"Sandawe", "sad", ""},
- {"Sango", "sag", "sg"},
- {"Sanskrit", "san", "sa", MAKELCID(MAKELANGID(LANG_SANSKRIT, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Santali", "sat", ""},
- {"Sardinian", "srd", "sc"},
- {"Sasak", "sas", ""},
- {"Saxon, Low; German, Low; Low Saxon; Low German", "nds", ""},
- {"Scots", "sco", ""},
- {"Scottish Gaelic; Gaelic", "gla", "gd"},
- {"Selkup", "sel", ""},
- {"Semitic (Other)", "sem", ""},
- {"Serbian", "scc", "sr", MAKELCID(MAKELANGID(LANG_SERBIAN, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Serbian", "srp", "sr", MAKELCID(MAKELANGID(LANG_SERBIAN, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Serer", "srr", ""},
- {"Shan", "shn", ""},
- {"Shona", "sna", "sn"},
- {"Sichuan Yi", "iii", "ii"},
- {"Sidamo", "sid", ""},
- {"Sign languages", "sgn", ""},
- {"Siksika", "bla", ""},
- {"Sindhi", "snd", "sd", MAKELCID(MAKELANGID(LANG_SINDHI, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Sinhalese", "sin", "si", MAKELCID(MAKELANGID(LANG_SINHALESE, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Sino-Tibetan (Other)", "sit", ""},
- {"Siouan languages", "sio", ""},
- {"Skolt Sami", "sms", ""},
- {"Slave (Athapascan)", "den", ""},
- {"Slavic (Other)", "sla", ""},
- {"Slovak", "slo", "sk", MAKELCID(MAKELANGID(LANG_SLOVAK, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Slovak", "slk", "sk", MAKELCID(MAKELANGID(LANG_SLOVAK, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Slovenian", "slv", "sl", MAKELCID(MAKELANGID(LANG_SLOVENIAN, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Sogdian", "sog", ""},
- {"Somali", "som", "so"},
- {"Songhai", "son", ""},
- {"Soninke", "snk", ""},
- {"Sorbian languages", "wen", ""},
- {"Sotho, Northern", "nso", "", MAKELCID(MAKELANGID(LANG_SOTHO, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Sotho, Southern", "sot", "st", MAKELCID(MAKELANGID(LANG_SOTHO, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"South American Indian (Other)", "sai", ""},
- {"Southern Sami", "sma", ""},
- {"South Ndebele", "nbl", "nr"},
- {"Spanish; Castilian", "spa", "es", MAKELCID(MAKELANGID(LANG_SPANISH, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Sukuma", "suk", ""},
- {"Sumerian", "sux", ""},
- {"Sundanese", "sun", "su"},
- {"Susu", "sus", ""},
- {"Swahili", "swa", "sw", MAKELCID(MAKELANGID(LANG_SWAHILI, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Swati", "ssw", "ss"},
- {"Swedish", "swe", "sv", MAKELCID(MAKELANGID(LANG_SWEDISH, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Syriac", "syr", "", MAKELCID(MAKELANGID(LANG_SYRIAC, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Tagalog", "tgl", "tl"},
- {"Tahitian", "tah", "ty"},
- {"Tai (Other)", "tai", ""},
- {"Tajik", "tgk", "tg", MAKELCID(MAKELANGID(LANG_TAJIK, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Tamashek", "tmh", ""},
- {"Tamil", "tam", "ta", MAKELCID(MAKELANGID(LANG_TAMIL, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Tatar", "tat", "tt", MAKELCID(MAKELANGID(LANG_TATAR, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Telugu", "tel", "te", MAKELCID(MAKELANGID(LANG_TELUGU, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Tereno", "ter", ""},
- {"Tetum", "tet", ""},
- {"Thai", "tha", "th", MAKELCID(MAKELANGID(LANG_THAI, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Tibetan", "tib", "bo", MAKELCID(MAKELANGID(LANG_TIBETAN, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Tibetan", "bod", "bo", MAKELCID(MAKELANGID(LANG_TIBETAN, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Tigre", "tig", ""},
- {"Tigrinya", "tir", "ti", MAKELCID(MAKELANGID(LANG_TIGRIGNA, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Timne", "tem", ""},
- {"Tiv", "tiv", ""},
- {"Tlingit", "tli", ""},
- {"Tok Pisin", "tpi", ""},
- {"Tokelau", "tkl", ""},
- {"Tonga (Nyasa)", "tog", ""},
- {"Tonga (Tonga Islands)", "ton", "to"},
- {"Tsimshian", "tsi", ""},
- {"Tsonga", "tso", "ts"},
- {"Tswana", "tsn", "tn", MAKELCID(MAKELANGID(LANG_TSWANA, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Tumbuka", "tum", ""},
- {"Tupi languages", "tup", ""},
- {"Turkish", "tur", "tr", MAKELCID(MAKELANGID(LANG_TURKISH, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Turkish, Ottoman (1500-1928)", "ota", "", MAKELCID(MAKELANGID(LANG_TURKISH, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Turkmen", "tuk", "tk", MAKELCID(MAKELANGID(LANG_TURKMEN, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Tuvalu", "tvl", ""},
- {"Tuvinian", "tyv", ""},
- {"Twi", "twi", "tw"},
- {"Ugaritic", "uga", ""},
- {"Uighur", "uig", "ug", MAKELCID(MAKELANGID(LANG_UIGHUR, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Ukrainian", "ukr", "uk", MAKELCID(MAKELANGID(LANG_UKRAINIAN, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Umbundu", "umb", ""},
- {"Undetermined", "und", ""},
- {"Urdu", "urd", "ur", MAKELCID(MAKELANGID(LANG_URDU, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Uzbek", "uzb", "uz", MAKELCID(MAKELANGID(LANG_UZBEK, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Vai", "vai", ""},
- {"Venda", "ven", "ve"},
- {"Vietnamese", "vie", "vi", MAKELCID(MAKELANGID(LANG_VIETNAMESE, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Volapük", "vol", "vo"},
- {"Votic", "vot", ""},
- {"Wakashan languages", "wak", ""},
- {"Walamo", "wal", ""},
- {"Walloon", "wln", "wa"},
- {"Waray", "war", ""},
- {"Washo", "was", ""},
- {"Welsh", "wel", "cy", MAKELCID(MAKELANGID(LANG_WELSH, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Welsh", "cym", "cy", MAKELCID(MAKELANGID(LANG_WELSH, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Wolof", "wol", "wo", MAKELCID(MAKELANGID(LANG_WOLOF, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Xhosa", "xho", "xh", MAKELCID(MAKELANGID(LANG_XHOSA, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Yakut", "sah", "", MAKELCID(MAKELANGID(LANG_YAKUT, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Yao", "yao", ""},
- {"Yapese", "yap", ""},
- {"Yiddish", "yid", "yi"},
- {"Yoruba", "yor", "yo", MAKELCID(MAKELANGID(LANG_YORUBA, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Yupik languages", "ypk", ""},
- {"Zande", "znd", ""},
- {"Zapotec", "zap", ""},
- {"Zenaga", "zen", ""},
- {"Zhuang; Chuang", "zha", "za"},
- {"Zulu", "zul", "zu", MAKELCID(MAKELANGID(LANG_ZULU, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Zuni", "zun", ""},
- {"Classical Newari", "nwc", ""},
- {"Klingon", "tlh", ""},
- {"Blin", "byn", ""},
- {"Lojban", "jbo", ""},
- {"Lower Sorbian", "dsb", ""},
- {"Upper Sorbian", "hsb", ""},
- {"Kashubian", "csb", ""},
- {"Crimean Turkish", "crh", ""},
- {"Erzya", "myv", ""},
- {"Moksha", "mdf", ""},
- {"Karachay-Balkar", "krc", ""},
- {"Adyghe", "ady", ""},
- {"Udmurt", "udm", ""},
- {"Dargwa", "dar", ""},
- {"Ingush", "inh", ""},
- {"Nogai", "nog", ""},
- {"Haitian", "hat", "ht"},
- {"Kalmyk", "xal", ""},
- {"", "", ""},
- {"No subtitles", "---", "", LCID_NOSUBTITLES},
+ CStringA str;
+ int n = WideCharToMultiByte(CP_UTF8, 0, utf16, -1, NULL, 0, NULL, NULL)-1;
+ if(n < 0) return str;
+ str.ReleaseBuffer(WideCharToMultiByte(CP_UTF8, 0, utf16, -1, str.GetBuffer(n), n+1, NULL, NULL)-1);
+ return str;
+}
+
+static struct {LPCSTR name, iso6392, iso6391; LCID lcid;} s_isolangs[] = // TODO : fill LCID !!!
+{
+ {"Abkhazian", "abk", "ab"},
+ {"Achinese", "ace", ""},
+ {"Acoli", "ach", ""},
+ {"Adangme", "ada", ""},
+ {"Afar", "aar", "aa"},
+ {"Afrihili", "afh", ""},
+ {"Afrikaans", "afr", "af", MAKELCID( MAKELANGID(LANG_AFRIKAANS, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Afro-Asiatic (Other)", "afa", ""},
+ {"Akan", "aka", "ak"},
+ {"Akkadian", "akk", ""},
+ {"Albanian", "alb", "sq"},
+ {"Albanian", "sqi", "sq", MAKELCID( MAKELANGID(LANG_ALBANIAN, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Aleut", "ale", ""},
+ {"Algonquian languages", "alg", ""},
+ {"Altaic (Other)", "tut", ""},
+ {"Amharic", "amh", "am"},
+ {"Apache languages", "apa", ""},
+ {"Arabic", "ara", "ar", MAKELCID( MAKELANGID(LANG_ARABIC, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Aragonese", "arg", "an"},
+ {"Aramaic", "arc", ""},
+ {"Arapaho", "arp", ""},
+ {"Araucanian", "arn", ""},
+ {"Arawak", "arw", ""},
+ {"Armenian", "arm", "hy", MAKELCID( MAKELANGID(LANG_ARMENIAN, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Armenian", "hye", "hy", MAKELCID( MAKELANGID(LANG_ARMENIAN, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Artificial (Other)", "art", ""},
+ {"Assamese", "asm", "as", MAKELCID( MAKELANGID(LANG_ASSAMESE, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Asturian; Bable", "ast", ""},
+ {"Athapascan languages", "ath", ""},
+ {"Australian languages", "aus", ""},
+ {"Austronesian (Other)", "map", ""},
+ {"Avaric", "ava", "av"},
+ {"Avestan", "ave", "ae"},
+ {"Awadhi", "awa", ""},
+ {"Aymara", "aym", "ay"},
+ {"Azerbaijani", "aze", "az", MAKELCID( MAKELANGID(LANG_AZERI, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Bable; Asturian", "ast", ""},
+ {"Balinese", "ban", ""},
+ {"Baltic (Other)", "bat", ""},
+ {"Baluchi", "bal", ""},
+ {"Bambara", "bam", "bm"},
+ {"Bamileke languages", "bai", ""},
+ {"Banda", "bad", ""},
+ {"Bantu (Other)", "bnt", ""},
+ {"Basa", "bas", ""},
+ {"Bashkir", "bak", "ba", MAKELCID( MAKELANGID(LANG_BASHKIR, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Basque", "baq", "eu", MAKELCID( MAKELANGID(LANG_BASQUE, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Basque", "eus", "eu", MAKELCID( MAKELANGID(LANG_BASQUE, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Batak (Indonesia)", "btk", ""},
+ {"Beja", "bej", ""},
+ {"Belarusian", "bel", "be", MAKELCID( MAKELANGID(LANG_BELARUSIAN, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Bemba", "bem", ""},
+ {"Bengali", "ben", "bn", MAKELCID( MAKELANGID(LANG_BENGALI, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Berber (Other)", "ber", ""},
+ {"Bhojpuri", "bho", ""},
+ {"Bihari", "bih", "bh"},
+ {"Bikol", "bik", ""},
+ {"Bini", "bin", ""},
+ {"Bislama", "bis", "bi"},
+ {"Bokmål, Norwegian; Norwegian Bokmål", "nob", "nb"},
+ {"Bosnian", "bos", "bs"},
+ {"Braj", "bra", ""},
+ {"Breton", "bre", "br", MAKELCID( MAKELANGID(LANG_BRETON, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Buginese", "bug", ""},
+ {"Bulgarian", "bul", "bg", MAKELCID( MAKELANGID(LANG_BULGARIAN, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Buriat", "bua", ""},
+ {"Burmese", "bur", "my"},
+ {"Burmese", "mya", "my"},
+ {"Caddo", "cad", ""},
+ {"Carib", "car", ""},
+ {"Spanish; Castilian", "spa", "es", MAKELCID( MAKELANGID(LANG_SPANISH, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Catalan", "cat", "ca", MAKELCID( MAKELANGID(LANG_CATALAN, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Caucasian (Other)", "cau", ""},
+ {"Cebuano", "ceb", ""},
+ {"Celtic (Other)", "cel", ""},
+ {"Central American Indian (Other)", "cai", ""},
+ {"Chagatai", "chg", ""},
+ {"Chamic languages", "cmc", ""},
+ {"Chamorro", "cha", "ch"},
+ {"Chechen", "che", "ce"},
+ {"Cherokee", "chr", ""},
+ {"Chewa; Chichewa; Nyanja", "nya", "ny"},
+ {"Cheyenne", "chy", ""},
+ {"Chibcha", "chb", ""},
+ {"Chichewa; Chewa; Nyanja", "nya", "ny"},
+ {"Chinese", "chi", "zh", MAKELCID( MAKELANGID(LANG_CHINESE, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Chinese", "zho", "zh"},
+ {"Chinook jargon", "chn", ""},
+ {"Chipewyan", "chp", ""},
+ {"Choctaw", "cho", ""},
+ {"Chuang; Zhuang", "zha", "za"},
+ {"Church Slavic; Old Church Slavonic", "chu", "cu"},
+ {"Old Church Slavonic; Old Slavonic; ", "chu", "cu"},
+ {"Church Slavonic; Old Bulgarian; Church Slavic;", "chu", "cu"},
+ {"Old Slavonic; Church Slavonic; Old Bulgarian;", "chu", "cu"},
+ {"Church Slavic; Old Church Slavonic", "chu", "cu"},
+ {"Chuukese", "chk", ""},
+ {"Chuvash", "chv", "cv"},
+ {"Coptic", "cop", ""},
+ {"Cornish", "cor", "kw"},
+ {"Corsican", "cos", "co", MAKELCID( MAKELANGID(LANG_CORSICAN, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Cree", "cre", "cr"},
+ {"Creek", "mus", ""},
+ {"Creoles and pidgins (Other)", "crp", ""},
+ {"Creoles and pidgins,", "cpe", ""},
+ // {"English-based (Other)", "", ""},
+ {"Creoles and pidgins,", "cpf", ""},
+ // {"French-based (Other)", "", ""},
+ {"Creoles and pidgins,", "cpp", ""},
+ // {"Portuguese-based (Other)", "", ""},
+ {"Croatian", "scr", "hr", MAKELCID( MAKELANGID(LANG_CROATIAN, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Croatian", "hrv", "hr", MAKELCID( MAKELANGID(LANG_CROATIAN, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Cushitic (Other)", "cus", ""},
+ {"Czech", "cze", "cs", MAKELCID( MAKELANGID(LANG_CZECH, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Czech", "ces", "cs", MAKELCID( MAKELANGID(LANG_CZECH, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Dakota", "dak", ""},
+ {"Danish", "dan", "da", MAKELCID( MAKELANGID(LANG_DANISH, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Dargwa", "dar", ""},
+ {"Dayak", "day", ""},
+ {"Delaware", "del", ""},
+ {"Dinka", "din", ""},
+ {"Divehi", "div", "dv", MAKELCID( MAKELANGID(LANG_DIVEHI, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Dogri", "doi", ""},
+ {"Dogrib", "dgr", ""},
+ {"Dravidian (Other)", "dra", ""},
+ {"Duala", "dua", ""},
+ {"Dutch; Flemish", "dut", "nl", MAKELCID( MAKELANGID(LANG_DUTCH, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Dutch; Flemish", "nld", "nl", MAKELCID( MAKELANGID(LANG_DUTCH, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Dutch, Middle (ca. 1050-1350)", "dum", ""},
+ {"Dyula", "dyu", ""},
+ {"Dzongkha", "dzo", "dz"},
+ {"Efik", "efi", ""},
+ {"Egyptian (Ancient)", "egy", ""},
+ {"Ekajuk", "eka", ""},
+ {"Elamite", "elx", ""},
+ {"English", "eng", "en", MAKELCID( MAKELANGID(LANG_ENGLISH, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"English, Middle (1100-1500)", "enm", ""},
+ {"English, Old (ca.450-1100)", "ang", ""},
+ {"Esperanto", "epo", "eo"},
+ {"Estonian", "est", "et", MAKELCID( MAKELANGID(LANG_ESTONIAN, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Ewe", "ewe", "ee"},
+ {"Ewondo", "ewo", ""},
+ {"Fang", "fan", ""},
+ {"Fanti", "fat", ""},
+ {"Faroese", "fao", "fo", MAKELCID( MAKELANGID(LANG_FAEROESE, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Fijian", "fij", "fj"},
+ {"Finnish", "fin", "fi", MAKELCID( MAKELANGID(LANG_FINNISH, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Finno-Ugrian (Other)", "fiu", ""},
+ {"Flemish; Dutch", "dut", "nl"},
+ {"Flemish; Dutch", "nld", "nl"},
+ {"Fon", "fon", ""},
+ {"French", "fre", "fr", MAKELCID( MAKELANGID(LANG_FRENCH, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"French", "fra*", "fr", MAKELCID( MAKELANGID(LANG_FRENCH, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"French", "fra", "fr", MAKELCID( MAKELANGID(LANG_FRENCH, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"French, Middle (ca.1400-1600)", "frm", ""},
+ {"French, Old (842-ca.1400)", "fro", ""},
+ {"Frisian", "fry", "fy", MAKELCID( MAKELANGID(LANG_FRISIAN, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Friulian", "fur", ""},
+ {"Fulah", "ful", "ff"},
+ {"Ga", "gaa", ""},
+ {"Gaelic; Scottish Gaelic", "gla", "gd", MAKELCID( MAKELANGID(LANG_GALICIAN, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Gallegan", "glg", "gl"},
+ {"Ganda", "lug", "lg"},
+ {"Gayo", "gay", ""},
+ {"Gbaya", "gba", ""},
+ {"Geez", "gez", ""},
+ {"Georgian", "geo", "ka", MAKELCID( MAKELANGID(LANG_GEORGIAN, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Georgian", "kat", "ka", MAKELCID( MAKELANGID(LANG_GEORGIAN, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"German", "ger", "de", MAKELCID( MAKELANGID(LANG_GERMAN, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"German", "deu", "de", MAKELCID( MAKELANGID(LANG_GERMAN, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"German, Low; Saxon, Low; Low German; Low Saxon", "nds", ""},
+ {"German, Middle High (ca.1050-1500)", "gmh", ""},
+ {"German, Old High (ca.750-1050)", "goh", ""},
+ {"Germanic (Other)", "gem", ""},
+ {"Gikuyu; Kikuyu", "kik", "ki"},
+ {"Gilbertese", "gil", ""},
+ {"Gondi", "gon", ""},
+ {"Gorontalo", "gor", ""},
+ {"Gothic", "got", ""},
+ {"Grebo", "grb", ""},
+ {"Greek, Ancient (to 1453)", "grc", "", MAKELCID( MAKELANGID(LANG_GREEK, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Greek, Modern (1453-)", "gre", "el", MAKELCID( MAKELANGID(LANG_GREEK, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Greek, Modern (1453-)", "ell", "el", MAKELCID( MAKELANGID(LANG_GREEK, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Greenlandic; Kalaallisut", "kal", "kl", MAKELCID( MAKELANGID(LANG_GREENLANDIC, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Guarani", "grn", "gn"},
+ {"Gujarati", "guj", "gu", MAKELCID( MAKELANGID(LANG_GUJARATI, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Gwich´in", "gwi", ""},
+ {"Haida", "hai", ""},
+ {"Hausa", "hau", "ha", MAKELCID( MAKELANGID(LANG_HAUSA, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Hawaiian", "haw", ""},
+ {"Hebrew", "heb", "he", MAKELCID( MAKELANGID(LANG_HEBREW, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Herero", "her", "hz"},
+ {"Hiligaynon", "hil", ""},
+ {"Himachali", "him", ""},
+ {"Hindi", "hin", "hi", MAKELCID( MAKELANGID(LANG_HINDI, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Hiri Motu", "hmo", "ho"},
+ {"Hittite", "hit", ""},
+ {"Hmong", "hmn", ""},
+ {"Hungarian", "hun", "hu", MAKELCID( MAKELANGID(LANG_HUNGARIAN, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Hupa", "hup", ""},
+ {"Iban", "iba", ""},
+ {"Icelandic", "ice", "is", MAKELCID( MAKELANGID(LANG_ICELANDIC, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Icelandic", "isl", "is", MAKELCID( MAKELANGID(LANG_ICELANDIC, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Ido", "ido", "io"},
+ {"Igbo", "ibo", "ig", MAKELCID( MAKELANGID(LANG_IGBO, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Ijo", "ijo", ""},
+ {"Iloko", "ilo", ""},
+ {"Inari Sami", "smn", ""},
+ {"Indic (Other)", "inc", ""},
+ {"Indo-European (Other)", "ine", ""},
+ {"Indonesian", "ind", "id", MAKELCID( MAKELANGID(LANG_INDONESIAN, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Ingush", "inh", ""},
+ {"Interlingua (International", "ina", "ia"},
+ // {"Auxiliary Language Association)", "", ""},
+ {"Interlingue", "ile", "ie"},
+ {"Inuktitut", "iku", "iu", MAKELCID( MAKELANGID(LANG_INUKTITUT, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Inupiaq", "ipk", "ik"},
+ {"Iranian (Other)", "ira", ""},
+ {"Irish", "gle", "ga", MAKELCID( MAKELANGID(LANG_IRISH, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Irish, Middle (900-1200)", "mga", "", MAKELCID( MAKELANGID(LANG_IRISH, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Irish, Old (to 900)", "sga", "", MAKELCID( MAKELANGID(LANG_IRISH, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Iroquoian languages", "iro", ""},
+ {"Italian", "ita", "it", MAKELCID( MAKELANGID(LANG_ITALIAN, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Japanese", "jpn", "ja", MAKELCID( MAKELANGID(LANG_JAPANESE, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Javanese", "jav", "jv"},
+ {"Judeo-Arabic", "jrb", ""},
+ {"Judeo-Persian", "jpr", ""},
+ {"Kabardian", "kbd", ""},
+ {"Kabyle", "kab", ""},
+ {"Kachin", "kac", ""},
+ {"Kalaallisut; Greenlandic", "kal", "kl"},
+ {"Kamba", "kam", ""},
+ {"Kannada", "kan", "kn", MAKELCID( MAKELANGID(LANG_KANNADA, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Kanuri", "kau", "kr"},
+ {"Kara-Kalpak", "kaa", ""},
+ {"Karen", "kar", ""},
+ {"Kashmiri", "kas", "ks", MAKELCID( MAKELANGID(LANG_KASHMIRI, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Kawi", "kaw", ""},
+ {"Kazakh", "kaz", "kk", MAKELCID( MAKELANGID(LANG_KAZAK, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Khasi", "kha", ""},
+ {"Khmer", "khm", "km", MAKELCID( MAKELANGID(LANG_KHMER, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Khoisan (Other)", "khi", ""},
+ {"Khotanese", "kho", ""},
+ {"Kikuyu; Gikuyu", "kik", "ki"},
+ {"Kimbundu", "kmb", ""},
+ {"Kinyarwanda", "kin", "rw", MAKELCID( MAKELANGID(LANG_KINYARWANDA, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Kirghiz", "kir", "ky"},
+ {"Komi", "kom", "kv"},
+ {"Kongo", "kon", "kg"},
+ {"Konkani", "kok", "", MAKELCID( MAKELANGID(LANG_KONKANI, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Korean", "kor", "ko", MAKELCID( MAKELANGID(LANG_KOREAN, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Kosraean", "kos", ""},
+ {"Kpelle", "kpe", ""},
+ {"Kru", "kro", ""},
+ {"Kuanyama; Kwanyama", "kua", "kj"},
+ {"Kumyk", "kum", ""},
+ {"Kurdish", "kur", "ku"},
+ {"Kurukh", "kru", ""},
+ {"Kutenai", "kut", ""},
+ {"Kwanyama, Kuanyama", "kua", "kj"},
+ {"Ladino", "lad", ""},
+ {"Lahnda", "lah", ""},
+ {"Lamba", "lam", ""},
+ {"Lao", "lao", "lo", MAKELCID( MAKELANGID(LANG_LAO, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Latin", "lat", "la"},
+ {"Latvian", "lav", "lv", MAKELCID( MAKELANGID(LANG_LATVIAN, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Letzeburgesch; Luxembourgish", "ltz", "lb"},
+ {"Lezghian", "lez", ""},
+ {"Limburgan; Limburger; Limburgish", "lim", "li"},
+ {"Limburger; Limburgan; Limburgish;", "lim", "li"},
+ {"Limburgish; Limburger; Limburgan", "lim", "li"},
+ {"Lingala", "lin", "ln"},
+ {"Lithuanian", "lit", "lt", MAKELCID( MAKELANGID(LANG_LITHUANIAN, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Low German; Low Saxon; German, Low; Saxon, Low", "nds", ""},
+ {"Low Saxon; Low German; Saxon, Low; German, Low", "nds", ""},
+ {"Lozi", "loz", ""},
+ {"Luba-Katanga", "lub", "lu"},
+ {"Luba-Lulua", "lua", ""},
+ {"Luiseno", "lui", ""},
+ {"Lule Sami", "smj", ""},
+ {"Lunda", "lun", ""},
+ {"Luo (Kenya and Tanzania)", "luo", ""},
+ {"Lushai", "lus", ""},
+ {"Luxembourgish; Letzeburgesch", "ltz", "lb", MAKELCID( MAKELANGID(LANG_LUXEMBOURGISH, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Macedonian", "mac", "mk", MAKELCID( MAKELANGID(LANG_MACEDONIAN, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Macedonian", "mkd", "mk", MAKELCID( MAKELANGID(LANG_MACEDONIAN, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Madurese", "mad", ""},
+ {"Magahi", "mag", ""},
+ {"Maithili", "mai", ""},
+ {"Makasar", "mak", ""},
+ {"Malagasy", "mlg", "mg"},
+ {"Malay", "may", "ms", MAKELCID( MAKELANGID(LANG_MALAY, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Malay", "msa", "ms", MAKELCID( MAKELANGID(LANG_MALAY, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Malayalam", "mal", "ml", MAKELCID( MAKELANGID(LANG_MALAYALAM, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Maltese", "mlt", "mt", MAKELCID( MAKELANGID(LANG_MALTESE, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Manchu", "mnc", ""},
+ {"Mandar", "mdr", ""},
+ {"Mandingo", "man", ""},
+ {"Manipuri", "mni", "", MAKELCID( MAKELANGID(LANG_MANIPURI, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Manobo languages", "mno", ""},
+ {"Manx", "glv", "gv"},
+ {"Maori", "mao", "mi", MAKELCID( MAKELANGID(LANG_MAORI, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Maori", "mri", "mi", MAKELCID( MAKELANGID(LANG_MAORI, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Marathi", "mar", "mr", MAKELCID( MAKELANGID(LANG_MARATHI, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Mari", "chm", ""},
+ {"Marshallese", "mah", "mh"},
+ {"Marwari", "mwr", ""},
+ {"Masai", "mas", ""},
+ {"Mayan languages", "myn", ""},
+ {"Mende", "men", ""},
+ {"Micmac", "mic", ""},
+ {"Minangkabau", "min", ""},
+ {"Miscellaneous languages", "mis", ""},
+ {"Mohawk", "moh", "", MAKELCID( MAKELANGID(LANG_MOHAWK, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Moldavian", "mol", "mo"},
+ {"Mon-Khmer (Other)", "mkh", ""},
+ {"Mongo", "lol", ""},
+ {"Mongolian", "mon", "mn", MAKELCID( MAKELANGID(LANG_MONGOLIAN, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Mossi", "mos", ""},
+ {"Multiple languages", "mul", ""},
+ {"Munda languages", "mun", ""},
+ {"Nahuatl", "nah", ""},
+ {"Nauru", "nau", "na"},
+ {"Navaho, Navajo", "nav", "nv"},
+ {"Navajo; Navaho", "nav", "nv"},
+ {"Ndebele, North", "nde", "nd"},
+ {"Ndebele, South", "nbl", "nr"},
+ {"Ndonga", "ndo", "ng"},
+ {"Neapolitan", "nap", ""},
+ {"Nepali", "nep", "ne", MAKELCID( MAKELANGID(LANG_NEPALI, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Newari", "new", ""},
+ {"Nias", "nia", ""},
+ {"Niger-Kordofanian (Other)", "nic", ""},
+ {"Nilo-Saharan (Other)", "ssa", ""},
+ {"Niuean", "niu", ""},
+ {"Norse, Old", "non", ""},
+ {"North American Indian (Other)", "nai", ""},
+ {"Northern Sami", "sme", "se"},
+ {"North Ndebele", "nde", "nd"},
+ {"Norwegian", "nor", "no", MAKELCID( MAKELANGID(LANG_NORWEGIAN, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Norwegian Bokmål; Bokmål, Norwegian", "nob", "nb", MAKELCID( MAKELANGID(LANG_NORWEGIAN, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Norwegian Nynorsk; Nynorsk, Norwegian", "nno", "nn", MAKELCID( MAKELANGID(LANG_NORWEGIAN, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Nubian languages", "nub", ""},
+ {"Nyamwezi", "nym", ""},
+ {"Nyanja; Chichewa; Chewa", "nya", "ny"},
+ {"Nyankole", "nyn", ""},
+ {"Nynorsk, Norwegian; Norwegian Nynorsk", "nno", "nn"},
+ {"Nyoro", "nyo", ""},
+ {"Nzima", "nzi", ""},
+ {"Occitan (post 1500},; Provençal", "oci", "oc", MAKELCID( MAKELANGID(LANG_OCCITAN, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Ojibwa", "oji", "oj"},
+ {"Old Bulgarian; Old Slavonic; Church Slavonic;", "chu", "cu"},
+ {"Oriya", "ori", "or"},
+ {"Oromo", "orm", "om"},
+ {"Osage", "osa", ""},
+ {"Ossetian; Ossetic", "oss", "os"},
+ {"Ossetic; Ossetian", "oss", "os"},
+ {"Otomian languages", "oto", ""},
+ {"Pahlavi", "pal", ""},
+ {"Palauan", "pau", ""},
+ {"Pali", "pli", "pi"},
+ {"Pampanga", "pam", ""},
+ {"Pangasinan", "pag", ""},
+ {"Panjabi", "pan", "pa"},
+ {"Papiamento", "pap", ""},
+ {"Papuan (Other)", "paa", ""},
+ {"Persian", "per", "fa", MAKELCID( MAKELANGID(LANG_PERSIAN, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Persian", "fas", "fa", MAKELCID( MAKELANGID(LANG_PERSIAN, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Persian, Old (ca.600-400 B.C.)", "peo", ""},
+ {"Philippine (Other)", "phi", ""},
+ {"Phoenician", "phn", ""},
+ {"Pohnpeian", "pon", ""},
+ {"Polish", "pol", "pl", MAKELCID( MAKELANGID(LANG_POLISH, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Portuguese", "por", "pt", MAKELCID( MAKELANGID(LANG_PORTUGUESE, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Prakrit languages", "pra", ""},
+ {"Provençal; Occitan (post 1500)", "oci", "oc"},
+ {"Provençal, Old (to 1500)", "pro", ""},
+ {"Pushto", "pus", "ps"},
+ {"Quechua", "que", "qu", MAKELCID( MAKELANGID(LANG_QUECHUA, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Raeto-Romance", "roh", "rm"},
+ {"Rajasthani", "raj", ""},
+ {"Rapanui", "rap", ""},
+ {"Rarotongan", "rar", ""},
+ {"Reserved for local use", "qaa-qtz", ""},
+ {"Romance (Other)", "roa", ""},
+ {"Romanian", "rum", "ro", MAKELCID( MAKELANGID(LANG_ROMANIAN, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Romanian", "ron", "ro", MAKELCID( MAKELANGID(LANG_ROMANIAN, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Romany", "rom", ""},
+ {"Rundi", "run", "rn"},
+ {"Russian", "rus", "ru", MAKELCID( MAKELANGID(LANG_RUSSIAN, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Salishan languages", "sal", ""},
+ {"Samaritan Aramaic", "sam", ""},
+ {"Sami languages (Other)", "smi", ""},
+ {"Samoan", "smo", "sm"},
+ {"Sandawe", "sad", ""},
+ {"Sango", "sag", "sg"},
+ {"Sanskrit", "san", "sa", MAKELCID( MAKELANGID(LANG_SANSKRIT, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Santali", "sat", ""},
+ {"Sardinian", "srd", "sc"},
+ {"Sasak", "sas", ""},
+ {"Saxon, Low; German, Low; Low Saxon; Low German", "nds", ""},
+ {"Scots", "sco", ""},
+ {"Scottish Gaelic; Gaelic", "gla", "gd"},
+ {"Selkup", "sel", ""},
+ {"Semitic (Other)", "sem", ""},
+ {"Serbian", "scc", "sr", MAKELCID( MAKELANGID(LANG_SERBIAN, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Serbian", "srp", "sr", MAKELCID( MAKELANGID(LANG_SERBIAN, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Serer", "srr", ""},
+ {"Shan", "shn", ""},
+ {"Shona", "sna", "sn"},
+ {"Sichuan Yi", "iii", "ii"},
+ {"Sidamo", "sid", ""},
+ {"Sign languages", "sgn", ""},
+ {"Siksika", "bla", ""},
+ {"Sindhi", "snd", "sd", MAKELCID( MAKELANGID(LANG_SINDHI, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Sinhalese", "sin", "si", MAKELCID( MAKELANGID(LANG_SINHALESE, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Sino-Tibetan (Other)", "sit", ""},
+ {"Siouan languages", "sio", ""},
+ {"Skolt Sami", "sms", ""},
+ {"Slave (Athapascan)", "den", ""},
+ {"Slavic (Other)", "sla", ""},
+ {"Slovak", "slo", "sk", MAKELCID( MAKELANGID(LANG_SLOVAK, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Slovak", "slk", "sk", MAKELCID( MAKELANGID(LANG_SLOVAK, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Slovenian", "slv", "sl", MAKELCID( MAKELANGID(LANG_SLOVENIAN, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Sogdian", "sog", ""},
+ {"Somali", "som", "so"},
+ {"Songhai", "son", ""},
+ {"Soninke", "snk", ""},
+ {"Sorbian languages", "wen", ""},
+ {"Sotho, Northern", "nso", "", MAKELCID( MAKELANGID(LANG_SOTHO, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Sotho, Southern", "sot", "st", MAKELCID( MAKELANGID(LANG_SOTHO, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"South American Indian (Other)", "sai", ""},
+ {"Southern Sami", "sma", ""},
+ {"South Ndebele", "nbl", "nr"},
+ {"Spanish; Castilian", "spa", "es", MAKELCID( MAKELANGID(LANG_SPANISH, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Sukuma", "suk", ""},
+ {"Sumerian", "sux", ""},
+ {"Sundanese", "sun", "su"},
+ {"Susu", "sus", ""},
+ {"Swahili", "swa", "sw", MAKELCID( MAKELANGID(LANG_SWAHILI, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Swati", "ssw", "ss"},
+ {"Swedish", "swe", "sv", MAKELCID( MAKELANGID(LANG_SWEDISH, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Syriac", "syr", "", MAKELCID( MAKELANGID(LANG_SYRIAC, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Tagalog", "tgl", "tl"},
+ {"Tahitian", "tah", "ty"},
+ {"Tai (Other)", "tai", ""},
+ {"Tajik", "tgk", "tg", MAKELCID( MAKELANGID(LANG_TAJIK, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Tamashek", "tmh", ""},
+ {"Tamil", "tam", "ta", MAKELCID( MAKELANGID(LANG_TAMIL, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Tatar", "tat", "tt", MAKELCID( MAKELANGID(LANG_TATAR, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Telugu", "tel", "te", MAKELCID( MAKELANGID(LANG_TELUGU, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Tereno", "ter", ""},
+ {"Tetum", "tet", ""},
+ {"Thai", "tha", "th", MAKELCID( MAKELANGID(LANG_THAI, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Tibetan", "tib", "bo", MAKELCID( MAKELANGID(LANG_TIBETAN, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Tibetan", "bod", "bo", MAKELCID( MAKELANGID(LANG_TIBETAN, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Tigre", "tig", ""},
+ {"Tigrinya", "tir", "ti", MAKELCID( MAKELANGID(LANG_TIGRIGNA, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Timne", "tem", ""},
+ {"Tiv", "tiv", ""},
+ {"Tlingit", "tli", ""},
+ {"Tok Pisin", "tpi", ""},
+ {"Tokelau", "tkl", ""},
+ {"Tonga (Nyasa)", "tog", ""},
+ {"Tonga (Tonga Islands)", "ton", "to"},
+ {"Tsimshian", "tsi", ""},
+ {"Tsonga", "tso", "ts"},
+ {"Tswana", "tsn", "tn", MAKELCID( MAKELANGID(LANG_TSWANA, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Tumbuka", "tum", ""},
+ {"Tupi languages", "tup", ""},
+ {"Turkish", "tur", "tr", MAKELCID( MAKELANGID(LANG_TURKISH, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Turkish, Ottoman (1500-1928)", "ota", "", MAKELCID( MAKELANGID(LANG_TURKISH, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Turkmen", "tuk", "tk", MAKELCID( MAKELANGID(LANG_TURKMEN, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Tuvalu", "tvl", ""},
+ {"Tuvinian", "tyv", ""},
+ {"Twi", "twi", "tw"},
+ {"Ugaritic", "uga", ""},
+ {"Uighur", "uig", "ug", MAKELCID( MAKELANGID(LANG_UIGHUR, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Ukrainian", "ukr", "uk", MAKELCID( MAKELANGID(LANG_UKRAINIAN, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Umbundu", "umb", ""},
+ {"Undetermined", "und", ""},
+ {"Urdu", "urd", "ur", MAKELCID( MAKELANGID(LANG_URDU, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Uzbek", "uzb", "uz", MAKELCID( MAKELANGID(LANG_UZBEK, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Vai", "vai", ""},
+ {"Venda", "ven", "ve"},
+ {"Vietnamese", "vie", "vi", MAKELCID( MAKELANGID(LANG_VIETNAMESE, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Volapük", "vol", "vo"},
+ {"Votic", "vot", ""},
+ {"Wakashan languages", "wak", ""},
+ {"Walamo", "wal", ""},
+ {"Walloon", "wln", "wa"},
+ {"Waray", "war", ""},
+ {"Washo", "was", ""},
+ {"Welsh", "wel", "cy", MAKELCID( MAKELANGID(LANG_WELSH, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Welsh", "cym", "cy", MAKELCID( MAKELANGID(LANG_WELSH, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Wolof", "wol", "wo", MAKELCID( MAKELANGID(LANG_WOLOF, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Xhosa", "xho", "xh", MAKELCID( MAKELANGID(LANG_XHOSA, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Yakut", "sah", "", MAKELCID( MAKELANGID(LANG_YAKUT, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Yao", "yao", ""},
+ {"Yapese", "yap", ""},
+ {"Yiddish", "yid", "yi"},
+ {"Yoruba", "yor", "yo", MAKELCID( MAKELANGID(LANG_YORUBA, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Yupik languages", "ypk", ""},
+ {"Zande", "znd", ""},
+ {"Zapotec", "zap", ""},
+ {"Zenaga", "zen", ""},
+ {"Zhuang; Chuang", "zha", "za"},
+ {"Zulu", "zul", "zu", MAKELCID( MAKELANGID(LANG_ZULU, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Zuni", "zun", ""},
+ {"Classical Newari", "nwc", ""},
+ {"Klingon", "tlh", ""},
+ {"Blin", "byn", ""},
+ {"Lojban", "jbo", ""},
+ {"Lower Sorbian", "dsb", ""},
+ {"Upper Sorbian", "hsb", ""},
+ {"Kashubian", "csb", ""},
+ {"Crimean Turkish", "crh", ""},
+ {"Erzya", "myv", ""},
+ {"Moksha", "mdf", ""},
+ {"Karachay-Balkar", "krc", ""},
+ {"Adyghe", "ady", ""},
+ {"Udmurt", "udm", ""},
+ {"Dargwa", "dar", ""},
+ {"Ingush", "inh", ""},
+ {"Nogai", "nog", ""},
+ {"Haitian", "hat", "ht"},
+ {"Kalmyk", "xal", ""},
+ {"", "", ""},
+ {"No subtitles", "---", "", LCID_NOSUBTITLES},
};
CString ISO6391ToLanguage(LPCSTR code)
{
- CHAR tmp[2+1];
- strncpy_s(tmp, code, 2);
- tmp[2] = 0;
- _strlwr_s(tmp);
- for(ptrdiff_t i = 0, j = countof(s_isolangs); i < j; i++)
- if(!strcmp(s_isolangs[i].iso6391, tmp))
- {
- CString ret = CString(CStringA(s_isolangs[i].name));
- int i = ret.Find(';');
- if(i > 0) ret = ret.Left(i);
- return ret;
- }
- return(_T(""));
+ CHAR tmp[2+1];
+ strncpy_s(tmp, code, 2);
+ tmp[2] = 0;
+ _strlwr_s(tmp);
+ for(ptrdiff_t i = 0, j = countof(s_isolangs); i < j; i++)
+ if(!strcmp(s_isolangs[i].iso6391, tmp))
+ {
+ CString ret = CString(CStringA(s_isolangs[i].name));
+ int i = ret.Find(';');
+ if(i > 0) ret = ret.Left(i);
+ return ret;
+ }
+ return(_T(""));
}
CString ISO6392ToLanguage(LPCSTR code)
{
- CHAR tmp[3+1];
- strncpy_s(tmp, code, 3);
- tmp[3] = 0;
- _strlwr_s(tmp);
- for(ptrdiff_t i = 0, j = countof(s_isolangs); i < j; i++)
- {
- if(!strcmp(s_isolangs[i].iso6392, tmp))
- {
- CString ret = CString(CStringA(s_isolangs[i].name));
- int i = ret.Find(';');
- if(i > 0) ret = ret.Left(i);
- return ret;
- }
- }
- return _T("");
+ CHAR tmp[3+1];
+ strncpy_s(tmp, code, 3);
+ tmp[3] = 0;
+ _strlwr_s(tmp);
+ for(ptrdiff_t i = 0, j = countof(s_isolangs); i < j; i++)
+ {
+ if(!strcmp(s_isolangs[i].iso6392, tmp))
+ {
+ CString ret = CString(CStringA(s_isolangs[i].name));
+ int i = ret.Find(';');
+ if(i > 0) ret = ret.Left(i);
+ return ret;
+ }
+ }
+ return _T("");
}
LCID ISO6391ToLcid(LPCSTR code)
{
- CHAR tmp[3+1];
- strncpy_s(tmp, code, 3);
- tmp[3] = 0;
- _strlwr_s(tmp);
- for(ptrdiff_t i = 0, j = countof(s_isolangs); i < j; i++)
- {
- if(!strcmp(s_isolangs[i].iso6391, code))
- {
- return s_isolangs[i].lcid;
- }
- }
- return 0;
+ CHAR tmp[3+1];
+ strncpy_s(tmp, code, 3);
+ tmp[3] = 0;
+ _strlwr_s(tmp);
+ for(ptrdiff_t i = 0, j = countof(s_isolangs); i < j; i++)
+ {
+ if(!strcmp(s_isolangs[i].iso6391, code))
+ {
+ return s_isolangs[i].lcid;
+ }
+ }
+ return 0;
}
LCID ISO6392ToLcid(LPCSTR code)
{
- CHAR tmp[3+1];
- strncpy_s(tmp, code, 3);
- tmp[3] = 0;
- _strlwr_s(tmp);
- for(ptrdiff_t i = 0, j = countof(s_isolangs); i < j; i++)
- {
- if(!strcmp(s_isolangs[i].iso6392, tmp))
- {
- return s_isolangs[i].lcid;
- }
- }
- return 0;
+ CHAR tmp[3+1];
+ strncpy_s(tmp, code, 3);
+ tmp[3] = 0;
+ _strlwr_s(tmp);
+ for(ptrdiff_t i = 0, j = countof(s_isolangs); i < j; i++)
+ {
+ if(!strcmp(s_isolangs[i].iso6392, tmp))
+ {
+ return s_isolangs[i].lcid;
+ }
+ }
+ return 0;
}
CString ISO6391To6392(LPCSTR code)
{
- CHAR tmp[2+1];
- strncpy_s(tmp, code, 2);
- tmp[2] = 0;
- _strlwr_s(tmp);
- for(ptrdiff_t i = 0, j = countof(s_isolangs); i < j; i++)
- if(!strcmp(s_isolangs[i].iso6391, tmp))
- return CString(CStringA(s_isolangs[i].iso6392));
- return _T("");
+ CHAR tmp[2+1];
+ strncpy_s(tmp, code, 2);
+ tmp[2] = 0;
+ _strlwr_s(tmp);
+ for(ptrdiff_t i = 0, j = countof(s_isolangs); i < j; i++)
+ if(!strcmp(s_isolangs[i].iso6391, tmp))
+ return CString(CStringA(s_isolangs[i].iso6392));
+ return _T("");
}
CString ISO6392To6391(LPCSTR code)
{
- CHAR tmp[3+1];
- strncpy_s(tmp, code, 3);
- tmp[3] = 0;
- _strlwr_s(tmp);
- for(ptrdiff_t i = 0, j = countof(s_isolangs); i < j; i++)
- if(!strcmp(s_isolangs[i].iso6392, tmp))
- return CString(CStringA(s_isolangs[i].iso6391));
- return _T("");
+ CHAR tmp[3+1];
+ strncpy_s(tmp, code, 3);
+ tmp[3] = 0;
+ _strlwr_s(tmp);
+ for(ptrdiff_t i = 0, j = countof(s_isolangs); i < j; i++)
+ if(!strcmp(s_isolangs[i].iso6392, tmp))
+ return CString(CStringA(s_isolangs[i].iso6391));
+ return _T("");
}
CString LanguageToISO6392(LPCTSTR lang)
{
- CString str = lang;
- str.MakeLower();
- for(ptrdiff_t i = 0, j = countof(s_isolangs); i < j; i++)
- {
- CAtlList<CString> sl;
- Explode(CString(s_isolangs[i].name), sl, ';');
- POSITION pos = sl.GetHeadPosition();
- while(pos)
- {
- if(!str.CompareNoCase(sl.GetNext(pos)))
- return CString(s_isolangs[i].iso6392);
- }
- }
- return _T("");
+ CString str = lang;
+ str.MakeLower();
+ for(ptrdiff_t i = 0, j = countof(s_isolangs); i < j; i++)
+ {
+ CAtlList<CString> sl;
+ Explode(CString(s_isolangs[i].name), sl, ';');
+ POSITION pos = sl.GetHeadPosition();
+ while(pos)
+ {
+ if(!str.CompareNoCase(sl.GetNext(pos)))
+ return CString(s_isolangs[i].iso6392);
+ }
+ }
+ return _T("");
}
int MakeAACInitData(BYTE* pData, int profile, int freq, int channels)
{
- int srate_idx;
-
- if(92017 <= freq) srate_idx = 0;
- else if(75132 <= freq) srate_idx = 1;
- else if(55426 <= freq) srate_idx = 2;
- else if(46009 <= freq) srate_idx = 3;
- else if(37566 <= freq) srate_idx = 4;
- else if(27713 <= freq) srate_idx = 5;
- else if(23004 <= freq) srate_idx = 6;
- else if(18783 <= freq) srate_idx = 7;
- else if(13856 <= freq) srate_idx = 8;
- else if(11502 <= freq) srate_idx = 9;
- else if(9391 <= freq) srate_idx = 10;
- else srate_idx = 11;
-
- pData[0] = ((abs(profile) + 1) << 3) | ((srate_idx & 0xe) >> 1);
- pData[1] = ((srate_idx & 0x1) << 7) | (channels << 3);
-
- int ret = 2;
-
- if(profile < 0)
- {
- freq *= 2;
-
- if(92017 <= freq) srate_idx = 0;
- else if(75132 <= freq) srate_idx = 1;
- else if(55426 <= freq) srate_idx = 2;
- else if(46009 <= freq) srate_idx = 3;
- else if(37566 <= freq) srate_idx = 4;
- else if(27713 <= freq) srate_idx = 5;
- else if(23004 <= freq) srate_idx = 6;
- else if(18783 <= freq) srate_idx = 7;
- else if(13856 <= freq) srate_idx = 8;
- else if(11502 <= freq) srate_idx = 9;
- else if(9391 <= freq) srate_idx = 10;
- else srate_idx = 11;
-
- pData[2] = 0x2B7 >> 3;
- pData[3] = (BYTE)((0x2B7 << 5) | 5);
- pData[4] = (1 << 7) | (srate_idx << 3);
-
- ret = 5;
- }
-
- return(ret);
+ int srate_idx;
+
+ if(92017 <= freq) srate_idx = 0;
+ else if(75132 <= freq) srate_idx = 1;
+ else if(55426 <= freq) srate_idx = 2;
+ else if(46009 <= freq) srate_idx = 3;
+ else if(37566 <= freq) srate_idx = 4;
+ else if(27713 <= freq) srate_idx = 5;
+ else if(23004 <= freq) srate_idx = 6;
+ else if(18783 <= freq) srate_idx = 7;
+ else if(13856 <= freq) srate_idx = 8;
+ else if(11502 <= freq) srate_idx = 9;
+ else if(9391 <= freq) srate_idx = 10;
+ else srate_idx = 11;
+
+ pData[0] = ((abs(profile) + 1) << 3) | ((srate_idx & 0xe) >> 1);
+ pData[1] = ((srate_idx & 0x1) << 7) | (channels << 3);
+
+ int ret = 2;
+
+ if(profile < 0)
+ {
+ freq *= 2;
+
+ if(92017 <= freq) srate_idx = 0;
+ else if(75132 <= freq) srate_idx = 1;
+ else if(55426 <= freq) srate_idx = 2;
+ else if(46009 <= freq) srate_idx = 3;
+ else if(37566 <= freq) srate_idx = 4;
+ else if(27713 <= freq) srate_idx = 5;
+ else if(23004 <= freq) srate_idx = 6;
+ else if(18783 <= freq) srate_idx = 7;
+ else if(13856 <= freq) srate_idx = 8;
+ else if(11502 <= freq) srate_idx = 9;
+ else if(9391 <= freq) srate_idx = 10;
+ else srate_idx = 11;
+
+ pData[2] = 0x2B7>>3;
+ pData[3] = (BYTE)((0x2B7<<5) | 5);
+ pData[4] = (1<<7) | (srate_idx<<3);
+
+ ret = 5;
+ }
+
+ return(ret);
}
BOOL CFileGetStatus(LPCTSTR lpszFileName, CFileStatus& status)
{
- try
- {
- return CFile::GetStatus(lpszFileName, status);
- }
- catch(CException* e)
- {
- // MFCBUG: E_INVALIDARG / "Parameter is incorrect" is thrown for certain cds (vs2003)
- // http://groups.google.co.uk/groups?hl=en&lr=&ie=UTF-8&threadm=OZuXYRzWDHA.536%40TK2MSFTNGP10.phx.gbl&rnum=1&prev=/groups%3Fhl%3Den%26lr%3D%26ie%3DISO-8859-1
- TRACE(_T("CFile::GetStatus has thrown an exception\n"));
- e->Delete();
- return false;
- }
+ try
+ {
+ return CFile::GetStatus(lpszFileName, status);
+ }
+ catch(CException* e)
+ {
+ // MFCBUG: E_INVALIDARG / "Parameter is incorrect" is thrown for certain cds (vs2003)
+ // http://groups.google.co.uk/groups?hl=en&lr=&ie=UTF-8&threadm=OZuXYRzWDHA.536%40TK2MSFTNGP10.phx.gbl&rnum=1&prev=/groups%3Fhl%3Den%26lr%3D%26ie%3DISO-8859-1
+ TRACE(_T("CFile::GetStatus has thrown an exception\n"));
+ e->Delete();
+ return false;
+ }
}
// filter registration helpers
bool DeleteRegKey(LPCTSTR pszKey, LPCTSTR pszSubkey)
{
- bool bOK = false;
+ bool bOK = false;
- HKEY hKey;
- LONG ec = ::RegOpenKeyEx(HKEY_CLASSES_ROOT, pszKey, 0, KEY_ALL_ACCESS, &hKey);
- if(ec == ERROR_SUCCESS)
- {
- if(pszSubkey != 0)
- ec = ::RegDeleteKey(hKey, pszSubkey);
+ HKEY hKey;
+ LONG ec = ::RegOpenKeyEx(HKEY_CLASSES_ROOT, pszKey, 0, KEY_ALL_ACCESS, &hKey);
+ if(ec == ERROR_SUCCESS)
+ {
+ if(pszSubkey != 0)
+ ec = ::RegDeleteKey(hKey, pszSubkey);
- bOK = (ec == ERROR_SUCCESS);
+ bOK = (ec == ERROR_SUCCESS);
- ::RegCloseKey(hKey);
- }
+ ::RegCloseKey(hKey);
+ }
- return bOK;
+ return bOK;
}
bool SetRegKeyValue(LPCTSTR pszKey, LPCTSTR pszSubkey, LPCTSTR pszValueName, LPCTSTR pszValue)
{
- bool bOK = false;
+ bool bOK = false;
- CString szKey(pszKey);
- if(pszSubkey != 0)
- szKey += CString(_T("\\")) + pszSubkey;
+ CString szKey(pszKey);
+ if(pszSubkey != 0)
+ szKey += CString(_T("\\")) + pszSubkey;
- HKEY hKey;
- LONG ec = ::RegCreateKeyEx(HKEY_CLASSES_ROOT, szKey, 0, 0, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, 0, &hKey, 0);
- if(ec == ERROR_SUCCESS)
- {
- if(pszValue != 0)
- {
- ec = ::RegSetValueEx(hKey, pszValueName, 0, REG_SZ,
- reinterpret_cast<BYTE*>(const_cast<LPTSTR>(pszValue)),
- (_tcslen(pszValue) + 1) * sizeof(TCHAR));
- }
+ HKEY hKey;
+ LONG ec = ::RegCreateKeyEx(HKEY_CLASSES_ROOT, szKey, 0, 0, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, 0, &hKey, 0);
+ if(ec == ERROR_SUCCESS)
+ {
+ if(pszValue != 0)
+ {
+ ec = ::RegSetValueEx(hKey, pszValueName, 0, REG_SZ,
+ reinterpret_cast<BYTE*>(const_cast<LPTSTR>(pszValue)),
+ (_tcslen(pszValue) + 1) * sizeof(TCHAR));
+ }
- bOK = (ec == ERROR_SUCCESS);
+ bOK = (ec == ERROR_SUCCESS);
- ::RegCloseKey(hKey);
- }
+ ::RegCloseKey(hKey);
+ }
- return bOK;
+ return bOK;
}
bool SetRegKeyValue(LPCTSTR pszKey, LPCTSTR pszSubkey, LPCTSTR pszValue)
{
- return SetRegKeyValue(pszKey, pszSubkey, 0, pszValue);
+ return SetRegKeyValue(pszKey, pszSubkey, 0, pszValue);
}
void RegisterSourceFilter(const CLSID& clsid, const GUID& subtype2, LPCTSTR chkbytes, LPCTSTR ext, ...)
{
- CString null = CStringFromGUID(GUID_NULL);
- CString majortype = CStringFromGUID(MEDIATYPE_Stream);
- CString subtype = CStringFromGUID(subtype2);
-
- SetRegKeyValue(_T("Media Type\\") + majortype, subtype, _T("0"), chkbytes);
- SetRegKeyValue(_T("Media Type\\") + majortype, subtype, _T("Source Filter"), CStringFromGUID(clsid));
+ CString null = CStringFromGUID(GUID_NULL);
+ CString majortype = CStringFromGUID(MEDIATYPE_Stream);
+ CString subtype = CStringFromGUID(subtype2);
- DeleteRegKey(_T("Media Type\\") + null, subtype);
+ SetRegKeyValue(_T("Media Type\\") + majortype, subtype, _T("0"), chkbytes);
+ SetRegKeyValue(_T("Media Type\\") + majortype, subtype, _T("Source Filter"), CStringFromGUID(clsid));
+
+ DeleteRegKey(_T("Media Type\\") + null, subtype);
- va_list marker;
- va_start(marker, ext);
- for(; ext; ext = va_arg(marker, LPCTSTR))
- DeleteRegKey(_T("Media Type\\Extensions"), ext);
- va_end(marker);
+ va_list marker;
+ va_start(marker, ext);
+ for(; ext; ext = va_arg(marker, LPCTSTR))
+ DeleteRegKey(_T("Media Type\\Extensions"), ext);
+ va_end(marker);
}
void RegisterSourceFilter(const CLSID& clsid, const GUID& subtype2, const CAtlList<CString>& chkbytes, LPCTSTR ext, ...)
{
- CString null = CStringFromGUID(GUID_NULL);
- CString majortype = CStringFromGUID(MEDIATYPE_Stream);
- CString subtype = CStringFromGUID(subtype2);
-
- POSITION pos = chkbytes.GetHeadPosition();
- for(ptrdiff_t i = 0; pos; i++)
- {
- CString idx;
- idx.Format(_T("%d"), i);
- SetRegKeyValue(_T("Media Type\\") + majortype, subtype, idx, chkbytes.GetNext(pos));
- }
+ CString null = CStringFromGUID(GUID_NULL);
+ CString majortype = CStringFromGUID(MEDIATYPE_Stream);
+ CString subtype = CStringFromGUID(subtype2);
- SetRegKeyValue(_T("Media Type\\") + majortype, subtype, _T("Source Filter"), CStringFromGUID(clsid));
+ POSITION pos = chkbytes.GetHeadPosition();
+ for(ptrdiff_t i = 0; pos; i++)
+ {
+ CString idx;
+ idx.Format(_T("%d"), i);
+ SetRegKeyValue(_T("Media Type\\") + majortype, subtype, idx, chkbytes.GetNext(pos));
+ }
- DeleteRegKey(_T("Media Type\\") + null, subtype);
+ SetRegKeyValue(_T("Media Type\\") + majortype, subtype, _T("Source Filter"), CStringFromGUID(clsid));
+
+ DeleteRegKey(_T("Media Type\\") + null, subtype);
- va_list marker;
- va_start(marker, ext);
- for(; ext; ext = va_arg(marker, LPCTSTR))
- DeleteRegKey(_T("Media Type\\Extensions"), ext);
- va_end(marker);
+ va_list marker;
+ va_start(marker, ext);
+ for(; ext; ext = va_arg(marker, LPCTSTR))
+ DeleteRegKey(_T("Media Type\\Extensions"), ext);
+ va_end(marker);
}
void UnRegisterSourceFilter(const GUID& subtype)
{
- DeleteRegKey(_T("Media Type\\") + CStringFromGUID(MEDIATYPE_Stream), CStringFromGUID(subtype));
+ DeleteRegKey(_T("Media Type\\") + CStringFromGUID(MEDIATYPE_Stream), CStringFromGUID(subtype));
}
typedef struct
{
- const GUID* Guid;
- const LPCTSTR Description;
+ const GUID* Guid;
+ const LPCTSTR Description;
} DXVA2_DECODER;
-static const DXVA2_DECODER DXVA2Decoder[] =
-{
- { &GUID_NULL, _T("Unknown") },
- { &GUID_NULL, _T("Not using DXVA") },
- { &DXVA2_ModeH264_A, _T("H.264 motion compensation, no FGT") },
- { &DXVA2_ModeH264_B, _T("H.264 motion compensation, FGT") },
- { &DXVA2_ModeH264_C, _T("H.264 IDCT, no FGT") },
- { &DXVA2_ModeH264_D, _T("H.264 IDCT, FGT") },
- { &DXVA2_ModeH264_E, _T("H.264 bitstream decoder, no FGT") },
- { &DXVA2_ModeH264_F, _T("H.264 bitstream decoder, FGT") },
- { &DXVA_Intel_H264_ClearVideo, _T("H.264 bitstream decoder, ClearVideo(tm)") },
- { &DXVA2_ModeMPEG2_IDCT, _T("MPEG-2 IDCT") },
- { &DXVA2_ModeMPEG2_MoComp, _T("MPEG-2 motion compensation") },
- { &DXVA2_ModeMPEG2_VLD, _T("MPEG-2 variable-length decoder") },
- { &DXVA_ModeMPEG2_A, _T("MPEG-2 A (Motion comp)") },
- { &DXVA_ModeMPEG2_B, _T("MPEG-2 B (Motion comp+blending)") },
- { &DXVA_ModeMPEG2_C, _T("MPEG-2 C (IDCT)") },
- { &DXVA_ModeMPEG2_D, _T("MPEG-2 D (IDCT+blending)") },
- { &DXVA2_ModeVC1_A, _T("VC-1 post processing") },
- { &DXVA2_ModeVC1_B, _T("VC-1 motion compensation") },
- { &DXVA2_ModeVC1_C, _T("VC-1 IDCT") },
- { &DXVA2_ModeVC1_D, _T("VC-1 bitstream decoder") },
- { &DXVA_Intel_VC1_ClearVideo, _T("VC-1 bitstream ClearVideo(tm) decoder") },
- { &DXVA2_ModeWMV8_A, _T("WMV 8 post processing.") },
- { &DXVA2_ModeWMV8_B, _T("WMV8 motion compensation") },
- { &DXVA2_ModeWMV9_A, _T("WMV9 post processing") },
- { &DXVA2_ModeWMV9_B, _T("WMV9 motion compensation") },
- { &DXVA2_ModeWMV9_C, _T("WMV9 IDCT") },
+static const DXVA2_DECODER DXVA2Decoder[] =
+{
+ { &GUID_NULL, _T("Unknown") },
+ { &GUID_NULL, _T("Not using DXVA") },
+ { &DXVA2_ModeH264_A, _T("H.264 motion compensation, no FGT") },
+ { &DXVA2_ModeH264_B, _T("H.264 motion compensation, FGT") },
+ { &DXVA2_ModeH264_C, _T("H.264 IDCT, no FGT") },
+ { &DXVA2_ModeH264_D, _T("H.264 IDCT, FGT") },
+ { &DXVA2_ModeH264_E, _T("H.264 bitstream decoder, no FGT") },
+ { &DXVA2_ModeH264_F, _T("H.264 bitstream decoder, FGT") },
+ { &DXVA_Intel_H264_ClearVideo, _T("H.264 bitstream decoder, ClearVideo(tm)") },
+ { &DXVA2_ModeMPEG2_IDCT, _T("MPEG-2 IDCT") },
+ { &DXVA2_ModeMPEG2_MoComp, _T("MPEG-2 motion compensation") },
+ { &DXVA2_ModeMPEG2_VLD, _T("MPEG-2 variable-length decoder") },
+ { &DXVA_ModeMPEG2_A, _T("MPEG-2 A (Motion comp)") },
+ { &DXVA_ModeMPEG2_B, _T("MPEG-2 B (Motion comp+blending)") },
+ { &DXVA_ModeMPEG2_C, _T("MPEG-2 C (IDCT)") },
+ { &DXVA_ModeMPEG2_D, _T("MPEG-2 D (IDCT+blending)") },
+ { &DXVA2_ModeVC1_A, _T("VC-1 post processing") },
+ { &DXVA2_ModeVC1_B, _T("VC-1 motion compensation") },
+ { &DXVA2_ModeVC1_C, _T("VC-1 IDCT") },
+ { &DXVA2_ModeVC1_D, _T("VC-1 bitstream decoder") },
+ { &DXVA_Intel_VC1_ClearVideo, _T("VC-1 bitstream ClearVideo(tm) decoder") },
+ { &DXVA2_ModeWMV8_A, _T("WMV 8 post processing.") },
+ { &DXVA2_ModeWMV8_B, _T("WMV8 motion compensation") },
+ { &DXVA2_ModeWMV9_A, _T("WMV9 post processing") },
+ { &DXVA2_ModeWMV9_B, _T("WMV9 motion compensation") },
+ { &DXVA2_ModeWMV9_C, _T("WMV9 IDCT") },
};
LPCTSTR GetDXVAMode(const GUID* guidDecoder)
{
- int nPos = 0;
+ int nPos = 0;
- for(int i = 1; i < countof(DXVA2Decoder); i++)
- {
- if(*guidDecoder == *DXVA2Decoder[i].Guid)
- {
- nPos = i;
- break;
- }
- }
+ for (int i=1; i<countof(DXVA2Decoder); i++)
+ {
+ if (*guidDecoder == *DXVA2Decoder[i].Guid)
+ {
+ nPos = i;
+ break;
+ }
+ }
- return DXVA2Decoder[nPos].Description;
+ return DXVA2Decoder[nPos].Description;
}
void DumpBuffer(BYTE* pBuffer, int nSize)
{
- CString strMsg;
- int nPos;
- strMsg.AppendFormat(L"Size : %d\n", nSize);
- for(int i = 0; i < 3; i++)
- {
- for(int j = 0; j < 32; j++)
- {
- nPos = i * 32 + j;
- if(nPos >= nSize) break;
- strMsg.AppendFormat(L"%02x ", pBuffer[nPos]);
- }
- if(nPos >= nSize) break;
- strMsg.AppendFormat(L"\n");
- }
-
- if(nSize > 32 * 3)
- {
- strMsg.AppendFormat(L".../...\n");
- for(int j = 32; j > 0; j--)
- {
- strMsg.AppendFormat(L"%02x ", pBuffer[nSize - j]);
- }
- }
- strMsg.AppendFormat(L"\n");
-
- TRACE(strMsg);
+ CString strMsg;
+ int nPos;
+ strMsg.AppendFormat (L"Size : %d\n", nSize);
+ for (int i=0; i<3; i++)
+ {
+ for (int j=0; j<32; j++)
+ {
+ nPos = i*32 + j;
+ if (nPos >= nSize) break;
+ strMsg.AppendFormat (L"%02x ", pBuffer[nPos]);
+ }
+ if (nPos >= nSize) break;
+ strMsg.AppendFormat (L"\n");
+ }
+
+ if (nSize > 32*3)
+ {
+ strMsg.AppendFormat (L".../...\n");
+ for (int j=32; j>0; j--)
+ {
+ strMsg.AppendFormat (L"%02x ", pBuffer[nSize - j]);
+ }
+ }
+ strMsg.AppendFormat(L"\n");
+
+ TRACE (strMsg);
}
CString ReftimeToString(const REFERENCE_TIME& rtVal)
{
- CString strTemp;
- LONGLONG llTotalMs = ConvertToMilliseconds(rtVal);
- int lHour = (int)(llTotalMs / (1000 * 60 * 60));
- int lMinute = (llTotalMs / (1000 * 60)) % 60;
- int lSecond = (llTotalMs / 1000) % 60;
- int lMillisec = llTotalMs % 1000;
+ CString strTemp;
+ LONGLONG llTotalMs = ConvertToMilliseconds (rtVal);
+ int lHour = (int)(llTotalMs / (1000*60*60));
+ int lMinute = (llTotalMs / (1000*60)) % 60;
+ int lSecond = (llTotalMs / 1000) % 60;
+ int lMillisec = llTotalMs % 1000;
- strTemp.Format(_T("%02d:%02d:%02d,%03d"), lHour, lMinute, lSecond, lMillisec);
- return strTemp;
+ strTemp.Format (_T("%02d:%02d:%02d,%03d"), lHour, lMinute, lSecond, lMillisec);
+ return strTemp;
}
REFERENCE_TIME StringToReftime(LPCTSTR strVal)
{
- REFERENCE_TIME rt = 0;
- int lHour = 0;
- int lMinute = 0;
- int lSecond = 0;
- int lMillisec = 0;
+ REFERENCE_TIME rt = 0;
+ int lHour = 0;
+ int lMinute = 0;
+ int lSecond = 0;
+ int lMillisec = 0;
- if(_stscanf_s(strVal, _T("%02d:%02d:%02d,%03d"), &lHour, &lMinute, &lSecond, &lMillisec) == 4)
- {
- rt = ((((lHour * 24) + lMinute) * 60 + lSecond) * MILLISECONDS + lMillisec) * (UNITS / MILLISECONDS);
- }
+ if (_stscanf_s (strVal, _T("%02d:%02d:%02d,%03d"), &lHour, &lMinute, &lSecond, &lMillisec) == 4)
+ {
+ rt = ( (((lHour*24)+lMinute)*60 + lSecond) * MILLISECONDS + lMillisec ) * (UNITS/MILLISECONDS);
+ }
- return rt;
+ return rt;
}
const double Rec601_Kr = 0.299;
@@ -2487,21 +2426,21 @@ const double Rec601_Kg = 0.587; COLORREF YCrCbToRGB_Rec601(BYTE Y, BYTE Cr, BYTE Cb)
{
- double rp = Y + 2 * (Cr - 128) * (1.0 - Rec601_Kr);
- double gp = Y - 2 * (Cb - 128) * (1.0 - Rec601_Kb) * Rec601_Kb / Rec601_Kg - 2 * (Cr - 128) * (1.0 - Rec601_Kr) * Rec601_Kr / Rec601_Kg;
- double bp = Y + 2 * (Cb - 128) * (1.0 - Rec601_Kb);
+ double rp = Y + 2*(Cr-128)*(1.0-Rec601_Kr);
+ double gp = Y - 2*(Cb-128)*(1.0-Rec601_Kb)*Rec601_Kb/Rec601_Kg - 2*(Cr-128)*(1.0-Rec601_Kr)*Rec601_Kr/Rec601_Kg;
+ double bp = Y + 2*(Cb-128)*(1.0-Rec601_Kb);
- return RGB(fabs(rp), fabs(gp), fabs(bp));
+ return RGB (fabs(rp), fabs(gp), fabs(bp));
}
DWORD YCrCbToRGB_Rec601(BYTE A, BYTE Y, BYTE Cr, BYTE Cb)
{
- double rp = Y + 2 * (Cr - 128) * (1.0 - Rec601_Kr);
- double gp = Y - 2 * (Cb - 128) * (1.0 - Rec601_Kb) * Rec601_Kb / Rec601_Kg - 2 * (Cr - 128) * (1.0 - Rec601_Kr) * Rec601_Kr / Rec601_Kg;
- double bp = Y + 2 * (Cb - 128) * (1.0 - Rec601_Kb);
+ double rp = Y + 2*(Cr-128)*(1.0-Rec601_Kr);
+ double gp = Y - 2*(Cb-128)*(1.0-Rec601_Kb)*Rec601_Kb/Rec601_Kg - 2*(Cr-128)*(1.0-Rec601_Kr)*Rec601_Kr/Rec601_Kg;
+ double bp = Y + 2*(Cb-128)*(1.0-Rec601_Kb);
- return D3DCOLOR_ARGB(A, (BYTE)fabs(rp), (BYTE)fabs(gp), (BYTE)fabs(bp));
+ return D3DCOLOR_ARGB(A, (BYTE)fabs(rp), (BYTE)fabs(gp), (BYTE)fabs(bp));
}
@@ -2511,106 +2450,88 @@ const double Rec709_Kg = 0.7154; COLORREF YCrCbToRGB_Rec709(BYTE Y, BYTE Cr, BYTE Cb)
{
- double rp = Y + 2 * (Cr - 128) * (1.0 - Rec709_Kr);
- double gp = Y - 2 * (Cb - 128) * (1.0 - Rec709_Kb) * Rec709_Kb / Rec709_Kg - 2 * (Cr - 128) * (1.0 - Rec709_Kr) * Rec709_Kr / Rec709_Kg;
- double bp = Y + 2 * (Cb - 128) * (1.0 - Rec709_Kb);
+ double rp = Y + 2*(Cr-128)*(1.0-Rec709_Kr);
+ double gp = Y - 2*(Cb-128)*(1.0-Rec709_Kb)*Rec709_Kb/Rec709_Kg - 2*(Cr-128)*(1.0-Rec709_Kr)*Rec709_Kr/Rec709_Kg;
+ double bp = Y + 2*(Cb-128)*(1.0-Rec709_Kb);
- return RGB(fabs(rp), fabs(gp), fabs(bp));
+ return RGB (fabs(rp), fabs(gp), fabs(bp));
}
DWORD YCrCbToRGB_Rec709(BYTE A, BYTE Y, BYTE Cr, BYTE Cb)
{
- double rp = Y + 2 * (Cr - 128) * (1.0 - Rec709_Kr);
- double gp = Y - 2 * (Cb - 128) * (1.0 - Rec709_Kb) * Rec709_Kb / Rec709_Kg - 2 * (Cr - 128) * (1.0 - Rec709_Kr) * Rec709_Kr / Rec709_Kg;
- double bp = Y + 2 * (Cb - 128) * (1.0 - Rec709_Kb);
+ double rp = Y + 2*(Cr-128)*(1.0-Rec709_Kr);
+ double gp = Y - 2*(Cb-128)*(1.0-Rec709_Kb)*Rec709_Kb/Rec709_Kg - 2*(Cr-128)*(1.0-Rec709_Kr)*Rec709_Kr/Rec709_Kg;
+ double bp = Y + 2*(Cb-128)*(1.0-Rec709_Kb);
- return D3DCOLOR_ARGB(A, (BYTE)fabs(rp), (BYTE)fabs(gp), (BYTE)fabs(bp));
+ return D3DCOLOR_ARGB (A, (BYTE)fabs(rp), (BYTE)fabs(gp), (BYTE)fabs(bp));
}
void TraceFilterInfo(IBaseFilter* pBF)
{
- FILTER_INFO Info;
- if(SUCCEEDED(pBF->QueryFilterInfo(&Info)))
- {
- TRACE(" === Filter info : %S\n", Info.achName);
- BeginEnumPins(pBF, pEnum, pPin)
- {
- TracePinInfo(pPin);
- }
+ FILTER_INFO Info;
+ if (SUCCEEDED (pBF->QueryFilterInfo(&Info)))
+ {
+ TRACE (" === Filter info : %S\n", Info.achName);
+ BeginEnumPins(pBF, pEnum, pPin)
+ {
+ TracePinInfo(pPin);
+ }
- EndEnumPins
- Info.pGraph->Release();
- }
+ EndEnumPins
+ Info.pGraph->Release();
+ }
}
void TracePinInfo(IPin* pPin)
{
- PIN_INFO PinInfo;
- FILTER_INFO ConnectedFilterInfo;
- PIN_INFO ConnectedInfo;
- CComPtr<IPin> pConnected;
- memset(&ConnectedInfo, 0, sizeof(ConnectedInfo));
- memset(&ConnectedFilterInfo, 0, sizeof(ConnectedFilterInfo));
- if(SUCCEEDED(pPin->ConnectedTo(&pConnected)))
- {
- pConnected->QueryPinInfo(&ConnectedInfo);
- ConnectedInfo.pFilter->QueryFilterInfo(&ConnectedFilterInfo);
- ConnectedInfo.pFilter->Release();
- ConnectedFilterInfo.pGraph->Release();
- }
- pPin->QueryPinInfo(&PinInfo);
- TRACE(" %S (%S) -> %S (Filter %S)\n",
- PinInfo.achName,
- PinInfo.dir == PINDIR_OUTPUT ? _T("Out") : _T("In"),
- ConnectedInfo.achName,
- ConnectedFilterInfo.achName);
- PinInfo.pFilter->Release();
+ PIN_INFO PinInfo;
+ FILTER_INFO ConnectedFilterInfo;
+ PIN_INFO ConnectedInfo;
+ CComPtr<IPin> pConnected;
+ memset (&ConnectedInfo, 0, sizeof(ConnectedInfo));
+ memset (&ConnectedFilterInfo, 0, sizeof(ConnectedFilterInfo));
+ if (SUCCEEDED (pPin->ConnectedTo (&pConnected)))
+ {
+ pConnected->QueryPinInfo (&ConnectedInfo);
+ ConnectedInfo.pFilter->QueryFilterInfo(&ConnectedFilterInfo);
+ ConnectedInfo.pFilter->Release();
+ ConnectedFilterInfo.pGraph->Release();
+ }
+ pPin->QueryPinInfo (&PinInfo);
+ TRACE(" %S (%S) -> %S (Filter %S)\n",
+ PinInfo.achName,
+ PinInfo.dir == PINDIR_OUTPUT ? _T("Out") : _T("In"),
+ ConnectedInfo.achName,
+ ConnectedFilterInfo.achName);
+ PinInfo.pFilter->Release();
}
const wchar_t *StreamTypeToName(PES_STREAM_TYPE _Type)
{
- switch(_Type)
- {
- case VIDEO_STREAM_MPEG1:
- return L"MPEG-1";
- case VIDEO_STREAM_MPEG2:
- return L"MPEG-2";
- case AUDIO_STREAM_MPEG1:
- return L"MPEG-1";
- case AUDIO_STREAM_MPEG2:
- return L"MPEG-2";
- case VIDEO_STREAM_H264:
- return L"H264";
- case AUDIO_STREAM_LPCM:
- return L"LPCM";
- case AUDIO_STREAM_AC3:
- return L"Dolby Digital";
- case AUDIO_STREAM_DTS:
- return L"DTS";
- case AUDIO_STREAM_AC3_TRUE_HD:
- return L"Dolby TrueHD";
- case AUDIO_STREAM_AC3_PLUS:
- return L"Dolby Digital Plus";
- case AUDIO_STREAM_DTS_HD:
- return L"DTS-HD High Resolution Audio";
- case AUDIO_STREAM_DTS_HD_MASTER_AUDIO:
- return L"DTS-HD Master Audio";
- case PRESENTATION_GRAPHICS_STREAM:
- return L"Presentation Graphics Stream";
- case INTERACTIVE_GRAPHICS_STREAM:
- return L"Interactive Graphics Stream";
- case SUBTITLE_STREAM:
- return L"Subtitle";
- case SECONDARY_AUDIO_AC3_PLUS:
- return L"Secondary Dolby Digital Plus";
- case SECONDARY_AUDIO_DTS_HD:
- return L"Secondary DTS-HD High Resolution Audio";
- case VIDEO_STREAM_VC1:
- return L"VC-1";
- }
- return NULL;
+ switch (_Type)
+ {
+ case VIDEO_STREAM_MPEG1: return L"MPEG-1";
+ case VIDEO_STREAM_MPEG2: return L"MPEG-2";
+ case AUDIO_STREAM_MPEG1: return L"MPEG-1";
+ case AUDIO_STREAM_MPEG2: return L"MPEG-2";
+ case VIDEO_STREAM_H264: return L"H264";
+ case AUDIO_STREAM_LPCM: return L"LPCM";
+ case AUDIO_STREAM_AC3: return L"Dolby Digital";
+ case AUDIO_STREAM_DTS: return L"DTS";
+ case AUDIO_STREAM_AC3_TRUE_HD: return L"Dolby TrueHD";
+ case AUDIO_STREAM_AC3_PLUS: return L"Dolby Digital Plus";
+ case AUDIO_STREAM_DTS_HD: return L"DTS-HD High Resolution Audio";
+ case AUDIO_STREAM_DTS_HD_MASTER_AUDIO: return L"DTS-HD Master Audio";
+ case PRESENTATION_GRAPHICS_STREAM: return L"Presentation Graphics Stream";
+ case INTERACTIVE_GRAPHICS_STREAM: return L"Interactive Graphics Stream";
+ case SUBTITLE_STREAM: return L"Subtitle";
+ case SECONDARY_AUDIO_AC3_PLUS: return L"Secondary Dolby Digital Plus";
+ case SECONDARY_AUDIO_DTS_HD: return L"Secondary DTS-HD High Resolution Audio";
+ case VIDEO_STREAM_VC1: return L"VC-1";
+ }
+ return NULL;
}
diff --git a/src/DSUtil/DSUtil.h b/src/DSUtil/DSUtil.h index 2dc436302..e30eb3f6e 100644 --- a/src/DSUtil/DSUtil.h +++ b/src/DSUtil/DSUtil.h @@ -1,4 +1,4 @@ -/*
+/*
* Copyright (C) 2003-2006 Gabest
* http://www.gabest.org
*
@@ -6,15 +6,15 @@ * it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
- *
+ *
* This Program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with GNU Make; see the file COPYING. If not, write to
- * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
+ * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
* http://www.gnu.org/copyleft/gpl.html
*
*/
@@ -120,27 +120,15 @@ extern void TracePinInfo(IPin* pPin); class CPinInfo : public PIN_INFO
{
public:
- CPinInfo()
- {
- pFilter = NULL;
- }
- ~CPinInfo()
- {
- if(pFilter) pFilter->Release();
- }
+ CPinInfo() {pFilter = NULL;}
+ ~CPinInfo() {if(pFilter) pFilter->Release();}
};
class CFilterInfo : public FILTER_INFO
{
public:
- CFilterInfo()
- {
- pGraph = NULL;
- }
- ~CFilterInfo()
- {
- if(pGraph) pGraph->Release();
- }
+ CFilterInfo() {pGraph = NULL;}
+ ~CFilterInfo() {if(pGraph) pGraph->Release();}
};
#define BeginEnumFilters(pFilterGraph, pEnumFilters, pBaseFilter) \
@@ -149,7 +137,7 @@ public: { \
for(CComPtr<IBaseFilter> pBaseFilter; S_OK == pEnumFilters->Next(1, &pBaseFilter, 0); pBaseFilter = NULL) \
{ \
-
+
#define EndEnumFilters }}}
#define BeginEnumCachedFilters(pGraphConfig, pEnumFilters, pBaseFilter) \
@@ -158,7 +146,7 @@ public: { \
for(CComPtr<IBaseFilter> pBaseFilter; S_OK == pEnumFilters->Next(1, &pBaseFilter, 0); pBaseFilter = NULL) \
{ \
-
+
#define EndEnumCachedFilters }}}
#define BeginEnumPins(pBaseFilter, pEnumPins, pPin) \
@@ -167,7 +155,7 @@ public: { \
for(CComPtr<IPin> pPin; S_OK == pEnumPins->Next(1, &pPin, 0); pPin = NULL) \
{ \
-
+
#define EndEnumPins }}}
#define BeginEnumMediaTypes(pPin, pEnumMediaTypes, pMediaType) \
@@ -177,7 +165,7 @@ public: AM_MEDIA_TYPE* pMediaType = NULL; \
for(; S_OK == pEnumMediaTypes->Next(1, &pMediaType, NULL); DeleteMediaType(pMediaType), pMediaType = NULL) \
{ \
-
+
#define EndEnumMediaTypes(pMediaType) } if(pMediaType) DeleteMediaType(pMediaType); }}
#define BeginEnumSysDev(clsid, pMoniker) \
@@ -189,7 +177,7 @@ public: { \
for(CComPtr<IMoniker> pMoniker; pClassEnum4$##clsid->Next(1, &pMoniker, 0) == S_OK; pMoniker = NULL) \
{ \
-
+
#define EndEnumSysDev }}}
#define QI(i) (riid == __uuidof(i)) ? GetInterface((i*)this, ppv) :
@@ -206,10 +194,10 @@ template <typename T> __inline void INITDDSTRUCT(T& dd) template <class T>
static CUnknown* WINAPI CreateInstance(LPUNKNOWN lpunk, HRESULT* phr)
{
- *phr = S_OK;
+ *phr = S_OK;
CUnknown* punk = DNew T(lpunk, phr);
if(punk == NULL) *phr = E_OUTOFMEMORY;
- return punk;
+ return punk;
}
#define SAFE_DELETE(p) { if(p) { delete (p); (p)=NULL; } }
diff --git a/src/DSUtil/FontInstaller.cpp b/src/DSUtil/FontInstaller.cpp index f9ce24ff8..842bdd837 100644 --- a/src/DSUtil/FontInstaller.cpp +++ b/src/DSUtil/FontInstaller.cpp @@ -3,92 +3,92 @@ CFontInstaller::CFontInstaller()
{
- if(HMODULE hGdi = GetModuleHandle(_T("gdi32.dll")))
- {
- pAddFontMemResourceEx = (HANDLE(WINAPI *)(PVOID, DWORD, PVOID, DWORD*))GetProcAddress(hGdi, "AddFontMemResourceEx");
- pAddFontResourceEx = (int (WINAPI *)(LPCTSTR, DWORD, PVOID))GetProcAddress(hGdi, "AddFontResourceExA");
- pRemoveFontMemResourceEx = (BOOL (WINAPI *)(HANDLE))GetProcAddress(hGdi, "RemoveFontMemResourceEx");
- pRemoveFontResourceEx = (BOOL (WINAPI *)(LPCTSTR, DWORD, PVOID))GetProcAddress(hGdi, "RemoveFontResourceExA");
- }
+ if(HMODULE hGdi = GetModuleHandle(_T("gdi32.dll")))
+ {
+ pAddFontMemResourceEx = (HANDLE (WINAPI *)(PVOID,DWORD,PVOID,DWORD*))GetProcAddress(hGdi, "AddFontMemResourceEx");
+ pAddFontResourceEx = (int (WINAPI *)(LPCTSTR,DWORD,PVOID))GetProcAddress(hGdi, "AddFontResourceExA");
+ pRemoveFontMemResourceEx = (BOOL (WINAPI *)(HANDLE))GetProcAddress(hGdi, "RemoveFontMemResourceEx");
+ pRemoveFontResourceEx = (BOOL (WINAPI *)(LPCTSTR,DWORD,PVOID))GetProcAddress(hGdi, "RemoveFontResourceExA");
+ }
- if(HMODULE hGdi = GetModuleHandle(_T("kernel32.dll")))
- {
- pMoveFileEx = (BOOL (WINAPI *)(LPCTSTR, LPCTSTR, DWORD))GetProcAddress(hGdi, "MoveFileExA");
- }
+ if(HMODULE hGdi = GetModuleHandle(_T("kernel32.dll")))
+ {
+ pMoveFileEx = (BOOL (WINAPI *)(LPCTSTR, LPCTSTR, DWORD))GetProcAddress(hGdi, "MoveFileExA");
+ }
}
CFontInstaller::~CFontInstaller()
{
- UninstallFonts();
+ UninstallFonts();
}
bool CFontInstaller::InstallFont(const CAtlArray<BYTE>& data)
{
- return InstallFont(data.GetData(), data.GetCount());
+ return InstallFont(data.GetData(), data.GetCount());
}
bool CFontInstaller::InstallFont(const void* pData, UINT len)
{
- return InstallFontFile(pData, len) || InstallFontMemory(pData, len);
+ return InstallFontFile(pData, len) || InstallFontMemory(pData, len);
}
void CFontInstaller::UninstallFonts()
{
- if(pRemoveFontMemResourceEx)
- {
- POSITION pos = m_fonts.GetHeadPosition();
- while(pos) pRemoveFontMemResourceEx(m_fonts.GetNext(pos));
- m_fonts.RemoveAll();
- }
+ if(pRemoveFontMemResourceEx)
+ {
+ POSITION pos = m_fonts.GetHeadPosition();
+ while(pos) pRemoveFontMemResourceEx(m_fonts.GetNext(pos));
+ m_fonts.RemoveAll();
+ }
- if(pRemoveFontResourceEx)
- {
- POSITION pos = m_files.GetHeadPosition();
- while(pos)
- {
- CString fn = m_files.GetNext(pos);
- pRemoveFontResourceEx(fn, FR_PRIVATE, 0);
- if(!DeleteFile(fn) && pMoveFileEx)
- pMoveFileEx(fn, NULL, MOVEFILE_DELAY_UNTIL_REBOOT);
- }
-
- m_files.RemoveAll();
- }
+ if(pRemoveFontResourceEx)
+ {
+ POSITION pos = m_files.GetHeadPosition();
+ while(pos)
+ {
+ CString fn = m_files.GetNext(pos);
+ pRemoveFontResourceEx(fn, FR_PRIVATE, 0);
+ if(!DeleteFile(fn) && pMoveFileEx)
+ pMoveFileEx(fn, NULL, MOVEFILE_DELAY_UNTIL_REBOOT);
+ }
+
+ m_files.RemoveAll();
+ }
}
bool CFontInstaller::InstallFontMemory(const void* pData, UINT len)
{
- if(!pAddFontMemResourceEx)
- return false;
+ if(!pAddFontMemResourceEx)
+ return false;
- DWORD nFonts = 0;
- HANDLE hFont = pAddFontMemResourceEx((PVOID)pData, len, NULL, &nFonts);
- if(hFont && nFonts > 0) m_fonts.AddTail(hFont);
- return hFont && nFonts > 0;
+ DWORD nFonts = 0;
+ HANDLE hFont = pAddFontMemResourceEx((PVOID)pData, len, NULL, &nFonts);
+ if(hFont && nFonts > 0) m_fonts.AddTail(hFont);
+ return hFont && nFonts > 0;
}
bool CFontInstaller::InstallFontFile(const void* pData, UINT len)
{
- if(!pAddFontResourceEx)
- return false;
+ if(!pAddFontResourceEx)
+ return false;
- CFile f;
- TCHAR path[_MAX_PATH], fn[_MAX_PATH];
- if(!GetTempPath(MAX_PATH, path) || !GetTempFileName(path, _T("g_font"), 0, fn))
- return false;
+ CFile f;
+ TCHAR path[_MAX_PATH], fn[_MAX_PATH];
+ if(!GetTempPath(MAX_PATH, path) || !GetTempFileName(path, _T("g_font"), 0, fn))
+ return false;
- if(f.Open(fn, CFile::modeWrite))
- {
- f.Write(pData, len);
- f.Close();
+ if(f.Open(fn, CFile::modeWrite))
+ {
+ f.Write(pData, len);
+ f.Close();
- if(pAddFontResourceEx(fn, FR_PRIVATE, 0) > 0)
- {
- m_files.AddTail(fn);
- return true;
- }
- }
+ if(pAddFontResourceEx(fn, FR_PRIVATE, 0) > 0)
+ {
+ m_files.AddTail(fn);
+ return true;
+ }
+ }
- DeleteFile(fn);
- return false;
+ DeleteFile(fn);
+ return false;
}
diff --git a/src/DSUtil/FontInstaller.h b/src/DSUtil/FontInstaller.h index b8eeeb8b4..60d1e77e1 100644 --- a/src/DSUtil/FontInstaller.h +++ b/src/DSUtil/FontInstaller.h @@ -4,22 +4,22 @@ class CFontInstaller
{
- HANDLE(WINAPI *pAddFontMemResourceEx)(PVOID, DWORD, PVOID, DWORD*);
- BOOL (WINAPI *pRemoveFontMemResourceEx)(HANDLE);
- int (WINAPI *pAddFontResourceEx)(LPCTSTR, DWORD, PVOID);
- BOOL (WINAPI *pRemoveFontResourceEx)(LPCTSTR, DWORD, PVOID);
- BOOL (WINAPI *pMoveFileEx)(LPCTSTR, LPCTSTR, DWORD);
+ HANDLE (WINAPI *pAddFontMemResourceEx)(PVOID,DWORD,PVOID,DWORD*);
+ BOOL (WINAPI *pRemoveFontMemResourceEx)(HANDLE);
+ int (WINAPI *pAddFontResourceEx)(LPCTSTR,DWORD,PVOID);
+ BOOL (WINAPI *pRemoveFontResourceEx)(LPCTSTR,DWORD,PVOID);
+ BOOL (WINAPI *pMoveFileEx)(LPCTSTR, LPCTSTR,DWORD);
- CAtlList<HANDLE> m_fonts;
- CAtlList<CString> m_files;
- bool InstallFontMemory(const void* pData, UINT len);
- bool InstallFontFile(const void* pData, UINT len);
+ CAtlList<HANDLE> m_fonts;
+ CAtlList<CString> m_files;
+ bool InstallFontMemory(const void* pData, UINT len);
+ bool InstallFontFile(const void* pData, UINT len);
public:
- CFontInstaller();
- virtual ~CFontInstaller();
+ CFontInstaller();
+ virtual ~CFontInstaller();
- bool InstallFont(const CAtlArray<BYTE>& data);
- bool InstallFont(const void* pData, UINT len);
- void UninstallFonts();
+ bool InstallFont(const CAtlArray<BYTE>& data);
+ bool InstallFont(const void* pData, UINT len);
+ void UninstallFonts();
};
diff --git a/src/DSUtil/GolombBuffer.cpp b/src/DSUtil/GolombBuffer.cpp index feaa9bb88..5a9bff625 100644 --- a/src/DSUtil/GolombBuffer.cpp +++ b/src/DSUtil/GolombBuffer.cpp @@ -1,4 +1,4 @@ -/*
+/*
* $Id$
*
* (C) 2006-2010 see AUTHORS
@@ -26,10 +26,10 @@ CGolombBuffer::CGolombBuffer(BYTE* pBuffer, int nSize)
{
- m_pBuffer = pBuffer;
- m_nSize = nSize;
+ m_pBuffer = pBuffer;
+ m_nSize = nSize;
- Reset();
+ Reset();
}
@@ -37,83 +37,83 @@ UINT64 CGolombBuffer::BitRead(int nBits, bool fPeek) {
// ASSERT(nBits >= 0 && nBits <= 64);
- while(m_bitlen < nBits)
- {
- m_bitbuff <<= 8;
+ while(m_bitlen < nBits)
+ {
+ m_bitbuff <<= 8;
- if(m_nBitPos >= m_nSize) return 0;
+ if (m_nBitPos >= m_nSize) return 0;
- *(BYTE*)&m_bitbuff = m_pBuffer[m_nBitPos++];
- m_bitlen += 8;
- }
+ *(BYTE*)&m_bitbuff = m_pBuffer[m_nBitPos++];
+ m_bitlen += 8;
+ }
- int bitlen = m_bitlen - nBits;
+ int bitlen = m_bitlen - nBits;
- UINT64 ret = (m_bitbuff >> bitlen) & ((1ui64 << nBits) - 1);
+ UINT64 ret = (m_bitbuff >> bitlen) & ((1ui64 << nBits) - 1);
- if(!fPeek)
- {
- m_bitbuff &= ((1ui64 << bitlen) - 1);
- m_bitlen = bitlen;
- }
+ if(!fPeek)
+ {
+ m_bitbuff &= ((1ui64 << bitlen) - 1);
+ m_bitlen = bitlen;
+ }
- return ret;
+ return ret;
}
UINT64 CGolombBuffer::UExpGolombRead()
{
- int n = -1;
- for(BYTE b = 0; !b; n++) b = (BYTE)BitRead(1);
- return (1ui64 << n) - 1 + BitRead(n);
+ int n = -1;
+ for(BYTE b = 0; !b; n++) b = (BYTE)BitRead(1);
+ return (1ui64 << n) - 1 + BitRead(n);
}
INT64 CGolombBuffer::SExpGolombRead()
{
- UINT64 k = UExpGolombRead();
- return ((k & 1) ? 1 : -1) * ((k + 1) >> 1);
+ UINT64 k = UExpGolombRead();
+ return ((k&1) ? 1 : -1) * ((k + 1) >> 1);
}
void CGolombBuffer::BitByteAlign()
{
- m_bitlen &= ~7;
+ m_bitlen &= ~7;
}
__int64 CGolombBuffer::GetPos()
{
- return m_nBitPos - (m_bitlen >> 3);
+ return m_nBitPos - (m_bitlen>>3);
}
void CGolombBuffer::ReadBuffer(BYTE* pDest, int nSize)
{
- ASSERT(m_nBitPos + nSize <= m_nSize);
- ASSERT(m_bitlen == 0);
- nSize = min(nSize, m_nSize - m_nBitPos);
-
- memcpy(pDest, m_pBuffer + m_nBitPos, nSize);
- m_nBitPos += nSize;
+ ASSERT (m_nBitPos + nSize <= m_nSize);
+ ASSERT (m_bitlen == 0);
+ nSize = min (nSize, m_nSize - m_nBitPos);
+
+ memcpy (pDest, m_pBuffer+m_nBitPos, nSize);
+ m_nBitPos += nSize;
}
void CGolombBuffer::Reset()
{
- m_nBitPos = 0;
- m_bitlen = 0;
- m_bitbuff = 0;
+ m_nBitPos = 0;
+ m_bitlen = 0;
+ m_bitbuff = 0;
}
void CGolombBuffer::Reset(BYTE* pNewBuffer, int nNewSize)
{
- m_pBuffer = pNewBuffer;
- m_nSize = nNewSize;
+ m_pBuffer = pNewBuffer;
+ m_nSize = nNewSize;
- Reset();
+ Reset();
}
void CGolombBuffer::SkipBytes(int nCount)
{
- m_nBitPos += nCount;
- m_bitlen = 0;
- m_bitbuff = 0;
+ m_nBitPos += nCount;
+ m_bitlen = 0;
+ m_bitbuff = 0;
}
diff --git a/src/DSUtil/GolombBuffer.h b/src/DSUtil/GolombBuffer.h index 6e5e3c9d8..ffb596e02 100644 --- a/src/DSUtil/GolombBuffer.h +++ b/src/DSUtil/GolombBuffer.h @@ -1,4 +1,4 @@ -/*
+/*
* $Id$
*
* (C) 2006-2010 see AUTHORS
@@ -25,58 +25,34 @@ class CGolombBuffer
{
public:
- CGolombBuffer(BYTE* pBuffer, int nSize);
-
- UINT64 BitRead(int nBits, bool fPeek = false);
- UINT64 UExpGolombRead();
- INT64 SExpGolombRead();
- void BitByteAlign();
-
- inline BYTE ReadByte()
- {
- return (BYTE) BitRead(8);
- };
- inline SHORT ReadShort()
- {
- return (SHORT)BitRead(16);
- };
- inline DWORD ReadDword()
- {
- return (DWORD)BitRead(32);
- };
- void ReadBuffer(BYTE* pDest, int nSize);
-
- void Reset();
- void Reset(BYTE* pNewBuffer, int nNewSize);
-
- void SetSize(int nValue)
- {
- m_nSize = nValue;
- };
- int GetSize() const
- {
- return m_nSize;
- };
- int RemainingSize() const
- {
- return m_nSize - m_nBitPos;
- };
- bool IsEOF() const
- {
- return m_nBitPos >= m_nSize;
- };
- INT64 GetPos();
- BYTE* GetBufferPos()
- {
- return m_pBuffer + m_nBitPos;
- };
-
- void SkipBytes(int nCount);
+ CGolombBuffer(BYTE* pBuffer, int nSize);
+
+ UINT64 BitRead(int nBits, bool fPeek = false);
+ UINT64 UExpGolombRead();
+ INT64 SExpGolombRead();
+ void BitByteAlign();
+
+ inline BYTE ReadByte() { return (BYTE) BitRead ( 8); };
+ inline SHORT ReadShort() { return (SHORT)BitRead (16); };
+ inline DWORD ReadDword() { return (DWORD)BitRead (32); };
+ void ReadBuffer(BYTE* pDest, int nSize);
+
+ void Reset();
+ void Reset(BYTE* pNewBuffer, int nNewSize);
+
+ void SetSize(int nValue) { m_nSize = nValue; };
+ int GetSize() const { return m_nSize; };
+ int RemainingSize() const { return m_nSize - m_nBitPos; };
+ bool IsEOF() const { return m_nBitPos >= m_nSize; };
+ INT64 GetPos();
+ BYTE* GetBufferPos() { return m_pBuffer + m_nBitPos; };
+
+ void SkipBytes(int nCount);
private :
- BYTE* m_pBuffer;
- int m_nSize;
- int m_nBitPos;
- int m_bitlen;
- INT64 m_bitbuff;
+ BYTE* m_pBuffer;
+ int m_nSize;
+ int m_nBitPos;
+ int m_bitlen;
+ INT64 m_bitbuff;
};
diff --git a/src/DSUtil/H264Nalu.cpp b/src/DSUtil/H264Nalu.cpp index 288abf390..dd8fe57f9 100644 --- a/src/DSUtil/H264Nalu.cpp +++ b/src/DSUtil/H264Nalu.cpp @@ -1,4 +1,4 @@ -/*
+/*
* $Id$
*
* (C) 2006-2010 see AUTHORS
@@ -25,74 +25,74 @@ void CH264Nalu::SetBuffer(BYTE* pBuffer, int nSize, int nNALSize)
{
- m_pBuffer = pBuffer;
- m_nSize = nSize;
- m_nNALSize = nNALSize;
- m_nCurPos = 0;
- m_nNextRTP = 0;
+ m_pBuffer = pBuffer;
+ m_nSize = nSize;
+ m_nNALSize = nNALSize;
+ m_nCurPos = 0;
+ m_nNextRTP = 0;
- m_nNALStartPos = 0;
- m_nNALDataPos = 0;
+ m_nNALStartPos = 0;
+ m_nNALDataPos = 0;
}
bool CH264Nalu::MoveToNextStartcode()
{
- int nBuffEnd = (m_nNextRTP > 0) ? min(m_nNextRTP, m_nSize - 4) : m_nSize - 4;
+ int nBuffEnd = (m_nNextRTP > 0) ? min (m_nNextRTP, m_nSize-4) : m_nSize-4;
- for(int i = m_nCurPos; i < nBuffEnd; i++)
- {
- if((*((DWORD*)(m_pBuffer + i)) & 0x00FFFFFF) == 0x00010000)
- {
- // Find next AnnexB Nal
- m_nCurPos = i;
- return true;
- }
- }
+ for (int i=m_nCurPos; i<nBuffEnd; i++)
+ {
+ if ((*((DWORD*)(m_pBuffer+i)) & 0x00FFFFFF) == 0x00010000)
+ {
+ // Find next AnnexB Nal
+ m_nCurPos = i;
+ return true;
+ }
+ }
- if((m_nNALSize != 0) && (m_nNextRTP < m_nSize))
- {
- m_nCurPos = m_nNextRTP;
- return true;
- }
+ if ((m_nNALSize != 0) && (m_nNextRTP < m_nSize))
+ {
+ m_nCurPos = m_nNextRTP;
+ return true;
+ }
- m_nCurPos = m_nSize;
- return false;
+ m_nCurPos = m_nSize;
+ return false;
}
bool CH264Nalu::ReadNext()
{
- if(m_nCurPos >= m_nSize) return false;
+ if (m_nCurPos >= m_nSize) return false;
- if((m_nNALSize != 0) && (m_nCurPos == m_nNextRTP))
- {
- // RTP Nalu type : (XX XX) XX XX NAL..., with XX XX XX XX or XX XX equal to NAL size
- m_nNALStartPos = m_nCurPos;
- m_nNALDataPos = m_nCurPos + m_nNALSize;
- int nTemp = 0;
- for(int i = 0; i < m_nNALSize; i++)
- {
- nTemp = (nTemp << 8) + m_pBuffer[m_nCurPos++];
- }
- m_nNextRTP += nTemp + m_nNALSize;
- MoveToNextStartcode();
- }
- else
- {
- // Remove trailing bits
- while(m_pBuffer[m_nCurPos] == 0x00 && ((*((DWORD*)(m_pBuffer + m_nCurPos)) & 0x00FFFFFF) != 0x00010000))
- m_nCurPos++;
+ if ((m_nNALSize != 0) && (m_nCurPos == m_nNextRTP))
+ {
+ // RTP Nalu type : (XX XX) XX XX NAL..., with XX XX XX XX or XX XX equal to NAL size
+ m_nNALStartPos = m_nCurPos;
+ m_nNALDataPos = m_nCurPos + m_nNALSize;
+ int nTemp = 0;
+ for (int i=0; i<m_nNALSize; i++)
+ {
+ nTemp = (nTemp << 8) + m_pBuffer[m_nCurPos++];
+ }
+ m_nNextRTP += nTemp + m_nNALSize;
+ MoveToNextStartcode();
+ }
+ else
+ {
+ // Remove trailing bits
+ while (m_pBuffer[m_nCurPos]==0x00 && ((*((DWORD*)(m_pBuffer+m_nCurPos)) & 0x00FFFFFF) != 0x00010000))
+ m_nCurPos++;
- // AnnexB Nalu : 00 00 01 NAL...
- m_nNALStartPos = m_nCurPos;
- m_nCurPos += 3;
- m_nNALDataPos = m_nCurPos;
- MoveToNextStartcode();
- }
+ // AnnexB Nalu : 00 00 01 NAL...
+ m_nNALStartPos = m_nCurPos;
+ m_nCurPos += 3;
+ m_nNALDataPos = m_nCurPos;
+ MoveToNextStartcode();
+ }
- forbidden_bit = (m_pBuffer[m_nNALDataPos] >> 7) & 1;
- nal_reference_idc = (m_pBuffer[m_nNALDataPos] >> 5) & 3;
- nal_unit_type = (NALU_TYPE)(m_pBuffer[m_nNALDataPos] & 0x1f);
+ forbidden_bit = (m_pBuffer[m_nNALDataPos]>>7) & 1;
+ nal_reference_idc = (m_pBuffer[m_nNALDataPos]>>5) & 3;
+ nal_unit_type = (NALU_TYPE) (m_pBuffer[m_nNALDataPos] & 0x1f);
- return true;
+ return true;
}
\ No newline at end of file diff --git a/src/DSUtil/H264Nalu.h b/src/DSUtil/H264Nalu.h index 493b6edf2..67548a264 100644 --- a/src/DSUtil/H264Nalu.h +++ b/src/DSUtil/H264Nalu.h @@ -1,4 +1,4 @@ -/*
+/*
* $Id$
*
* (C) 2006-2010 see AUTHORS
@@ -25,77 +25,56 @@ typedef enum
{
- NALU_TYPE_SLICE = 1,
- NALU_TYPE_DPA = 2,
- NALU_TYPE_DPB = 3,
- NALU_TYPE_DPC = 4,
- NALU_TYPE_IDR = 5,
- NALU_TYPE_SEI = 6,
- NALU_TYPE_SPS = 7,
- NALU_TYPE_PPS = 8,
- NALU_TYPE_AUD = 9,
- NALU_TYPE_EOSEQ = 10,
- NALU_TYPE_EOSTREAM = 11,
- NALU_TYPE_FILL = 12
+ NALU_TYPE_SLICE = 1,
+ NALU_TYPE_DPA = 2,
+ NALU_TYPE_DPB = 3,
+ NALU_TYPE_DPC = 4,
+ NALU_TYPE_IDR = 5,
+ NALU_TYPE_SEI = 6,
+ NALU_TYPE_SPS = 7,
+ NALU_TYPE_PPS = 8,
+ NALU_TYPE_AUD = 9,
+ NALU_TYPE_EOSEQ = 10,
+ NALU_TYPE_EOSTREAM = 11,
+ NALU_TYPE_FILL = 12
} NALU_TYPE;
class CH264Nalu
{
private :
- int forbidden_bit; //! should be always FALSE
- int nal_reference_idc; //! NALU_PRIORITY_xxxx
- NALU_TYPE nal_unit_type; //! NALU_TYPE_xxxx
+ int forbidden_bit; //! should be always FALSE
+ int nal_reference_idc; //! NALU_PRIORITY_xxxx
+ NALU_TYPE nal_unit_type; //! NALU_TYPE_xxxx
- int m_nNALStartPos; //! NALU start (including startcode / size)
- int m_nNALDataPos; //! Useful part
- unsigned m_nDataLen; //! Length of the NAL unit (Excluding the start code, which does not belong to the NALU)
+ int m_nNALStartPos; //! NALU start (including startcode / size)
+ int m_nNALDataPos; //! Useful part
+ unsigned m_nDataLen; //! Length of the NAL unit (Excluding the start code, which does not belong to the NALU)
- BYTE* m_pBuffer;
- int m_nCurPos;
- int m_nNextRTP;
- int m_nSize;
- int m_nNALSize;
+ BYTE* m_pBuffer;
+ int m_nCurPos;
+ int m_nNextRTP;
+ int m_nSize;
+ int m_nNALSize;
- bool MoveToNextStartcode();
+ bool MoveToNextStartcode();
public :
- NALU_TYPE GetType() const
- {
- return nal_unit_type;
- };
- bool IsRefFrame() const
- {
- return (nal_reference_idc != 0);
- };
+ NALU_TYPE GetType() const { return nal_unit_type; };
+ bool IsRefFrame() const { return (nal_reference_idc != 0); };
- int GetDataLength() const
- {
- return m_nCurPos - m_nNALDataPos;
- };
- BYTE* GetDataBuffer()
- {
- return m_pBuffer + m_nNALDataPos;
- };
- int GetRoundedDataLength() const
- {
- int nSize = m_nCurPos - m_nNALDataPos;
- return nSize + 128 - (nSize % 128);
- }
+ int GetDataLength() const { return m_nCurPos - m_nNALDataPos; };
+ BYTE* GetDataBuffer() { return m_pBuffer + m_nNALDataPos; };
+ int GetRoundedDataLength() const
+ {
+ int nSize = m_nCurPos - m_nNALDataPos;
+ return nSize + 128 - (nSize %128);
+ }
- int GetLength() const
- {
- return m_nCurPos - m_nNALStartPos;
- };
- BYTE* GetNALBuffer()
- {
- return m_pBuffer + m_nNALStartPos;
- };
- bool IsEOF() const
- {
- return m_nCurPos >= m_nSize;
- };
+ int GetLength() const { return m_nCurPos - m_nNALStartPos; };
+ BYTE* GetNALBuffer() { return m_pBuffer + m_nNALStartPos; };
+ bool IsEOF() const { return m_nCurPos >= m_nSize; };
- void SetBuffer(BYTE* pBuffer, int nSize, int nNALSize);
- bool ReadNext();
+ void SetBuffer (BYTE* pBuffer, int nSize, int nNALSize);
+ bool ReadNext();
};
diff --git a/src/DSUtil/HdmvClipInfo.cpp b/src/DSUtil/HdmvClipInfo.cpp index fa08b6cec..432d712a2 100644 --- a/src/DSUtil/HdmvClipInfo.cpp +++ b/src/DSUtil/HdmvClipInfo.cpp @@ -1,4 +1,4 @@ -/*
+/*
* $Id$
*
* (C) 2006-2010 see AUTHORS
@@ -28,347 +28,347 @@ extern LCID ISO6392ToLcid(LPCSTR code); CHdmvClipInfo::CHdmvClipInfo(void)
{
- m_hFile = INVALID_HANDLE_VALUE;
- m_bIsHdmv = false;
+ m_hFile = INVALID_HANDLE_VALUE;
+ m_bIsHdmv = false;
}
CHdmvClipInfo::~CHdmvClipInfo()
{
- CloseFile(S_OK);
+ CloseFile(S_OK);
}
HRESULT CHdmvClipInfo::CloseFile(HRESULT hr)
{
- if(m_hFile != INVALID_HANDLE_VALUE)
- {
- CloseHandle(m_hFile);
- m_hFile = INVALID_HANDLE_VALUE;
- }
- return hr;
+ if (m_hFile != INVALID_HANDLE_VALUE)
+ {
+ CloseHandle(m_hFile);
+ m_hFile = INVALID_HANDLE_VALUE;
+ }
+ return hr;
}
DWORD CHdmvClipInfo::ReadDword()
{
- return ReadByte() << 24 | ReadByte() << 16 | ReadByte() << 8 | ReadByte();
+ return ReadByte()<<24 | ReadByte()<<16 | ReadByte()<<8 | ReadByte();
}
SHORT CHdmvClipInfo::ReadShort()
{
- return ReadByte() << 8 | ReadByte();
+ return ReadByte()<<8 | ReadByte();
}
BYTE CHdmvClipInfo::ReadByte()
{
- BYTE bVal;
- DWORD dwRead;
- ReadFile(m_hFile, &bVal, sizeof(bVal), &dwRead, NULL);
+ BYTE bVal;
+ DWORD dwRead;
+ ReadFile (m_hFile, &bVal, sizeof(bVal), &dwRead, NULL);
- return bVal;
+ return bVal;
}
void CHdmvClipInfo::ReadBuffer(BYTE* pBuff, DWORD nLen)
{
- DWORD dwRead;
- ReadFile(m_hFile, pBuff, nLen, &dwRead, NULL);
+ DWORD dwRead;
+ ReadFile (m_hFile, pBuff, nLen, &dwRead, NULL);
}
HRESULT CHdmvClipInfo::ReadProgramInfo()
{
- BYTE number_of_program_sequences;
- BYTE number_of_streams_in_ps;
- DWORD dwPos;
-
- m_Streams.RemoveAll();
- SetFilePointer(m_hFile, ProgramInfo_start_address, NULL, FILE_BEGIN);
-
- ReadDword(); //length
- ReadByte(); //reserved_for_word_align
- number_of_program_sequences = (BYTE)ReadByte();
- int iStream = 0;
- for(size_t i = 0; i < number_of_program_sequences; i++)
- {
- ReadDword(); //SPN_program_sequence_start
- ReadShort(); //program_map_PID
- number_of_streams_in_ps = (BYTE)ReadByte(); //number_of_streams_in_ps
- ReadByte(); //reserved_for_future_use
-
- for(size_t stream_index = 0; stream_index < number_of_streams_in_ps; stream_index++)
- {
- m_Streams.SetCount(iStream + 1);
- m_Streams[iStream].m_PID = ReadShort(); // stream_PID
-
- // == StreamCodingInfo
- dwPos = SetFilePointer(m_hFile, 0, NULL, FILE_CURRENT) + 1;
- dwPos += ReadByte(); // length
- m_Streams[iStream].m_Type = (PES_STREAM_TYPE)ReadByte();
-
- switch(m_Streams[iStream].m_Type)
- {
- case VIDEO_STREAM_MPEG1:
- case VIDEO_STREAM_MPEG2:
- case VIDEO_STREAM_H264:
- case VIDEO_STREAM_VC1:
- {
- uint8 Temp = ReadByte();
- BDVM_VideoFormat VideoFormat = (BDVM_VideoFormat)(Temp >> 4);
- BDVM_FrameRate FrameRate = (BDVM_FrameRate)(Temp & 0xf);
- Temp = ReadByte();
- BDVM_AspectRatio AspectRatio = (BDVM_AspectRatio)(Temp >> 4);
-
- m_Streams[iStream].m_VideoFormat = VideoFormat;
- m_Streams[iStream].m_FrameRate = FrameRate;
- m_Streams[iStream].m_AspectRatio = AspectRatio;
- }
- break;
- case AUDIO_STREAM_MPEG1:
- case AUDIO_STREAM_MPEG2:
- case AUDIO_STREAM_LPCM:
- case AUDIO_STREAM_AC3:
- case AUDIO_STREAM_DTS:
- case AUDIO_STREAM_AC3_TRUE_HD:
- case AUDIO_STREAM_AC3_PLUS:
- case AUDIO_STREAM_DTS_HD:
- case AUDIO_STREAM_DTS_HD_MASTER_AUDIO:
- case SECONDARY_AUDIO_AC3_PLUS:
- case SECONDARY_AUDIO_DTS_HD:
- {
- uint8 Temp = ReadByte();
- BDVM_ChannelLayout ChannelLayout = (BDVM_ChannelLayout)(Temp >> 4);
- BDVM_SampleRate SampleRate = (BDVM_SampleRate)(Temp & 0xF);
-
- ReadBuffer((BYTE*)m_Streams[iStream].m_LanguageCode, 3);
- m_Streams[iStream].m_LCID = ISO6392ToLcid(m_Streams[iStream].m_LanguageCode);
- m_Streams[iStream].m_ChannelLayout = ChannelLayout;
- m_Streams[iStream].m_SampleRate = SampleRate;
- }
- break;
- case PRESENTATION_GRAPHICS_STREAM:
- case INTERACTIVE_GRAPHICS_STREAM:
- {
- ReadBuffer((BYTE*)m_Streams[iStream].m_LanguageCode, 3);
- m_Streams[iStream].m_LCID = ISO6392ToLcid(m_Streams[iStream].m_LanguageCode);
- }
- break;
- case SUBTITLE_STREAM:
- {
- ReadByte(); // Should this really be here?
- ReadBuffer((BYTE*)m_Streams[iStream].m_LanguageCode, 3);
- m_Streams[iStream].m_LCID = ISO6392ToLcid(m_Streams[iStream].m_LanguageCode);
- }
- break;
- default :
- break;
- }
-
- iStream++;
- SetFilePointer(m_hFile, dwPos, NULL, FILE_BEGIN);
- }
- }
- return S_OK;
+ BYTE number_of_program_sequences;
+ BYTE number_of_streams_in_ps;
+ DWORD dwPos;
+
+ m_Streams.RemoveAll();
+ SetFilePointer (m_hFile, ProgramInfo_start_address, NULL, FILE_BEGIN);
+
+ ReadDword(); //length
+ ReadByte(); //reserved_for_word_align
+ number_of_program_sequences = (BYTE)ReadByte();
+ int iStream = 0;
+ for (size_t i=0; i<number_of_program_sequences; i++)
+ {
+ ReadDword(); //SPN_program_sequence_start
+ ReadShort(); //program_map_PID
+ number_of_streams_in_ps = (BYTE)ReadByte(); //number_of_streams_in_ps
+ ReadByte(); //reserved_for_future_use
+
+ for (size_t stream_index=0; stream_index<number_of_streams_in_ps; stream_index++)
+ {
+ m_Streams.SetCount(iStream + 1);
+ m_Streams[iStream].m_PID = ReadShort(); // stream_PID
+
+ // == StreamCodingInfo
+ dwPos = SetFilePointer(m_hFile, 0, NULL, FILE_CURRENT) + 1;
+ dwPos += ReadByte(); // length
+ m_Streams[iStream].m_Type = (PES_STREAM_TYPE)ReadByte();
+
+ switch (m_Streams[iStream].m_Type)
+ {
+ case VIDEO_STREAM_MPEG1:
+ case VIDEO_STREAM_MPEG2:
+ case VIDEO_STREAM_H264:
+ case VIDEO_STREAM_VC1:
+ {
+ uint8 Temp = ReadByte();
+ BDVM_VideoFormat VideoFormat = (BDVM_VideoFormat)(Temp >> 4);
+ BDVM_FrameRate FrameRate = (BDVM_FrameRate)(Temp & 0xf);
+ Temp = ReadByte();
+ BDVM_AspectRatio AspectRatio = (BDVM_AspectRatio)(Temp >> 4);
+
+ m_Streams[iStream].m_VideoFormat = VideoFormat;
+ m_Streams[iStream].m_FrameRate = FrameRate;
+ m_Streams[iStream].m_AspectRatio = AspectRatio;
+ }
+ break;
+ case AUDIO_STREAM_MPEG1:
+ case AUDIO_STREAM_MPEG2:
+ case AUDIO_STREAM_LPCM:
+ case AUDIO_STREAM_AC3:
+ case AUDIO_STREAM_DTS:
+ case AUDIO_STREAM_AC3_TRUE_HD:
+ case AUDIO_STREAM_AC3_PLUS:
+ case AUDIO_STREAM_DTS_HD:
+ case AUDIO_STREAM_DTS_HD_MASTER_AUDIO:
+ case SECONDARY_AUDIO_AC3_PLUS:
+ case SECONDARY_AUDIO_DTS_HD:
+ {
+ uint8 Temp = ReadByte();
+ BDVM_ChannelLayout ChannelLayout = (BDVM_ChannelLayout)(Temp >> 4);
+ BDVM_SampleRate SampleRate = (BDVM_SampleRate)(Temp & 0xF);
+
+ ReadBuffer((BYTE*)m_Streams[iStream].m_LanguageCode, 3);
+ m_Streams[iStream].m_LCID = ISO6392ToLcid (m_Streams[iStream].m_LanguageCode);
+ m_Streams[iStream].m_ChannelLayout = ChannelLayout;
+ m_Streams[iStream].m_SampleRate = SampleRate;
+ }
+ break;
+ case PRESENTATION_GRAPHICS_STREAM:
+ case INTERACTIVE_GRAPHICS_STREAM:
+ {
+ ReadBuffer((BYTE*)m_Streams[iStream].m_LanguageCode, 3);
+ m_Streams[iStream].m_LCID = ISO6392ToLcid (m_Streams[iStream].m_LanguageCode);
+ }
+ break;
+ case SUBTITLE_STREAM:
+ {
+ ReadByte(); // Should this really be here?
+ ReadBuffer((BYTE*)m_Streams[iStream].m_LanguageCode, 3);
+ m_Streams[iStream].m_LCID = ISO6392ToLcid (m_Streams[iStream].m_LanguageCode);
+ }
+ break;
+ default :
+ break;
+ }
+
+ iStream++;
+ SetFilePointer(m_hFile, dwPos, NULL, FILE_BEGIN);
+ }
+ }
+ return S_OK;
}
HRESULT CHdmvClipInfo::ReadInfo(LPCTSTR strFile)
{
- BYTE Buff[100];
+ BYTE Buff[100];
- m_bIsHdmv = false;
- m_hFile = CreateFile(strFile, GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL,
- OPEN_EXISTING, FILE_ATTRIBUTE_READONLY | FILE_FLAG_SEQUENTIAL_SCAN, NULL);
+ m_bIsHdmv = false;
+ m_hFile = CreateFile(strFile, GENERIC_READ, FILE_SHARE_READ|FILE_SHARE_WRITE, NULL,
+ OPEN_EXISTING, FILE_ATTRIBUTE_READONLY|FILE_FLAG_SEQUENTIAL_SCAN, NULL);
- if(m_hFile != INVALID_HANDLE_VALUE)
- {
- ReadBuffer(Buff, 4);
- if(memcmp(Buff, "HDMV", 4)) return CloseFile(VFW_E_INVALID_FILE_FORMAT);
+ if(m_hFile != INVALID_HANDLE_VALUE)
+ {
+ ReadBuffer(Buff, 4);
+ if (memcmp (Buff, "HDMV", 4)) return CloseFile(VFW_E_INVALID_FILE_FORMAT);
- ReadBuffer(Buff, 4);
- if((memcmp(Buff, "0200", 4) != 0) && (memcmp(Buff, "0100", 4) != 0)) return CloseFile(VFW_E_INVALID_FILE_FORMAT);
+ ReadBuffer(Buff, 4);
+ if ((memcmp (Buff, "0200", 4)!=0) && (memcmp (Buff, "0100", 4)!=0)) return CloseFile (VFW_E_INVALID_FILE_FORMAT);
- SequenceInfo_start_address = ReadDword();
- ProgramInfo_start_address = ReadDword();
+ SequenceInfo_start_address = ReadDword();
+ ProgramInfo_start_address = ReadDword();
- ReadProgramInfo();
+ ReadProgramInfo();
- m_bIsHdmv = true;
+ m_bIsHdmv = true;
- return CloseFile(S_OK);
- }
-
- return AmHresultFromWin32(GetLastError());
+ return CloseFile(S_OK);
+ }
+
+ return AmHresultFromWin32(GetLastError());
}
CHdmvClipInfo::Stream* CHdmvClipInfo::FindStream(SHORT wPID)
{
- size_t nStreams = m_Streams.GetCount();
- for(size_t i = 0; i < nStreams; i++)
- {
- if(m_Streams[i].m_PID == wPID)
- return &m_Streams[i];
- }
-
- return NULL;
+ size_t nStreams = m_Streams.GetCount();
+ for (size_t i=0; i<nStreams; i++)
+ {
+ if (m_Streams[i].m_PID == wPID)
+ return &m_Streams[i];
+ }
+
+ return NULL;
}
LPCTSTR CHdmvClipInfo::Stream::Format()
{
- switch(m_Type)
- {
- case VIDEO_STREAM_MPEG1:
- return _T("Mpeg1");
- case VIDEO_STREAM_MPEG2:
- return _T("Mpeg2");
- case VIDEO_STREAM_H264:
- return _T("H264");
- case VIDEO_STREAM_VC1:
- return _T("VC1");
- case AUDIO_STREAM_MPEG1:
- return _T("MPEG1");
- case AUDIO_STREAM_MPEG2:
- return _T("MPEG2");
- case AUDIO_STREAM_LPCM:
- return _T("LPCM");
- case AUDIO_STREAM_AC3:
- return _T("AC3");
- case AUDIO_STREAM_DTS:
- return _T("DTS");
- case AUDIO_STREAM_AC3_TRUE_HD:
- return _T("MLP");
- case AUDIO_STREAM_AC3_PLUS:
- return _T("DD+");
- case AUDIO_STREAM_DTS_HD:
- return _T("DTS-HD");
- case AUDIO_STREAM_DTS_HD_MASTER_AUDIO:
- return _T("DTS-HD XLL");
- case SECONDARY_AUDIO_AC3_PLUS:
- return _T("Sec DD+");
- case SECONDARY_AUDIO_DTS_HD:
- return _T("Sec DTS-HD");
- case PRESENTATION_GRAPHICS_STREAM :
- return _T("PG");
- case INTERACTIVE_GRAPHICS_STREAM :
- return _T("IG");
- case SUBTITLE_STREAM :
- return _T("Text");
- default :
- return _T("Unknown");
- }
+ switch (m_Type)
+ {
+ case VIDEO_STREAM_MPEG1:
+ return _T("Mpeg1");
+ case VIDEO_STREAM_MPEG2:
+ return _T("Mpeg2");
+ case VIDEO_STREAM_H264:
+ return _T("H264");
+ case VIDEO_STREAM_VC1:
+ return _T("VC1");
+ case AUDIO_STREAM_MPEG1:
+ return _T("MPEG1");
+ case AUDIO_STREAM_MPEG2:
+ return _T("MPEG2");
+ case AUDIO_STREAM_LPCM:
+ return _T("LPCM");
+ case AUDIO_STREAM_AC3:
+ return _T("AC3");
+ case AUDIO_STREAM_DTS:
+ return _T("DTS");
+ case AUDIO_STREAM_AC3_TRUE_HD:
+ return _T("MLP");
+ case AUDIO_STREAM_AC3_PLUS:
+ return _T("DD+");
+ case AUDIO_STREAM_DTS_HD:
+ return _T("DTS-HD");
+ case AUDIO_STREAM_DTS_HD_MASTER_AUDIO:
+ return _T("DTS-HD XLL");
+ case SECONDARY_AUDIO_AC3_PLUS:
+ return _T("Sec DD+");
+ case SECONDARY_AUDIO_DTS_HD:
+ return _T("Sec DTS-HD");
+ case PRESENTATION_GRAPHICS_STREAM :
+ return _T("PG");
+ case INTERACTIVE_GRAPHICS_STREAM :
+ return _T("IG");
+ case SUBTITLE_STREAM :
+ return _T("Text");
+ default :
+ return _T("Unknown");
+ }
}
HRESULT CHdmvClipInfo::ReadPlaylist(CString strPlaylistFile, REFERENCE_TIME& rtDuration, CAtlList<PlaylistItem>& Playlist)
{
- BYTE Buff[100];
- CPath Path(strPlaylistFile);
- bool bDuplicate = false;
-
- // Get BDMV folder
- Path.RemoveFileSpec();
- Path.RemoveFileSpec();
-
- m_hFile = CreateFile(strPlaylistFile, GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL,
- OPEN_EXISTING, FILE_ATTRIBUTE_READONLY | FILE_FLAG_SEQUENTIAL_SCAN, NULL);
-
- if(m_hFile != INVALID_HANDLE_VALUE)
- {
- ReadBuffer(Buff, 4);
- if(memcmp(Buff, "MPLS", 4)) return CloseFile(VFW_E_INVALID_FILE_FORMAT);
-
- ReadBuffer(Buff, 4);
- if((memcmp(Buff, "0200", 4) != 0) && (memcmp(Buff, "0100", 4) != 0)) return CloseFile(VFW_E_INVALID_FILE_FORMAT);
-
- DWORD dwPos;
- DWORD dwTemp;
- SHORT nPlaylistItems;
-
- dwPos = ReadDword();
- SetFilePointer(m_hFile, dwPos, NULL, FILE_BEGIN);
-
- ReadDword();
- ReadShort();
- nPlaylistItems = ReadShort();
- ReadShort();
-
- dwPos += 10;
- rtDuration = 0;
- for(size_t i = 0; i < nPlaylistItems; i++)
- {
- PlaylistItem Item;
- SetFilePointer(m_hFile, dwPos, NULL, FILE_BEGIN);
- dwPos = dwPos + ReadShort() + 2;
- ReadBuffer(Buff, 5);
- Item.m_strFileName.Format(_T("%s\\STREAM\\%c%c%c%c%c.M2TS"), Path, Buff[0], Buff[1], Buff[2], Buff[3], Buff[4]);
-
- ReadBuffer(Buff, 4);
- if(memcmp(Buff, "M2TS", 4)) return CloseFile(VFW_E_INVALID_FILE_FORMAT);
- ReadBuffer(Buff, 3);
-
- dwTemp = ReadDword();
- Item.m_rtIn = 20000i64 * dwTemp / 90; // Carefull : 32->33 bits!
-
- dwTemp = ReadDword();
- Item.m_rtOut = 20000i64 * dwTemp / 90; // Carefull : 32->33 bits!
-
- rtDuration += (Item.m_rtOut - Item.m_rtIn);
-
- if(Playlist.Find(Item) != NULL)
- bDuplicate = true;
- Playlist.AddTail(Item);
-
- //TRACE ("File : %S, Duration : %S, Total duration : %S\n", strTemp, ReftimeToString (rtOut - rtIn), ReftimeToString (rtDuration));
- }
-
- CloseFile(S_OK);
- return bDuplicate ? S_FALSE : S_OK;
- }
-
- return AmHresultFromWin32(GetLastError());
+ BYTE Buff[100];
+ CPath Path (strPlaylistFile);
+ bool bDuplicate = false;
+
+ // Get BDMV folder
+ Path.RemoveFileSpec();
+ Path.RemoveFileSpec();
+
+ m_hFile = CreateFile(strPlaylistFile, GENERIC_READ, FILE_SHARE_READ|FILE_SHARE_WRITE, NULL,
+ OPEN_EXISTING, FILE_ATTRIBUTE_READONLY|FILE_FLAG_SEQUENTIAL_SCAN, NULL);
+
+ if(m_hFile != INVALID_HANDLE_VALUE)
+ {
+ ReadBuffer(Buff, 4);
+ if (memcmp (Buff, "MPLS", 4)) return CloseFile(VFW_E_INVALID_FILE_FORMAT);
+
+ ReadBuffer(Buff, 4);
+ if ((memcmp (Buff, "0200", 4)!=0) && (memcmp (Buff, "0100", 4)!=0)) return CloseFile(VFW_E_INVALID_FILE_FORMAT);
+
+ DWORD dwPos;
+ DWORD dwTemp;
+ SHORT nPlaylistItems;
+
+ dwPos = ReadDword();
+ SetFilePointer(m_hFile, dwPos, NULL, FILE_BEGIN);
+
+ ReadDword();
+ ReadShort();
+ nPlaylistItems = ReadShort();
+ ReadShort();
+
+ dwPos += 10;
+ rtDuration = 0;
+ for (size_t i=0; i<nPlaylistItems; i++)
+ {
+ PlaylistItem Item;
+ SetFilePointer(m_hFile, dwPos, NULL, FILE_BEGIN);
+ dwPos = dwPos + ReadShort() + 2;
+ ReadBuffer(Buff, 5);
+ Item.m_strFileName.Format(_T("%s\\STREAM\\%c%c%c%c%c.M2TS"), Path, Buff[0], Buff[1], Buff[2], Buff[3], Buff[4]);
+
+ ReadBuffer(Buff, 4);
+ if (memcmp (Buff, "M2TS", 4)) return CloseFile(VFW_E_INVALID_FILE_FORMAT);
+ ReadBuffer(Buff, 3);
+
+ dwTemp = ReadDword();
+ Item.m_rtIn = 20000i64*dwTemp/90; // Carefull : 32->33 bits!
+
+ dwTemp = ReadDword();
+ Item.m_rtOut = 20000i64*dwTemp/90; // Carefull : 32->33 bits!
+
+ rtDuration += (Item.m_rtOut - Item.m_rtIn);
+
+ if (Playlist.Find(Item) != NULL)
+ bDuplicate = true;
+ Playlist.AddTail (Item);
+
+ //TRACE ("File : %S, Duration : %S, Total duration : %S\n", strTemp, ReftimeToString (rtOut - rtIn), ReftimeToString (rtDuration));
+ }
+
+ CloseFile (S_OK);
+ return bDuplicate ? S_FALSE : S_OK;
+ }
+
+ return AmHresultFromWin32(GetLastError());
}
HRESULT CHdmvClipInfo::FindMainMovie(LPCTSTR strFolder, CString& strPlaylistFile, CAtlList<PlaylistItem>& MainPlaylist)
{
- HRESULT hr = E_FAIL;
-
- CString strPath(strFolder);
- CString strFilter;
-
- CAtlList<PlaylistItem> Playlist;
- WIN32_FIND_DATA fd = {0};
-
- strPath.Replace(_T("\\PLAYLIST\\"), _T("\\"));
- //strPath.Replace(_T("\\BDMV\\"), _T("\\"));
- strPath.Replace(_T("\\STREAM\\"), _T("\\"));
- strPath += _T("\\BDMV\\");
- strFilter.Format(_T("%sPLAYLIST\\*.mpls"), strPath);
-
- HANDLE hFind = FindFirstFile(strFilter, &fd);
- if(hFind != INVALID_HANDLE_VALUE)
- {
- REFERENCE_TIME rtMax = 0;
- REFERENCE_TIME rtCurrent;
- CString strCurrentPlaylist;
- do
- {
- strCurrentPlaylist.Format(_T("%sPLAYLIST\\%s"), strPath, fd.cFileName);
- Playlist.RemoveAll();
-
- // Main movie shouldn't have duplicate M2TS filename...
- if(ReadPlaylist(strCurrentPlaylist, rtCurrent, Playlist) == S_OK && rtCurrent > rtMax)
- {
- rtMax = rtCurrent;
-
- strPlaylistFile = strCurrentPlaylist;
- MainPlaylist.RemoveAll();
- POSITION pos = Playlist.GetHeadPosition();
- while(pos) MainPlaylist.AddTail(Playlist.GetNext(pos));
-
- hr = S_OK;
- }
- }
- while(FindNextFile(hFind, &fd));
-
- FindClose(hFind);
- }
-
- return hr;
+ HRESULT hr = E_FAIL;
+
+ CString strPath (strFolder);
+ CString strFilter;
+
+ CAtlList<PlaylistItem> Playlist;
+ WIN32_FIND_DATA fd = {0};
+
+ strPath.Replace(_T("\\PLAYLIST\\"), _T("\\"));
+ //strPath.Replace(_T("\\BDMV\\"), _T("\\"));
+ strPath.Replace(_T("\\STREAM\\"), _T("\\"));
+ strPath += _T("\\BDMV\\");
+ strFilter.Format (_T("%sPLAYLIST\\*.mpls"), strPath);
+
+ HANDLE hFind = FindFirstFile(strFilter, &fd);
+ if(hFind != INVALID_HANDLE_VALUE)
+ {
+ REFERENCE_TIME rtMax = 0;
+ REFERENCE_TIME rtCurrent;
+ CString strCurrentPlaylist;
+ do
+ {
+ strCurrentPlaylist.Format(_T("%sPLAYLIST\\%s"), strPath, fd.cFileName);
+ Playlist.RemoveAll();
+
+ // Main movie shouldn't have duplicate M2TS filename...
+ if (ReadPlaylist(strCurrentPlaylist, rtCurrent, Playlist) == S_OK && rtCurrent > rtMax)
+ {
+ rtMax = rtCurrent;
+
+ strPlaylistFile = strCurrentPlaylist;
+ MainPlaylist.RemoveAll();
+ POSITION pos = Playlist.GetHeadPosition();
+ while(pos) MainPlaylist.AddTail(Playlist.GetNext(pos));
+
+ hr = S_OK;
+ }
+ }
+ while(FindNextFile(hFind, &fd));
+
+ FindClose(hFind);
+ }
+
+ return hr;
}
diff --git a/src/DSUtil/HdmvClipInfo.h b/src/DSUtil/HdmvClipInfo.h index ab1df9b32..b178d3529 100644 --- a/src/DSUtil/HdmvClipInfo.h +++ b/src/DSUtil/HdmvClipInfo.h @@ -1,4 +1,4 @@ -/*
+/*
* $Id$
*
* (C) 2006-2010 see AUTHORS
@@ -89,81 +89,72 @@ class CHdmvClipInfo {
public:
- struct Stream
- {
- Stream()
- {
- memset(this, 0, sizeof(*this));
- }
- SHORT m_PID;
- PES_STREAM_TYPE m_Type;
- char m_LanguageCode[4];
- LCID m_LCID;
-
- // Valid for video types
- BDVM_VideoFormat m_VideoFormat;
- BDVM_FrameRate m_FrameRate;
- BDVM_AspectRatio m_AspectRatio;
- // Valid for audio types
- BDVM_ChannelLayout m_ChannelLayout;
- BDVM_SampleRate m_SampleRate;
-
- LPCTSTR Format();
- };
-
- struct PlaylistItem
- {
- CString m_strFileName;
- REFERENCE_TIME m_rtIn;
- REFERENCE_TIME m_rtOut;
-
- REFERENCE_TIME Duration() const
- {
- return m_rtOut - m_rtIn;
- }
-
- bool operator == (const PlaylistItem& pi) const
- {
- return pi.m_strFileName == m_strFileName;
- }
- };
-
- CHdmvClipInfo(void);
- ~CHdmvClipInfo();
-
- HRESULT ReadInfo(LPCTSTR strFile);
- Stream* FindStream(SHORT wPID);
- bool IsHdmv() const
- {
- return m_bIsHdmv;
- };
- size_t GetStreamNumber()
- {
- return m_Streams.GetCount();
- };
- Stream* GetStreamByIndex(size_t nIndex)
- {
- return (nIndex < m_Streams.GetCount()) ? &m_Streams[nIndex] : NULL;
- };
-
- HRESULT FindMainMovie(LPCTSTR strFolder, CString& strPlaylistFile, CAtlList<PlaylistItem>& MainPlaylist);
- HRESULT ReadPlaylist(CString strPlaylistFile, REFERENCE_TIME& rtDuration, CAtlList<PlaylistItem>& Playlist);
+ struct Stream
+ {
+ Stream()
+ {
+ memset(this, 0, sizeof(*this));
+ }
+ SHORT m_PID;
+ PES_STREAM_TYPE m_Type;
+ char m_LanguageCode[4];
+ LCID m_LCID;
+
+ // Valid for video types
+ BDVM_VideoFormat m_VideoFormat;
+ BDVM_FrameRate m_FrameRate;
+ BDVM_AspectRatio m_AspectRatio;
+ // Valid for audio types
+ BDVM_ChannelLayout m_ChannelLayout;
+ BDVM_SampleRate m_SampleRate;
+
+ LPCTSTR Format();
+ };
+
+ struct PlaylistItem
+ {
+ CString m_strFileName;
+ REFERENCE_TIME m_rtIn;
+ REFERENCE_TIME m_rtOut;
+
+ REFERENCE_TIME Duration() const
+ {
+ return m_rtOut - m_rtIn;
+ }
+
+ bool operator == (const PlaylistItem& pi) const
+ {
+ return pi.m_strFileName == m_strFileName;
+ }
+ };
+
+ CHdmvClipInfo(void);
+ ~CHdmvClipInfo();
+
+ HRESULT ReadInfo(LPCTSTR strFile);
+ Stream* FindStream(SHORT wPID);
+ bool IsHdmv() const { return m_bIsHdmv; };
+ size_t GetStreamNumber() { return m_Streams.GetCount(); };
+ Stream* GetStreamByIndex(size_t nIndex){ return (nIndex < m_Streams.GetCount()) ? &m_Streams[nIndex] : NULL; };
+
+ HRESULT FindMainMovie(LPCTSTR strFolder, CString& strPlaylistFile, CAtlList<PlaylistItem>& MainPlaylist);
+ HRESULT ReadPlaylist(CString strPlaylistFile, REFERENCE_TIME& rtDuration, CAtlList<PlaylistItem>& Playlist);
private :
- DWORD SequenceInfo_start_address;
- DWORD ProgramInfo_start_address;
+ DWORD SequenceInfo_start_address;
+ DWORD ProgramInfo_start_address;
- HANDLE m_hFile;
+ HANDLE m_hFile;
- CAtlArray<Stream> m_Streams;
- bool m_bIsHdmv;
+ CAtlArray<Stream> m_Streams;
+ bool m_bIsHdmv;
- DWORD ReadDword();
- SHORT ReadShort();
- BYTE ReadByte();
- void ReadBuffer(BYTE* pBuff, DWORD nLen);
+ DWORD ReadDword();
+ SHORT ReadShort();
+ BYTE ReadByte();
+ void ReadBuffer(BYTE* pBuff, DWORD nLen);
- HRESULT ReadProgramInfo();
- HRESULT CloseFile(HRESULT hr);
+ HRESULT ReadProgramInfo();
+ HRESULT CloseFile(HRESULT hr);
};
diff --git a/src/DSUtil/MediaTypeEx.cpp b/src/DSUtil/MediaTypeEx.cpp index 95023c1a6..027808a3a 100644 --- a/src/DSUtil/MediaTypeEx.cpp +++ b/src/DSUtil/MediaTypeEx.cpp @@ -9,12 +9,12 @@ #pragma pack(push, 1)
typedef struct
{
- WAVEFORMATEX Format;
- BYTE bBigEndian;
- BYTE bsid;
- BYTE lfeon;
- BYTE copyrightb;
- BYTE nAuxBitsCode; // Aux bits per frame
+ WAVEFORMATEX Format;
+ BYTE bBigEndian;
+ BYTE bsid;
+ BYTE lfeon;
+ BYTE copyrightb;
+ BYTE nAuxBitsCode; // Aux bits per frame
} DOLBYAC3WAVEFORMAT;
#pragma pack(pop)
@@ -24,629 +24,629 @@ CMediaTypeEx::CMediaTypeEx() CString CMediaTypeEx::ToString(IPin* pPin)
{
- CString packing, type, codec, dim, rate, dur;
-
- // TODO
-
- if(majortype == MEDIATYPE_DVD_ENCRYPTED_PACK)
- {
- packing = _T("Encrypted MPEG2 Pack");
- }
- else if(majortype == MEDIATYPE_MPEG2_PACK)
- {
- packing = _T("MPEG2 Pack");
- }
- else if(majortype == MEDIATYPE_MPEG2_PES)
- {
- packing = _T("MPEG2 PES");
- }
-
- if(majortype == MEDIATYPE_Video)
- {
- type = _T("Video");
-
- BITMAPINFOHEADER bih;
- bool fBIH = ExtractBIH(this, &bih);
-
- int w, h, arx, ary;
- bool fDim = ExtractDim(this, w, h, arx, ary);
-
- if(fBIH && bih.biCompression)
- {
- codec = GetVideoCodecName(subtype, bih.biCompression);
- }
-
- if(codec.IsEmpty())
- {
- if(formattype == FORMAT_MPEGVideo) codec = _T("MPEG1 Video");
- else if(formattype == FORMAT_MPEG2_VIDEO) codec = _T("MPEG2 Video");
- else if(formattype == FORMAT_DiracVideoInfo) codec = _T("Dirac Video");
- }
-
- if(fDim)
- {
- dim.Format(_T("%dx%d"), w, h);
- if(w*ary != h * arx) dim.Format(_T("%s (%d:%d)"), CString(dim), arx, ary);
- }
-
- if(formattype == FORMAT_VideoInfo || formattype == FORMAT_MPEGVideo)
- {
- VIDEOINFOHEADER* vih = (VIDEOINFOHEADER*)pbFormat;
- if(vih->AvgTimePerFrame) rate.Format(_T("%0.2ffps "), 10000000.0f / vih->AvgTimePerFrame);
- if(vih->dwBitRate) rate.Format(_T("%s%dkbps"), CString(rate), vih->dwBitRate / 1000);
- }
- else if(formattype == FORMAT_VideoInfo2 || formattype == FORMAT_MPEG2_VIDEO || formattype == FORMAT_DiracVideoInfo)
- {
- VIDEOINFOHEADER2* vih = (VIDEOINFOHEADER2*)pbFormat;
- if(vih->AvgTimePerFrame) rate.Format(_T("%0.2ffps "), 10000000.0f / vih->AvgTimePerFrame);
- if(vih->dwBitRate) rate.Format(_T("%s%dkbps"), CString(rate), vih->dwBitRate / 1000);
- }
-
- rate.Trim();
-
- if(subtype == MEDIASUBTYPE_DVD_SUBPICTURE)
- {
- type = _T("Subtitle");
- codec = _T("DVD Subpicture");
- }
- }
- else if(majortype == MEDIATYPE_Audio)
- {
- type = _T("Audio");
-
- if(formattype == FORMAT_WaveFormatEx)
- {
- WAVEFORMATEX* wfe = (WAVEFORMATEX*)Format();
-
- if(wfe->wFormatTag/* > WAVE_FORMAT_PCM && wfe->wFormatTag < WAVE_FORMAT_EXTENSIBLE
+ CString packing, type, codec, dim, rate, dur;
+
+ // TODO
+
+ if(majortype == MEDIATYPE_DVD_ENCRYPTED_PACK)
+ {
+ packing = _T("Encrypted MPEG2 Pack");
+ }
+ else if(majortype == MEDIATYPE_MPEG2_PACK)
+ {
+ packing = _T("MPEG2 Pack");
+ }
+ else if(majortype == MEDIATYPE_MPEG2_PES)
+ {
+ packing = _T("MPEG2 PES");
+ }
+
+ if(majortype == MEDIATYPE_Video)
+ {
+ type = _T("Video");
+
+ BITMAPINFOHEADER bih;
+ bool fBIH = ExtractBIH(this, &bih);
+
+ int w, h, arx, ary;
+ bool fDim = ExtractDim(this, w, h, arx, ary);
+
+ if(fBIH && bih.biCompression)
+ {
+ codec = GetVideoCodecName(subtype, bih.biCompression);
+ }
+
+ if(codec.IsEmpty())
+ {
+ if(formattype == FORMAT_MPEGVideo) codec = _T("MPEG1 Video");
+ else if(formattype == FORMAT_MPEG2_VIDEO) codec = _T("MPEG2 Video");
+ else if(formattype == FORMAT_DiracVideoInfo) codec = _T("Dirac Video");
+ }
+
+ if(fDim)
+ {
+ dim.Format(_T("%dx%d"), w, h);
+ if(w*ary != h*arx) dim.Format(_T("%s (%d:%d)"), CString(dim), arx, ary);
+ }
+
+ if(formattype == FORMAT_VideoInfo || formattype == FORMAT_MPEGVideo)
+ {
+ VIDEOINFOHEADER* vih = (VIDEOINFOHEADER*)pbFormat;
+ if(vih->AvgTimePerFrame) rate.Format(_T("%0.2ffps "), 10000000.0f / vih->AvgTimePerFrame);
+ if(vih->dwBitRate) rate.Format(_T("%s%dkbps"), CString(rate), vih->dwBitRate/1000);
+ }
+ else if(formattype == FORMAT_VideoInfo2 || formattype == FORMAT_MPEG2_VIDEO || formattype == FORMAT_DiracVideoInfo)
+ {
+ VIDEOINFOHEADER2* vih = (VIDEOINFOHEADER2*)pbFormat;
+ if(vih->AvgTimePerFrame) rate.Format(_T("%0.2ffps "), 10000000.0f / vih->AvgTimePerFrame);
+ if(vih->dwBitRate) rate.Format(_T("%s%dkbps"), CString(rate), vih->dwBitRate/1000);
+ }
+
+ rate.Trim();
+
+ if(subtype == MEDIASUBTYPE_DVD_SUBPICTURE)
+ {
+ type = _T("Subtitle");
+ codec = _T("DVD Subpicture");
+ }
+ }
+ else if(majortype == MEDIATYPE_Audio)
+ {
+ type = _T("Audio");
+
+ if(formattype == FORMAT_WaveFormatEx)
+ {
+ WAVEFORMATEX* wfe = (WAVEFORMATEX*)Format();
+
+ if(wfe->wFormatTag/* > WAVE_FORMAT_PCM && wfe->wFormatTag < WAVE_FORMAT_EXTENSIBLE
&& wfe->wFormatTag != WAVE_FORMAT_IEEE_FLOAT*/
- || subtype != GUID_NULL)
- {
- codec = GetAudioCodecName(subtype, wfe->wFormatTag);
- dim.Format(_T("%dHz"), wfe->nSamplesPerSec);
- if(wfe->nChannels == 1) dim.Format(_T("%s mono"), CString(dim));
- else if(wfe->nChannels == 2) dim.Format(_T("%s stereo"), CString(dim));
- else dim.Format(_T("%s %dch"), CString(dim), wfe->nChannels);
- if(wfe->nAvgBytesPerSec) rate.Format(_T("%dkbps"), wfe->nAvgBytesPerSec * 8 / 1000);
- }
- }
- else if(formattype == FORMAT_VorbisFormat)
- {
- VORBISFORMAT* vf = (VORBISFORMAT*)Format();
-
- codec = GetAudioCodecName(subtype, 0);
- dim.Format(_T("%dHz"), vf->nSamplesPerSec);
- if(vf->nChannels == 1) dim.Format(_T("%s mono"), CString(dim));
- else if(vf->nChannels == 2) dim.Format(_T("%s stereo"), CString(dim));
- else dim.Format(_T("%s %dch"), CString(dim), vf->nChannels);
- if(vf->nAvgBitsPerSec) rate.Format(_T("%dkbps"), vf->nAvgBitsPerSec / 1000);
- }
- else if(formattype == FORMAT_VorbisFormat2)
- {
- VORBISFORMAT2* vf = (VORBISFORMAT2*)Format();
-
- codec = GetAudioCodecName(subtype, 0);
- dim.Format(_T("%dHz"), vf->SamplesPerSec);
- if(vf->Channels == 1) dim.Format(_T("%s mono"), CString(dim));
- else if(vf->Channels == 2) dim.Format(_T("%s stereo"), CString(dim));
- else dim.Format(_T("%s %dch"), CString(dim), vf->Channels);
- }
- }
- else if(majortype == MEDIATYPE_Text)
- {
- type = _T("Text");
- }
- else if(majortype == MEDIATYPE_Subtitle)
- {
- type = _T("Subtitle");
- codec = GetSubtitleCodecName(subtype);
- }
- else
- {
- type = _T("Unknown");
- }
-
- if(CComQIPtr<IMediaSeeking> pMS = pPin)
- {
- REFERENCE_TIME rtDur = 0;
- if(SUCCEEDED(pMS->GetDuration(&rtDur)) && rtDur)
- {
- rtDur /= 10000000;
- int s = rtDur % 60;
- rtDur /= 60;
- int m = rtDur % 60;
- rtDur /= 60;
- int h = (int)rtDur;
- if(h) dur.Format(_T("%d:%02d:%02d"), h, m, s);
- else if(m) dur.Format(_T("%02d:%02d"), m, s);
- else if(s) dur.Format(_T("%ds"), s);
- }
- }
-
- CString str;
- if(!codec.IsEmpty()) str += codec + _T(" ");
- if(!dim.IsEmpty()) str += dim + _T(" ");
- if(!rate.IsEmpty()) str += rate + _T(" ");
- if(!dur.IsEmpty()) str += dur + _T(" ");
- str.Trim(_T(" ,"));
-
- if(!str.IsEmpty()) str = type + _T(": ") + str;
- else str = type;
-
- return str;
+ || subtype != GUID_NULL)
+ {
+ codec = GetAudioCodecName(subtype, wfe->wFormatTag);
+ dim.Format(_T("%dHz"), wfe->nSamplesPerSec);
+ if(wfe->nChannels == 1) dim.Format(_T("%s mono"), CString(dim));
+ else if(wfe->nChannels == 2) dim.Format(_T("%s stereo"), CString(dim));
+ else dim.Format(_T("%s %dch"), CString(dim), wfe->nChannels);
+ if(wfe->nAvgBytesPerSec) rate.Format(_T("%dkbps"), wfe->nAvgBytesPerSec*8/1000);
+ }
+ }
+ else if(formattype == FORMAT_VorbisFormat)
+ {
+ VORBISFORMAT* vf = (VORBISFORMAT*)Format();
+
+ codec = GetAudioCodecName(subtype, 0);
+ dim.Format(_T("%dHz"), vf->nSamplesPerSec);
+ if(vf->nChannels == 1) dim.Format(_T("%s mono"), CString(dim));
+ else if(vf->nChannels == 2) dim.Format(_T("%s stereo"), CString(dim));
+ else dim.Format(_T("%s %dch"), CString(dim), vf->nChannels);
+ if(vf->nAvgBitsPerSec) rate.Format(_T("%dkbps"), vf->nAvgBitsPerSec/1000);
+ }
+ else if(formattype == FORMAT_VorbisFormat2)
+ {
+ VORBISFORMAT2* vf = (VORBISFORMAT2*)Format();
+
+ codec = GetAudioCodecName(subtype, 0);
+ dim.Format(_T("%dHz"), vf->SamplesPerSec);
+ if(vf->Channels == 1) dim.Format(_T("%s mono"), CString(dim));
+ else if(vf->Channels == 2) dim.Format(_T("%s stereo"), CString(dim));
+ else dim.Format(_T("%s %dch"), CString(dim), vf->Channels);
+ }
+ }
+ else if(majortype == MEDIATYPE_Text)
+ {
+ type = _T("Text");
+ }
+ else if(majortype == MEDIATYPE_Subtitle)
+ {
+ type = _T("Subtitle");
+ codec = GetSubtitleCodecName(subtype);
+ }
+ else
+ {
+ type = _T("Unknown");
+ }
+
+ if(CComQIPtr<IMediaSeeking> pMS = pPin)
+ {
+ REFERENCE_TIME rtDur = 0;
+ if(SUCCEEDED(pMS->GetDuration(&rtDur)) && rtDur)
+ {
+ rtDur /= 10000000;
+ int s = rtDur%60;
+ rtDur /= 60;
+ int m = rtDur%60;
+ rtDur /= 60;
+ int h = (int)rtDur;
+ if(h) dur.Format(_T("%d:%02d:%02d"), h, m, s);
+ else if(m) dur.Format(_T("%02d:%02d"), m, s);
+ else if(s) dur.Format(_T("%ds"), s);
+ }
+ }
+
+ CString str;
+ if(!codec.IsEmpty()) str += codec + _T(" ");
+ if(!dim.IsEmpty()) str += dim + _T(" ");
+ if(!rate.IsEmpty()) str += rate + _T(" ");
+ if(!dur.IsEmpty()) str += dur + _T(" ");
+ str.Trim(_T(" ,"));
+
+ if(!str.IsEmpty()) str = type + _T(": ") + str;
+ else str = type;
+
+ return str;
}
CString CMediaTypeEx::GetVideoCodecName(const GUID& subtype, DWORD biCompression)
{
- CString str;
-
- static CAtlMap<DWORD, CString> names;
-
- if(names.IsEmpty())
- {
- names['WMV1'] = _T("Windows Media Video 7");
- names['WMV2'] = _T("Windows Media Video 8");
- names['WMV3'] = _T("Windows Media Video 9");
- names['DIV3'] = _T("DivX 3");
- names['MP43'] = _T("MSMPEG4v3");
- names['MP42'] = _T("MSMPEG4v2");
- names['MP41'] = _T("MSMPEG4v1");
- names['DX50'] = _T("DivX 5");
- names['DIVX'] = _T("DivX 6");
- names['XVID'] = _T("Xvid");
- names['MP4V'] = _T("MPEG4 Video");
- names['AVC1'] = _T("MPEG4 Video (H264)");
- names['H264'] = _T("MPEG4 Video (H264)");
- names['RV10'] = _T("RealVideo 1");
- names['RV20'] = _T("RealVideo 2");
- names['RV30'] = _T("RealVideo 3");
- names['RV40'] = _T("RealVideo 4");
- names['FLV1'] = _T("Flash Video 1");
- names['FLV4'] = _T("Flash Video 4");
- names['VP50'] = _T("On2 VP5");
- names['VP60'] = _T("On2 VP6");
- names['SVQ3'] = _T("SVQ3");
- names['SVQ1'] = _T("SVQ1");
- names['H263'] = _T("H263");
- // names[''] = _T("");
- }
-
- if(biCompression)
- {
- BYTE* b = (BYTE*)&biCompression;
-
- for(ptrdiff_t i = 0; i < 4; i++)
- if(b[i] >= 'a' && b[i] <= 'z')
- b[i] = toupper(b[i]);
-
- if(!names.Lookup(MAKEFOURCC(b[3], b[2], b[1], b[0]), str))
- {
- if(subtype == MEDIASUBTYPE_DiracVideo) str = _T("Dirac Video");
- // else if(subtype == ) str = _T("");
- else if(biCompression < 256) str.Format(_T("%d"), biCompression);
- else str.Format(_T("%4.4hs"), &biCompression);
- }
- }
-
- return str;
+ CString str;
+
+ static CAtlMap<DWORD, CString> names;
+
+ if(names.IsEmpty())
+ {
+ names['WMV1'] = _T("Windows Media Video 7");
+ names['WMV2'] = _T("Windows Media Video 8");
+ names['WMV3'] = _T("Windows Media Video 9");
+ names['DIV3'] = _T("DivX 3");
+ names['MP43'] = _T("MSMPEG4v3");
+ names['MP42'] = _T("MSMPEG4v2");
+ names['MP41'] = _T("MSMPEG4v1");
+ names['DX50'] = _T("DivX 5");
+ names['DIVX'] = _T("DivX 6");
+ names['XVID'] = _T("Xvid");
+ names['MP4V'] = _T("MPEG4 Video");
+ names['AVC1'] = _T("MPEG4 Video (H264)");
+ names['H264'] = _T("MPEG4 Video (H264)");
+ names['RV10'] = _T("RealVideo 1");
+ names['RV20'] = _T("RealVideo 2");
+ names['RV30'] = _T("RealVideo 3");
+ names['RV40'] = _T("RealVideo 4");
+ names['FLV1'] = _T("Flash Video 1");
+ names['FLV4'] = _T("Flash Video 4");
+ names['VP50'] = _T("On2 VP5");
+ names['VP60'] = _T("On2 VP6");
+ names['SVQ3'] = _T("SVQ3");
+ names['SVQ1'] = _T("SVQ1");
+ names['H263'] = _T("H263");
+ // names[''] = _T("");
+ }
+
+ if(biCompression)
+ {
+ BYTE* b = (BYTE*)&biCompression;
+
+ for(ptrdiff_t i = 0; i < 4; i++)
+ if(b[i] >= 'a' && b[i] <= 'z')
+ b[i] = toupper(b[i]);
+
+ if(!names.Lookup(MAKEFOURCC(b[3], b[2], b[1], b[0]), str))
+ {
+ if(subtype == MEDIASUBTYPE_DiracVideo) str = _T("Dirac Video");
+ // else if(subtype == ) str = _T("");
+ else if(biCompression < 256) str.Format(_T("%d"), biCompression);
+ else str.Format(_T("%4.4hs"), &biCompression);
+ }
+ }
+
+ return str;
}
CString CMediaTypeEx::GetAudioCodecName(const GUID& subtype, WORD wFormatTag)
{
- CString str;
-
- static CAtlMap<WORD, CString> names;
-
- if(names.IsEmpty())
- {
- names[WAVE_FORMAT_PCM] = _T("PCM");
- names[WAVE_FORMAT_EXTENSIBLE] = _T("WAVE_FORMAT_EXTENSIBLE");
- names[WAVE_FORMAT_IEEE_FLOAT] = _T("IEEE Float");
- names[WAVE_FORMAT_ADPCM] = _T("MS ADPCM");
- names[WAVE_FORMAT_ALAW] = _T("aLaw");
- names[WAVE_FORMAT_MULAW] = _T("muLaw");
- names[WAVE_FORMAT_DRM] = _T("DRM");
- names[WAVE_FORMAT_OKI_ADPCM] = _T("OKI ADPCM");
- names[WAVE_FORMAT_DVI_ADPCM] = _T("DVI ADPCM");
- names[WAVE_FORMAT_IMA_ADPCM] = _T("IMA ADPCM");
- names[WAVE_FORMAT_MEDIASPACE_ADPCM] = _T("Mediaspace ADPCM");
- names[WAVE_FORMAT_SIERRA_ADPCM] = _T("Sierra ADPCM");
- names[WAVE_FORMAT_G723_ADPCM] = _T("G723 ADPCM");
- names[WAVE_FORMAT_DIALOGIC_OKI_ADPCM] = _T("Dialogic OKI ADPCM");
- names[WAVE_FORMAT_MEDIAVISION_ADPCM] = _T("Media Vision ADPCM");
- names[WAVE_FORMAT_YAMAHA_ADPCM] = _T("Yamaha ADPCM");
- names[WAVE_FORMAT_DSPGROUP_TRUESPEECH] = _T("DSP Group Truespeech");
- names[WAVE_FORMAT_DOLBY_AC2] = _T("Dolby AC2");
- names[WAVE_FORMAT_GSM610] = _T("GSM610");
- names[WAVE_FORMAT_MSNAUDIO] = _T("MSN Audio");
- names[WAVE_FORMAT_ANTEX_ADPCME] = _T("Antex ADPCME");
- names[WAVE_FORMAT_CS_IMAADPCM] = _T("Crystal Semiconductor IMA ADPCM");
- names[WAVE_FORMAT_ROCKWELL_ADPCM] = _T("Rockwell ADPCM");
- names[WAVE_FORMAT_ROCKWELL_DIGITALK] = _T("Rockwell Digitalk");
- names[WAVE_FORMAT_G721_ADPCM] = _T("G721");
- names[WAVE_FORMAT_G728_CELP] = _T("G728");
- names[WAVE_FORMAT_MSG723] = _T("MSG723");
- names[WAVE_FORMAT_MPEG] = _T("MPEG Audio");
- names[WAVE_FORMAT_MPEGLAYER3] = _T("MPEG Audio Layer 3");
- names[WAVE_FORMAT_LUCENT_G723] = _T("Lucent G723");
- names[WAVE_FORMAT_VOXWARE] = _T("Voxware");
- names[WAVE_FORMAT_G726_ADPCM] = _T("G726");
- names[WAVE_FORMAT_G722_ADPCM] = _T("G722");
- names[WAVE_FORMAT_G729A] = _T("G729A");
- names[WAVE_FORMAT_MEDIASONIC_G723] = _T("MediaSonic G723");
- names[WAVE_FORMAT_ZYXEL_ADPCM] = _T("ZyXEL ADPCM");
- names[WAVE_FORMAT_RHETOREX_ADPCM] = _T("Rhetorex ADPCM");
- names[WAVE_FORMAT_VIVO_G723] = _T("Vivo G723");
- names[WAVE_FORMAT_VIVO_SIREN] = _T("Vivo Siren");
- names[WAVE_FORMAT_DIGITAL_G723] = _T("Digital G723");
- names[WAVE_FORMAT_SANYO_LD_ADPCM] = _T("Sanyo LD ADPCM");
- names[WAVE_FORMAT_CREATIVE_ADPCM] = _T("Creative ADPCM");
- names[WAVE_FORMAT_CREATIVE_FASTSPEECH8] = _T("Creative Fastspeech 8");
- names[WAVE_FORMAT_CREATIVE_FASTSPEECH10] = _T("Creative Fastspeech 10");
- names[WAVE_FORMAT_UHER_ADPCM] = _T("UHER ADPCM");
- names[WAVE_FORMAT_DOLBY_AC3] = _T("Dolby AC3");
- names[WAVE_FORMAT_DVD_DTS] = _T("DTS");
- names[WAVE_FORMAT_AAC] = _T("AAC");
- names[WAVE_FORMAT_FLAC] = _T("FLAC");
- names[WAVE_FORMAT_TTA1] = _T("TTA");
- names[WAVE_FORMAT_14_4] = _T("RealAudio 14.4");
- names[WAVE_FORMAT_28_8] = _T("RealAudio 28.8");
- names[WAVE_FORMAT_ATRC] = _T("RealAudio ATRC");
- names[WAVE_FORMAT_COOK] = _T("RealAudio COOK");
- names[WAVE_FORMAT_DNET] = _T("RealAudio DNET");
- names[WAVE_FORMAT_RAAC] = _T("RealAudio RAAC");
- names[WAVE_FORMAT_RACP] = _T("RealAudio RACP");
- names[WAVE_FORMAT_SIPR] = _T("RealAudio SIPR");
- names[WAVE_FORMAT_PS2_PCM] = _T("PS2 PCM");
- names[WAVE_FORMAT_PS2_ADPCM] = _T("PS2 ADPCM");
- names[0x0160] = _T("Windows Media Audio");
- names[0x0161] = _T("Windows Media Audio");
- names[0x0162] = _T("Windows Media Audio");
- names[0x0163] = _T("Windows Media Audio");
- // names[] = _T("");
- }
-
- if(!names.Lookup(wFormatTag, str))
- {
- if(subtype == MEDIASUBTYPE_Vorbis) str = _T("Vorbis (deprecated)");
- else if(subtype == MEDIASUBTYPE_Vorbis2) str = _T("Vorbis");
- else if(subtype == MEDIASUBTYPE_MP4A) str = _T("MPEG4 Audio");
- else if(subtype == MEDIASUBTYPE_FLAC_FRAMED) str = _T("FLAC (framed)");
- else if(subtype == MEDIASUBTYPE_DOLBY_AC3) str += _T("Dolby AC3");
- else if(subtype == MEDIASUBTYPE_DTS) str += _T("DTS");
- // else if(subtype == ) str = _T("");
- else str.Format(_T("0x%04x"), wFormatTag);
- }
-
- if(wFormatTag == WAVE_FORMAT_PCM)
- {
- if(subtype == MEDIASUBTYPE_DOLBY_AC3) str += _T(" (AC3)");
- else if(subtype == MEDIASUBTYPE_DTS) str += _T(" (DTS)");
- }
-
- return str;
+ CString str;
+
+ static CAtlMap<WORD, CString> names;
+
+ if(names.IsEmpty())
+ {
+ names[WAVE_FORMAT_PCM] = _T("PCM");
+ names[WAVE_FORMAT_EXTENSIBLE] = _T("WAVE_FORMAT_EXTENSIBLE");
+ names[WAVE_FORMAT_IEEE_FLOAT] = _T("IEEE Float");
+ names[WAVE_FORMAT_ADPCM] = _T("MS ADPCM");
+ names[WAVE_FORMAT_ALAW] = _T("aLaw");
+ names[WAVE_FORMAT_MULAW] = _T("muLaw");
+ names[WAVE_FORMAT_DRM] = _T("DRM");
+ names[WAVE_FORMAT_OKI_ADPCM] = _T("OKI ADPCM");
+ names[WAVE_FORMAT_DVI_ADPCM] = _T("DVI ADPCM");
+ names[WAVE_FORMAT_IMA_ADPCM] = _T("IMA ADPCM");
+ names[WAVE_FORMAT_MEDIASPACE_ADPCM] = _T("Mediaspace ADPCM");
+ names[WAVE_FORMAT_SIERRA_ADPCM] = _T("Sierra ADPCM");
+ names[WAVE_FORMAT_G723_ADPCM] = _T("G723 ADPCM");
+ names[WAVE_FORMAT_DIALOGIC_OKI_ADPCM] = _T("Dialogic OKI ADPCM");
+ names[WAVE_FORMAT_MEDIAVISION_ADPCM] = _T("Media Vision ADPCM");
+ names[WAVE_FORMAT_YAMAHA_ADPCM] = _T("Yamaha ADPCM");
+ names[WAVE_FORMAT_DSPGROUP_TRUESPEECH] = _T("DSP Group Truespeech");
+ names[WAVE_FORMAT_DOLBY_AC2] = _T("Dolby AC2");
+ names[WAVE_FORMAT_GSM610] = _T("GSM610");
+ names[WAVE_FORMAT_MSNAUDIO] = _T("MSN Audio");
+ names[WAVE_FORMAT_ANTEX_ADPCME] = _T("Antex ADPCME");
+ names[WAVE_FORMAT_CS_IMAADPCM] = _T("Crystal Semiconductor IMA ADPCM");
+ names[WAVE_FORMAT_ROCKWELL_ADPCM] = _T("Rockwell ADPCM");
+ names[WAVE_FORMAT_ROCKWELL_DIGITALK] = _T("Rockwell Digitalk");
+ names[WAVE_FORMAT_G721_ADPCM] = _T("G721");
+ names[WAVE_FORMAT_G728_CELP] = _T("G728");
+ names[WAVE_FORMAT_MSG723] = _T("MSG723");
+ names[WAVE_FORMAT_MPEG] = _T("MPEG Audio");
+ names[WAVE_FORMAT_MPEGLAYER3] = _T("MPEG Audio Layer 3");
+ names[WAVE_FORMAT_LUCENT_G723] = _T("Lucent G723");
+ names[WAVE_FORMAT_VOXWARE] = _T("Voxware");
+ names[WAVE_FORMAT_G726_ADPCM] = _T("G726");
+ names[WAVE_FORMAT_G722_ADPCM] = _T("G722");
+ names[WAVE_FORMAT_G729A] = _T("G729A");
+ names[WAVE_FORMAT_MEDIASONIC_G723] = _T("MediaSonic G723");
+ names[WAVE_FORMAT_ZYXEL_ADPCM] = _T("ZyXEL ADPCM");
+ names[WAVE_FORMAT_RHETOREX_ADPCM] = _T("Rhetorex ADPCM");
+ names[WAVE_FORMAT_VIVO_G723] = _T("Vivo G723");
+ names[WAVE_FORMAT_VIVO_SIREN] = _T("Vivo Siren");
+ names[WAVE_FORMAT_DIGITAL_G723] = _T("Digital G723");
+ names[WAVE_FORMAT_SANYO_LD_ADPCM] = _T("Sanyo LD ADPCM");
+ names[WAVE_FORMAT_CREATIVE_ADPCM] = _T("Creative ADPCM");
+ names[WAVE_FORMAT_CREATIVE_FASTSPEECH8] = _T("Creative Fastspeech 8");
+ names[WAVE_FORMAT_CREATIVE_FASTSPEECH10] = _T("Creative Fastspeech 10");
+ names[WAVE_FORMAT_UHER_ADPCM] = _T("UHER ADPCM");
+ names[WAVE_FORMAT_DOLBY_AC3] = _T("Dolby AC3");
+ names[WAVE_FORMAT_DVD_DTS] = _T("DTS");
+ names[WAVE_FORMAT_AAC] = _T("AAC");
+ names[WAVE_FORMAT_FLAC] = _T("FLAC");
+ names[WAVE_FORMAT_TTA1] = _T("TTA");
+ names[WAVE_FORMAT_14_4] = _T("RealAudio 14.4");
+ names[WAVE_FORMAT_28_8] = _T("RealAudio 28.8");
+ names[WAVE_FORMAT_ATRC] = _T("RealAudio ATRC");
+ names[WAVE_FORMAT_COOK] = _T("RealAudio COOK");
+ names[WAVE_FORMAT_DNET] = _T("RealAudio DNET");
+ names[WAVE_FORMAT_RAAC] = _T("RealAudio RAAC");
+ names[WAVE_FORMAT_RACP] = _T("RealAudio RACP");
+ names[WAVE_FORMAT_SIPR] = _T("RealAudio SIPR");
+ names[WAVE_FORMAT_PS2_PCM] = _T("PS2 PCM");
+ names[WAVE_FORMAT_PS2_ADPCM] = _T("PS2 ADPCM");
+ names[0x0160] = _T("Windows Media Audio");
+ names[0x0161] = _T("Windows Media Audio");
+ names[0x0162] = _T("Windows Media Audio");
+ names[0x0163] = _T("Windows Media Audio");
+ // names[] = _T("");
+ }
+
+ if(!names.Lookup(wFormatTag, str))
+ {
+ if(subtype == MEDIASUBTYPE_Vorbis) str = _T("Vorbis (deprecated)");
+ else if(subtype == MEDIASUBTYPE_Vorbis2) str = _T("Vorbis");
+ else if(subtype == MEDIASUBTYPE_MP4A) str = _T("MPEG4 Audio");
+ else if(subtype == MEDIASUBTYPE_FLAC_FRAMED) str = _T("FLAC (framed)");
+ else if(subtype == MEDIASUBTYPE_DOLBY_AC3) str += _T("Dolby AC3");
+ else if(subtype == MEDIASUBTYPE_DTS) str += _T("DTS");
+ // else if(subtype == ) str = _T("");
+ else str.Format(_T("0x%04x"), wFormatTag);
+ }
+
+ if(wFormatTag == WAVE_FORMAT_PCM)
+ {
+ if(subtype == MEDIASUBTYPE_DOLBY_AC3) str += _T(" (AC3)");
+ else if(subtype == MEDIASUBTYPE_DTS) str += _T(" (DTS)");
+ }
+
+ return str;
}
CString CMediaTypeEx::GetSubtitleCodecName(const GUID& subtype)
{
- CString str;
-
- static CAtlMap<GUID, CString> names;
-
- if(names.IsEmpty())
- {
- names[MEDIASUBTYPE_UTF8] = _T("UTF-8");
- names[MEDIASUBTYPE_SSA] = _T("SubStation Alpha");
- names[MEDIASUBTYPE_ASS] = _T("Advanced SubStation Alpha");
- names[MEDIASUBTYPE_ASS2] = _T("Advanced SubStation Alpha");
- names[MEDIASUBTYPE_SSF] = _T("Stuctured Subtitle Format");
- names[MEDIASUBTYPE_USF] = _T("Universal Subtitle Format");
- names[MEDIASUBTYPE_VOBSUB] = _T("VobSub");
- // names[''] = _T("");
- }
+ CString str;
- if(names.Lookup(subtype, str))
- {
+ static CAtlMap<GUID, CString> names;
- }
+ if(names.IsEmpty())
+ {
+ names[MEDIASUBTYPE_UTF8] = _T("UTF-8");
+ names[MEDIASUBTYPE_SSA] = _T("SubStation Alpha");
+ names[MEDIASUBTYPE_ASS] = _T("Advanced SubStation Alpha");
+ names[MEDIASUBTYPE_ASS2] = _T("Advanced SubStation Alpha");
+ names[MEDIASUBTYPE_SSF] = _T("Stuctured Subtitle Format");
+ names[MEDIASUBTYPE_USF] = _T("Universal Subtitle Format");
+ names[MEDIASUBTYPE_VOBSUB] = _T("VobSub");
+ // names[''] = _T("");
+ }
- return str;
+ if(names.Lookup(subtype, str))
+ {
+
+ }
+
+ return str;
}
void CMediaTypeEx::Dump(CAtlList<CString>& sl)
{
- CString str;
-
- sl.RemoveAll();
-
- int fmtsize = 0;
-
- CString major = CStringFromGUID(majortype);
- CString sub = CStringFromGUID(subtype);
- CString format = CStringFromGUID(formattype);
-
- sl.AddTail(ToString() + _T("\n"));
-
- sl.AddTail(_T("AM_MEDIA_TYPE: "));
- str.Format(_T("majortype: %s %s"), CString(GuidNames[majortype]), major);
- sl.AddTail(str);
- str.Format(_T("subtype: %s %s"), CString(GuidNames[subtype]), sub);
- sl.AddTail(str);
- str.Format(_T("formattype: %s %s"), CString(GuidNames[formattype]), format);
- sl.AddTail(str);
- str.Format(_T("bFixedSizeSamples: %d"), bFixedSizeSamples);
- sl.AddTail(str);
- str.Format(_T("bTemporalCompression: %d"), bTemporalCompression);
- sl.AddTail(str);
- str.Format(_T("lSampleSize: %d"), lSampleSize);
- sl.AddTail(str);
- str.Format(_T("cbFormat: %d"), cbFormat);
- sl.AddTail(str);
-
- sl.AddTail(_T(""));
-
- if(formattype == FORMAT_VideoInfo || formattype == FORMAT_VideoInfo2
- || formattype == FORMAT_MPEGVideo || formattype == FORMAT_MPEG2_VIDEO)
- {
- fmtsize =
- formattype == FORMAT_VideoInfo ? sizeof(VIDEOINFOHEADER) :
- formattype == FORMAT_VideoInfo2 ? sizeof(VIDEOINFOHEADER2) :
- formattype == FORMAT_MPEGVideo ? sizeof(MPEG1VIDEOINFO) - 1 :
- formattype == FORMAT_MPEG2_VIDEO ? sizeof(MPEG2VIDEOINFO) - 4 :
- 0;
-
- VIDEOINFOHEADER& vih = *(VIDEOINFOHEADER*)pbFormat;
- BITMAPINFOHEADER* bih = &vih.bmiHeader;
-
- sl.AddTail(_T("VIDEOINFOHEADER:"));
- str.Format(_T("rcSource: (%d,%d)-(%d,%d)"), vih.rcSource.left, vih.rcSource.top, vih.rcSource.right, vih.rcSource.bottom);
- sl.AddTail(str);
- str.Format(_T("rcTarget: (%d,%d)-(%d,%d)"), vih.rcTarget.left, vih.rcTarget.top, vih.rcTarget.right, vih.rcTarget.bottom);
- sl.AddTail(str);
- str.Format(_T("dwBitRate: %d"), vih.dwBitRate);
- sl.AddTail(str);
- str.Format(_T("dwBitErrorRate: %d"), vih.dwBitErrorRate);
- sl.AddTail(str);
- str.Format(_T("AvgTimePerFrame: %I64d"), vih.AvgTimePerFrame);
- sl.AddTail(str);
-
- sl.AddTail(_T(""));
-
- if(formattype == FORMAT_VideoInfo2 || formattype == FORMAT_MPEG2_VIDEO)
- {
- VIDEOINFOHEADER2& vih = *(VIDEOINFOHEADER2*)pbFormat;
- bih = &vih.bmiHeader;
-
- sl.AddTail(_T("VIDEOINFOHEADER2:"));
- str.Format(_T("dwInterlaceFlags: 0x%08x"), vih.dwInterlaceFlags);
- sl.AddTail(str);
- str.Format(_T("dwCopyProtectFlags: 0x%08x"), vih.dwCopyProtectFlags);
- sl.AddTail(str);
- str.Format(_T("dwPictAspectRatioX: %d"), vih.dwPictAspectRatioX);
- sl.AddTail(str);
- str.Format(_T("dwPictAspectRatioY: %d"), vih.dwPictAspectRatioY);
- sl.AddTail(str);
- str.Format(_T("dwControlFlags: 0x%08x"), vih.dwControlFlags);
- sl.AddTail(str);
- str.Format(_T("dwReserved2: 0x%08x"), vih.dwReserved2);
- sl.AddTail(str);
-
- sl.AddTail(_T(""));
- }
-
- if(formattype == FORMAT_MPEGVideo)
- {
- MPEG1VIDEOINFO& mvih = *(MPEG1VIDEOINFO*)pbFormat;
-
- sl.AddTail(_T("MPEG1VIDEOINFO:"));
- str.Format(_T("dwStartTimeCode: %d"), mvih.dwStartTimeCode);
- sl.AddTail(str);
- str.Format(_T("cbSequenceHeader: %d"), mvih.cbSequenceHeader);
- sl.AddTail(str);
-
- sl.AddTail(_T(""));
- }
- else if(formattype == FORMAT_MPEG2_VIDEO)
- {
- MPEG2VIDEOINFO& mvih = *(MPEG2VIDEOINFO*)pbFormat;
-
- sl.AddTail(_T("MPEG2VIDEOINFO:"));
- str.Format(_T("dwStartTimeCode: %d"), mvih.dwStartTimeCode);
- sl.AddTail(str);
- str.Format(_T("cbSequenceHeader: %d"), mvih.cbSequenceHeader);
- sl.AddTail(str);
- str.Format(_T("dwProfile: 0x%08x"), mvih.dwProfile);
- sl.AddTail(str);
- str.Format(_T("dwLevel: 0x%08x"), mvih.dwLevel);
- sl.AddTail(str);
- str.Format(_T("dwFlags: 0x%08x"), mvih.dwFlags);
- sl.AddTail(str);
-
- sl.AddTail(_T(""));
- }
-
- sl.AddTail(_T("BITMAPINFOHEADER:"));
- str.Format(_T("biSize: %d"), bih->biSize);
- sl.AddTail(str);
- str.Format(_T("biWidth: %d"), bih->biWidth);
- sl.AddTail(str);
- str.Format(_T("biHeight: %d"), bih->biHeight);
- sl.AddTail(str);
- str.Format(_T("biPlanes: %d"), bih->biPlanes);
- sl.AddTail(str);
- str.Format(_T("biBitCount: %d"), bih->biBitCount);
- sl.AddTail(str);
- if(bih->biCompression < 256) str.Format(_T("biCompression: %d"), bih->biCompression);
- else str.Format(_T("biCompression: %4.4hs"), &bih->biCompression);
- sl.AddTail(str);
- str.Format(_T("biSizeImage: %d"), bih->biSizeImage);
- sl.AddTail(str);
- str.Format(_T("biXPelsPerMeter: %d"), bih->biXPelsPerMeter);
- sl.AddTail(str);
- str.Format(_T("biYPelsPerMeter: %d"), bih->biYPelsPerMeter);
- sl.AddTail(str);
- str.Format(_T("biClrUsed: %d"), bih->biClrUsed);
- sl.AddTail(str);
- str.Format(_T("biClrImportant: %d"), bih->biClrImportant);
- sl.AddTail(str);
-
- sl.AddTail(_T(""));
- }
- else if(formattype == FORMAT_WaveFormatEx)
- {
- fmtsize = sizeof(WAVEFORMATEX);
-
- WAVEFORMATEX& wfe = *(WAVEFORMATEX*)pbFormat;
-
- sl.AddTail(_T("WAVEFORMATEX:"));
- str.Format(_T("wFormatTag: 0x%04x"), wfe.wFormatTag);
- sl.AddTail(str);
- str.Format(_T("nChannels: %d"), wfe.nChannels);
- sl.AddTail(str);
- str.Format(_T("nSamplesPerSec: %d"), wfe.nSamplesPerSec);
- sl.AddTail(str);
- str.Format(_T("nAvgBytesPerSec: %d"), wfe.nAvgBytesPerSec);
- sl.AddTail(str);
- str.Format(_T("nBlockAlign: %d"), wfe.nBlockAlign);
- sl.AddTail(str);
- str.Format(_T("wBitsPerSample: %d"), wfe.wBitsPerSample);
- sl.AddTail(str);
- str.Format(_T("cbSize: %d (extra bytes)"), wfe.cbSize);
- sl.AddTail(str);
-
- sl.AddTail(_T(""));
-
- if(wfe.wFormatTag != WAVE_FORMAT_PCM && wfe.cbSize > 0)
- {
- if(wfe.wFormatTag == WAVE_FORMAT_EXTENSIBLE && wfe.cbSize == sizeof(WAVEFORMATEXTENSIBLE) - sizeof(WAVEFORMATEX))
- {
- fmtsize = sizeof(WAVEFORMATEXTENSIBLE);
-
- WAVEFORMATEXTENSIBLE& wfe = *(WAVEFORMATEXTENSIBLE*)pbFormat;
-
- sl.AddTail(_T("WAVEFORMATEXTENSIBLE:"));
- if(wfe.Format.wBitsPerSample != 0) str.Format(_T("wValidBitsPerSample: %d"), wfe.Samples.wValidBitsPerSample);
- else str.Format(_T("wSamplesPerBlock: %d"), wfe.Samples.wSamplesPerBlock);
- sl.AddTail(str);
- str.Format(_T("dwChannelMask: 0x%08x"), wfe.dwChannelMask);
- sl.AddTail(str);
- str.Format(_T("SubFormat: %s"), CStringFromGUID(wfe.SubFormat));
- sl.AddTail(str);
-
- sl.AddTail(_T(""));
- }
- else if(wfe.wFormatTag == WAVE_FORMAT_DOLBY_AC3 && wfe.cbSize == sizeof(DOLBYAC3WAVEFORMAT) - sizeof(WAVEFORMATEX))
- {
- fmtsize = sizeof(DOLBYAC3WAVEFORMAT);
-
- DOLBYAC3WAVEFORMAT& wfe = *(DOLBYAC3WAVEFORMAT*)pbFormat;
-
- sl.AddTail(_T("DOLBYAC3WAVEFORMAT:"));
- str.Format(_T("bBigEndian: %d"), wfe.bBigEndian);
- sl.AddTail(str);
- str.Format(_T("bsid: %d"), wfe.bsid);
- sl.AddTail(str);
- str.Format(_T("lfeon: %d"), wfe.lfeon);
- sl.AddTail(str);
- str.Format(_T("copyrightb: %d"), wfe.copyrightb);
- sl.AddTail(str);
- str.Format(_T("nAuxBitsCode: %d"), wfe.nAuxBitsCode);
- sl.AddTail(str);
-
- sl.AddTail(_T(""));
- }
- }
- }
- else if(formattype == FORMAT_VorbisFormat)
- {
- fmtsize = sizeof(VORBISFORMAT);
-
- VORBISFORMAT& vf = *(VORBISFORMAT*)pbFormat;
-
- sl.AddTail(_T("VORBISFORMAT:"));
- str.Format(_T("nChannels: %d"), vf.nChannels);
- sl.AddTail(str);
- str.Format(_T("nSamplesPerSec: %d"), vf.nSamplesPerSec);
- sl.AddTail(str);
- str.Format(_T("nMinBitsPerSec: %d"), vf.nMinBitsPerSec);
- sl.AddTail(str);
- str.Format(_T("nAvgBitsPerSec: %d"), vf.nAvgBitsPerSec);
- sl.AddTail(str);
- str.Format(_T("nMaxBitsPerSec: %d"), vf.nMaxBitsPerSec);
- sl.AddTail(str);
- str.Format(_T("fQuality: %.3f"), vf.fQuality);
- sl.AddTail(str);
-
- sl.AddTail(_T(""));
- }
- else if(formattype == FORMAT_VorbisFormat2)
- {
- fmtsize = sizeof(VORBISFORMAT2);
-
- VORBISFORMAT2& vf = *(VORBISFORMAT2*)pbFormat;
-
- sl.AddTail(_T("VORBISFORMAT:"));
- str.Format(_T("Channels: %d"), vf.Channels);
- sl.AddTail(str);
- str.Format(_T("SamplesPerSec: %d"), vf.SamplesPerSec);
- sl.AddTail(str);
- str.Format(_T("BitsPerSample: %d"), vf.BitsPerSample);
- sl.AddTail(str);
- str.Format(_T("HeaderSize: {%d, %d, %d}"), vf.HeaderSize[0], vf.HeaderSize[1], vf.HeaderSize[2]);
- sl.AddTail(str);
-
- sl.AddTail(_T(""));
- }
- else if(formattype == FORMAT_SubtitleInfo)
- {
- fmtsize = sizeof(SUBTITLEINFO);
-
- SUBTITLEINFO& si = *(SUBTITLEINFO*)pbFormat;
-
- sl.AddTail(_T("SUBTITLEINFO:"));
- str.Format(_T("dwOffset: %d"), si.dwOffset);
- sl.AddTail(str);
- str.Format(_T("IsoLang: %s"), CString(CStringA(si.IsoLang, sizeof(si.IsoLang) - 1)));
- sl.AddTail(str);
- str.Format(_T("TrackName: %s"), CString(CStringW(si.TrackName, sizeof(si.TrackName) - 1)));
- sl.AddTail(str);
-
- sl.AddTail(_T(""));
- }
-
- if(cbFormat > 0)
- {
- sl.AddTail(_T("pbFormat:"));
-
- for(ptrdiff_t i = 0, j = (cbFormat + 15) & ~15; i < j; i += 16)
- {
- str.Format(_T("%04x:"), i);
-
- for(ptrdiff_t k = i, l = min(i + 16, (int)cbFormat); k < l; k++)
- {
- CString byte;
- byte.Format(_T("%c%02x"), fmtsize > 0 && fmtsize == k ? '|' : ' ', pbFormat[k]);
- str += byte;
- }
-
- for(ptrdiff_t k = min(i + 16, (int)cbFormat), l = i + 16; k < l; k++)
- {
- str += _T(" ");
- }
-
- str += ' ';
-
- for(ptrdiff_t k = i, l = min(i + 16, (int)cbFormat); k < l; k++)
- {
- unsigned char c = (unsigned char)pbFormat[k];
- CStringA ch;
- ch.Format("%c", c >= 0x20 ? c : '.');
- str += ch;
- }
-
- sl.AddTail(str);
- }
-
- sl.AddTail(_T(""));
+ CString str;
+
+ sl.RemoveAll();
+
+ int fmtsize = 0;
+
+ CString major = CStringFromGUID(majortype);
+ CString sub = CStringFromGUID(subtype);
+ CString format = CStringFromGUID(formattype);
+
+ sl.AddTail(ToString() + _T("\n"));
+
+ sl.AddTail(_T("AM_MEDIA_TYPE: "));
+ str.Format(_T("majortype: %s %s"), CString(GuidNames[majortype]), major);
+ sl.AddTail(str);
+ str.Format(_T("subtype: %s %s"), CString(GuidNames[subtype]), sub);
+ sl.AddTail(str);
+ str.Format(_T("formattype: %s %s"), CString(GuidNames[formattype]), format);
+ sl.AddTail(str);
+ str.Format(_T("bFixedSizeSamples: %d"), bFixedSizeSamples);
+ sl.AddTail(str);
+ str.Format(_T("bTemporalCompression: %d"), bTemporalCompression);
+ sl.AddTail(str);
+ str.Format(_T("lSampleSize: %d"), lSampleSize);
+ sl.AddTail(str);
+ str.Format(_T("cbFormat: %d"), cbFormat);
+ sl.AddTail(str);
+
+ sl.AddTail(_T(""));
+
+ if(formattype == FORMAT_VideoInfo || formattype == FORMAT_VideoInfo2
+ || formattype == FORMAT_MPEGVideo || formattype == FORMAT_MPEG2_VIDEO)
+ {
+ fmtsize =
+ formattype == FORMAT_VideoInfo ? sizeof(VIDEOINFOHEADER) :
+ formattype == FORMAT_VideoInfo2 ? sizeof(VIDEOINFOHEADER2) :
+ formattype == FORMAT_MPEGVideo ? sizeof(MPEG1VIDEOINFO)-1 :
+ formattype == FORMAT_MPEG2_VIDEO ? sizeof(MPEG2VIDEOINFO)-4 :
+ 0;
+
+ VIDEOINFOHEADER& vih = *(VIDEOINFOHEADER*)pbFormat;
+ BITMAPINFOHEADER* bih = &vih.bmiHeader;
+
+ sl.AddTail(_T("VIDEOINFOHEADER:"));
+ str.Format(_T("rcSource: (%d,%d)-(%d,%d)"), vih.rcSource.left, vih.rcSource.top, vih.rcSource.right, vih.rcSource.bottom);
+ sl.AddTail(str);
+ str.Format(_T("rcTarget: (%d,%d)-(%d,%d)"), vih.rcTarget.left, vih.rcTarget.top, vih.rcTarget.right, vih.rcTarget.bottom);
+ sl.AddTail(str);
+ str.Format(_T("dwBitRate: %d"), vih.dwBitRate);
+ sl.AddTail(str);
+ str.Format(_T("dwBitErrorRate: %d"), vih.dwBitErrorRate);
+ sl.AddTail(str);
+ str.Format(_T("AvgTimePerFrame: %I64d"), vih.AvgTimePerFrame);
+ sl.AddTail(str);
+
+ sl.AddTail(_T(""));
+
+ if(formattype == FORMAT_VideoInfo2 || formattype == FORMAT_MPEG2_VIDEO)
+ {
+ VIDEOINFOHEADER2& vih = *(VIDEOINFOHEADER2*)pbFormat;
+ bih = &vih.bmiHeader;
+
+ sl.AddTail(_T("VIDEOINFOHEADER2:"));
+ str.Format(_T("dwInterlaceFlags: 0x%08x"), vih.dwInterlaceFlags);
+ sl.AddTail(str);
+ str.Format(_T("dwCopyProtectFlags: 0x%08x"), vih.dwCopyProtectFlags);
+ sl.AddTail(str);
+ str.Format(_T("dwPictAspectRatioX: %d"), vih.dwPictAspectRatioX);
+ sl.AddTail(str);
+ str.Format(_T("dwPictAspectRatioY: %d"), vih.dwPictAspectRatioY);
+ sl.AddTail(str);
+ str.Format(_T("dwControlFlags: 0x%08x"), vih.dwControlFlags);
+ sl.AddTail(str);
+ str.Format(_T("dwReserved2: 0x%08x"), vih.dwReserved2);
+ sl.AddTail(str);
+
+ sl.AddTail(_T(""));
+ }
+
+ if(formattype == FORMAT_MPEGVideo)
+ {
+ MPEG1VIDEOINFO& mvih = *(MPEG1VIDEOINFO*)pbFormat;
+
+ sl.AddTail(_T("MPEG1VIDEOINFO:"));
+ str.Format(_T("dwStartTimeCode: %d"), mvih.dwStartTimeCode);
+ sl.AddTail(str);
+ str.Format(_T("cbSequenceHeader: %d"), mvih.cbSequenceHeader);
+ sl.AddTail(str);
+
+ sl.AddTail(_T(""));
+ }
+ else if(formattype == FORMAT_MPEG2_VIDEO)
+ {
+ MPEG2VIDEOINFO& mvih = *(MPEG2VIDEOINFO*)pbFormat;
+
+ sl.AddTail(_T("MPEG2VIDEOINFO:"));
+ str.Format(_T("dwStartTimeCode: %d"), mvih.dwStartTimeCode);
+ sl.AddTail(str);
+ str.Format(_T("cbSequenceHeader: %d"), mvih.cbSequenceHeader);
+ sl.AddTail(str);
+ str.Format(_T("dwProfile: 0x%08x"), mvih.dwProfile);
+ sl.AddTail(str);
+ str.Format(_T("dwLevel: 0x%08x"), mvih.dwLevel);
+ sl.AddTail(str);
+ str.Format(_T("dwFlags: 0x%08x"), mvih.dwFlags);
+ sl.AddTail(str);
+
+ sl.AddTail(_T(""));
+ }
+
+ sl.AddTail(_T("BITMAPINFOHEADER:"));
+ str.Format(_T("biSize: %d"), bih->biSize);
+ sl.AddTail(str);
+ str.Format(_T("biWidth: %d"), bih->biWidth);
+ sl.AddTail(str);
+ str.Format(_T("biHeight: %d"), bih->biHeight);
+ sl.AddTail(str);
+ str.Format(_T("biPlanes: %d"), bih->biPlanes);
+ sl.AddTail(str);
+ str.Format(_T("biBitCount: %d"), bih->biBitCount);
+ sl.AddTail(str);
+ if(bih->biCompression < 256) str.Format(_T("biCompression: %d"), bih->biCompression);
+ else str.Format(_T("biCompression: %4.4hs"), &bih->biCompression);
+ sl.AddTail(str);
+ str.Format(_T("biSizeImage: %d"), bih->biSizeImage);
+ sl.AddTail(str);
+ str.Format(_T("biXPelsPerMeter: %d"), bih->biXPelsPerMeter);
+ sl.AddTail(str);
+ str.Format(_T("biYPelsPerMeter: %d"), bih->biYPelsPerMeter);
+ sl.AddTail(str);
+ str.Format(_T("biClrUsed: %d"), bih->biClrUsed);
+ sl.AddTail(str);
+ str.Format(_T("biClrImportant: %d"), bih->biClrImportant);
+ sl.AddTail(str);
+
+ sl.AddTail(_T(""));
}
+ else if(formattype == FORMAT_WaveFormatEx)
+ {
+ fmtsize = sizeof(WAVEFORMATEX);
+
+ WAVEFORMATEX& wfe = *(WAVEFORMATEX*)pbFormat;
+
+ sl.AddTail(_T("WAVEFORMATEX:"));
+ str.Format(_T("wFormatTag: 0x%04x"), wfe.wFormatTag);
+ sl.AddTail(str);
+ str.Format(_T("nChannels: %d"), wfe.nChannels);
+ sl.AddTail(str);
+ str.Format(_T("nSamplesPerSec: %d"), wfe.nSamplesPerSec);
+ sl.AddTail(str);
+ str.Format(_T("nAvgBytesPerSec: %d"), wfe.nAvgBytesPerSec);
+ sl.AddTail(str);
+ str.Format(_T("nBlockAlign: %d"), wfe.nBlockAlign);
+ sl.AddTail(str);
+ str.Format(_T("wBitsPerSample: %d"), wfe.wBitsPerSample);
+ sl.AddTail(str);
+ str.Format(_T("cbSize: %d (extra bytes)"), wfe.cbSize);
+ sl.AddTail(str);
+
+ sl.AddTail(_T(""));
+
+ if(wfe.wFormatTag != WAVE_FORMAT_PCM && wfe.cbSize > 0)
+ {
+ if(wfe.wFormatTag == WAVE_FORMAT_EXTENSIBLE && wfe.cbSize == sizeof(WAVEFORMATEXTENSIBLE)-sizeof(WAVEFORMATEX))
+ {
+ fmtsize = sizeof(WAVEFORMATEXTENSIBLE);
+
+ WAVEFORMATEXTENSIBLE& wfe = *(WAVEFORMATEXTENSIBLE*)pbFormat;
+
+ sl.AddTail(_T("WAVEFORMATEXTENSIBLE:"));
+ if(wfe.Format.wBitsPerSample != 0) str.Format(_T("wValidBitsPerSample: %d"), wfe.Samples.wValidBitsPerSample);
+ else str.Format(_T("wSamplesPerBlock: %d"), wfe.Samples.wSamplesPerBlock);
+ sl.AddTail(str);
+ str.Format(_T("dwChannelMask: 0x%08x"), wfe.dwChannelMask);
+ sl.AddTail(str);
+ str.Format(_T("SubFormat: %s"), CStringFromGUID(wfe.SubFormat));
+ sl.AddTail(str);
+
+ sl.AddTail(_T(""));
+ }
+ else if(wfe.wFormatTag == WAVE_FORMAT_DOLBY_AC3 && wfe.cbSize == sizeof(DOLBYAC3WAVEFORMAT)-sizeof(WAVEFORMATEX))
+ {
+ fmtsize = sizeof(DOLBYAC3WAVEFORMAT);
+
+ DOLBYAC3WAVEFORMAT& wfe = *(DOLBYAC3WAVEFORMAT*)pbFormat;
+
+ sl.AddTail(_T("DOLBYAC3WAVEFORMAT:"));
+ str.Format(_T("bBigEndian: %d"), wfe.bBigEndian);
+ sl.AddTail(str);
+ str.Format(_T("bsid: %d"), wfe.bsid);
+ sl.AddTail(str);
+ str.Format(_T("lfeon: %d"), wfe.lfeon);
+ sl.AddTail(str);
+ str.Format(_T("copyrightb: %d"), wfe.copyrightb);
+ sl.AddTail(str);
+ str.Format(_T("nAuxBitsCode: %d"), wfe.nAuxBitsCode);
+ sl.AddTail(str);
+
+ sl.AddTail(_T(""));
+ }
+ }
+ }
+ else if(formattype == FORMAT_VorbisFormat)
+ {
+ fmtsize = sizeof(VORBISFORMAT);
+
+ VORBISFORMAT& vf = *(VORBISFORMAT*)pbFormat;
+
+ sl.AddTail(_T("VORBISFORMAT:"));
+ str.Format(_T("nChannels: %d"), vf.nChannels);
+ sl.AddTail(str);
+ str.Format(_T("nSamplesPerSec: %d"), vf.nSamplesPerSec);
+ sl.AddTail(str);
+ str.Format(_T("nMinBitsPerSec: %d"), vf.nMinBitsPerSec);
+ sl.AddTail(str);
+ str.Format(_T("nAvgBitsPerSec: %d"), vf.nAvgBitsPerSec);
+ sl.AddTail(str);
+ str.Format(_T("nMaxBitsPerSec: %d"), vf.nMaxBitsPerSec);
+ sl.AddTail(str);
+ str.Format(_T("fQuality: %.3f"), vf.fQuality);
+ sl.AddTail(str);
+
+ sl.AddTail(_T(""));
+ }
+ else if(formattype == FORMAT_VorbisFormat2)
+ {
+ fmtsize = sizeof(VORBISFORMAT2);
+
+ VORBISFORMAT2& vf = *(VORBISFORMAT2*)pbFormat;
+
+ sl.AddTail(_T("VORBISFORMAT:"));
+ str.Format(_T("Channels: %d"), vf.Channels);
+ sl.AddTail(str);
+ str.Format(_T("SamplesPerSec: %d"), vf.SamplesPerSec);
+ sl.AddTail(str);
+ str.Format(_T("BitsPerSample: %d"), vf.BitsPerSample);
+ sl.AddTail(str);
+ str.Format(_T("HeaderSize: {%d, %d, %d}"), vf.HeaderSize[0], vf.HeaderSize[1], vf.HeaderSize[2]);
+ sl.AddTail(str);
+
+ sl.AddTail(_T(""));
+ }
+ else if(formattype == FORMAT_SubtitleInfo)
+ {
+ fmtsize = sizeof(SUBTITLEINFO);
+
+ SUBTITLEINFO& si = *(SUBTITLEINFO*)pbFormat;
+
+ sl.AddTail(_T("SUBTITLEINFO:"));
+ str.Format(_T("dwOffset: %d"), si.dwOffset);
+ sl.AddTail(str);
+ str.Format(_T("IsoLang: %s"), CString(CStringA(si.IsoLang, sizeof(si.IsoLang)-1)));
+ sl.AddTail(str);
+ str.Format(_T("TrackName: %s"), CString(CStringW(si.TrackName, sizeof(si.TrackName)-1)));
+ sl.AddTail(str);
+
+ sl.AddTail(_T(""));
+ }
+
+ if(cbFormat > 0)
+ {
+ sl.AddTail(_T("pbFormat:"));
+
+ for(ptrdiff_t i = 0, j = (cbFormat + 15) & ~15; i < j; i += 16)
+ {
+ str.Format(_T("%04x:"), i);
+
+ for(ptrdiff_t k = i, l = min(i + 16, (int)cbFormat); k < l; k++)
+ {
+ CString byte;
+ byte.Format(_T("%c%02x"), fmtsize > 0 && fmtsize == k ? '|' : ' ', pbFormat[k]);
+ str += byte;
+ }
+
+ for(ptrdiff_t k = min(i + 16, (int)cbFormat), l = i + 16; k < l; k++)
+ {
+ str += _T(" ");
+ }
+
+ str += ' ';
+
+ for(ptrdiff_t k = i, l = min(i + 16, (int)cbFormat); k < l; k++)
+ {
+ unsigned char c = (unsigned char)pbFormat[k];
+ CStringA ch;
+ ch.Format("%c", c >= 0x20 ? c : '.');
+ str += ch;
+ }
+
+ sl.AddTail(str);
+ }
+
+ sl.AddTail(_T(""));
+ }
}
diff --git a/src/DSUtil/MediaTypeEx.h b/src/DSUtil/MediaTypeEx.h index 72b104395..a066136d0 100644 --- a/src/DSUtil/MediaTypeEx.h +++ b/src/DSUtil/MediaTypeEx.h @@ -3,17 +3,14 @@ class CMediaTypeEx : public CMediaType
{
public:
- CMediaTypeEx();
- CMediaTypeEx(const CMediaType& mt)
- {
- CMediaType::operator = (mt);
- }
+ CMediaTypeEx();
+ CMediaTypeEx(const CMediaType& mt) {CMediaType::operator = (mt);}
- CString ToString(IPin* pPin = NULL);
+ CString ToString(IPin* pPin = NULL);
- static CString GetVideoCodecName(const GUID& subtype, DWORD biCompression);
- static CString GetAudioCodecName(const GUID& subtype, WORD wFormatTag);
- static CString GetSubtitleCodecName(const GUID& subtype);
+ static CString GetVideoCodecName(const GUID& subtype, DWORD biCompression);
+ static CString GetAudioCodecName(const GUID& subtype, WORD wFormatTag);
+ static CString GetSubtitleCodecName(const GUID& subtype);
- void Dump(CAtlList<CString>& sl);
+ void Dump(CAtlList<CString>& sl);
};
diff --git a/src/DSUtil/MediaTypes.cpp b/src/DSUtil/MediaTypes.cpp index 6c9c80d15..47a45c607 100644 --- a/src/DSUtil/MediaTypes.cpp +++ b/src/DSUtil/MediaTypes.cpp @@ -1,4 +1,4 @@ -/*
+/*
* Copyright (C) 2003-2006 Gabest
* http://www.gabest.org
*
@@ -6,15 +6,15 @@ * it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
- *
+ *
* This Program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with GNU Make; see the file COPYING. If not, write to
- * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
+ * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
* http://www.gnu.org/copyleft/gpl.html
*
*/
@@ -33,349 +33,349 @@ VIH vihs[] =
{
- // YUY2
- {
- {
- {0, 0, 0, 0}, {0, 0, 0, 0}, 0, 0, 0,
- {BIH_SIZE, 0, 0, 1, 16, mmioFOURCC('Y', 'U', 'Y', '2'), 0, 0, 0, 0, 0} // bmiHeader
- },
- {0, 0, 0}, // mask[3]
- VIH_NORMAL, // size
- &MEDIASUBTYPE_YUY2 // subtype
- },
- // YV12
- {
- {
- {0, 0, 0, 0}, {0, 0, 0, 0}, 0, 0, 0,
- {BIH_SIZE, 0, 0, 1, 12, mmioFOURCC('Y', 'V', '1', '2'), 0, 0, 0, 0, 0} // bmiHeader
- },
- {0, 0, 0}, // mask[3]
- VIH_NORMAL, // size
- &MEDIASUBTYPE_YV12 // subtype
- },
- // I420
- {
- {
- {0, 0, 0, 0}, {0, 0, 0, 0}, 0, 0, 0,
- {BIH_SIZE, 0, 0, 1, 12, mmioFOURCC('I', '4', '2', '0'), 0, 0, 0, 0, 0} // bmiHeader
- },
- {0, 0, 0}, // mask[3]
- VIH_NORMAL, // size
- &MEDIASUBTYPE_I420 // subtype
- },
- // IYUV
- {
- {
- {0, 0, 0, 0}, {0, 0, 0, 0}, 0, 0, 0,
- {BIH_SIZE, 0, 0, 1, 12, mmioFOURCC('I', 'Y', 'U', 'V'), 0, 0, 0, 0, 0} // bmiHeader
- },
- {0, 0, 0}, // mask[3]
- VIH_NORMAL, // size
- &MEDIASUBTYPE_IYUV // subtype
- },
- // 8888 normal
- {
- {
- {0, 0, 0, 0}, {0, 0, 0, 0}, 0, 0, 0,
- {BIH_SIZE, 0, 0, 1, 32, BI_RGB, 0, 0, 0, 0, 0} // bmiHeader
- },
- {0, 0, 0}, // mask[3]
- VIH_NORMAL, // size
- &MEDIASUBTYPE_RGB32 // subtype
- },
- // 8888 bitf
- {
- {
- {0, 0, 0, 0}, {0, 0, 0, 0}, 0, 0, 0,
- {BIH_SIZE, 0, 0, 1, 32, BI_BITFIELDS, 0, 0, 0, 0, 0} // bmiHeader
- },
- {0xFF0000, 0x00FF00, 0x0000FF}, // mask[3]
- VIH_BITFIELDS, // size
- &MEDIASUBTYPE_RGB32 // subtype
- },
- // A888 normal
- {
- {
- {0, 0, 0, 0}, {0, 0, 0, 0}, 0, 0, 0,
- {BIH_SIZE, 0, 0, 1, 32, BI_RGB, 0, 0, 0, 0, 0} // bmiHeader
- },
- {0, 0, 0}, // mask[3]
- VIH_NORMAL, // size
- &MEDIASUBTYPE_ARGB32 // subtype
- },
- // A888 bitf (I'm not sure if this exist...)
- {
- {
- {0, 0, 0, 0}, {0, 0, 0, 0}, 0, 0, 0,
- {BIH_SIZE, 0, 0, 1, 32, BI_BITFIELDS, 0, 0, 0, 0, 0} // bmiHeader
- },
- {0xFF0000, 0x00FF00, 0x0000FF}, // mask[3]
- VIH_BITFIELDS, // size
- &MEDIASUBTYPE_ARGB32 // subtype
- },
- // 888 normal
- {
- {
- {0, 0, 0, 0}, {0, 0, 0, 0}, 0, 0, 0,
- {BIH_SIZE, 0, 0, 1, 24, BI_RGB, 0, 0, 0, 0, 0} // bmiHeader
- },
- {0, 0, 0}, // mask[3]
- VIH_NORMAL, // size
- &MEDIASUBTYPE_RGB24 // subtype
- },
- // 888 bitf
- {
- {
- {0, 0, 0, 0}, {0, 0, 0, 0}, 0, 0, 0,
- {BIH_SIZE, 0, 0, 1, 24, BI_BITFIELDS, 0, 0, 0, 0, 0} // bmiHeader
- },
- {0xFF0000, 0x00FF00, 0x0000FF}, // mask[3]
- VIH_BITFIELDS, // size
- &MEDIASUBTYPE_RGB24 // subtype
- },
- // 565 normal
- {
- {
- {0, 0, 0, 0}, {0, 0, 0, 0}, 0, 0, 0,
- {BIH_SIZE, 0, 0, 1, 16, BI_RGB, 0, 0, 0, 0, 0} // bmiHeader
- },
- {0, 0, 0}, // mask[3]
- VIH_NORMAL, // size
- &MEDIASUBTYPE_RGB565 // subtype
- },
- // 565 bitf
- {
- {
- {0, 0, 0, 0}, {0, 0, 0, 0}, 0, 0, 0,
- {BIH_SIZE, 0, 0, 1, 16, BI_BITFIELDS, 0, 0, 0, 0, 0} // bmiHeader
- },
- {0xF800, 0x07E0, 0x001F}, // mask[3]
- VIH_BITFIELDS, // size
- &MEDIASUBTYPE_RGB565 // subtype
- },
- // 555 normal
- {
- {
- {0, 0, 0, 0}, {0, 0, 0, 0}, 0, 0, 0,
- {BIH_SIZE, 0, 0, 1, 16, BI_RGB, 0, 0, 0, 0, 0} // bmiHeader
- },
- {0, 0, 0}, // mask[3]
- VIH_NORMAL, // size
- &MEDIASUBTYPE_RGB555 // subtype
- },
- // 555 bitf
- {
- {
- {0, 0, 0, 0}, {0, 0, 0, 0}, 0, 0, 0,
- {BIH_SIZE, 0, 0, 1, 16, BI_BITFIELDS, 0, 0, 0, 0, 0} // bmiHeader
- },
- {0x7C00, 0x03E0, 0x001F}, // mask[3]
- VIH_BITFIELDS, // size
- &MEDIASUBTYPE_RGB555 // subtype
- },
+ // YUY2
+ {
+ {
+ {0, 0, 0, 0}, {0, 0, 0, 0}, 0, 0, 0,
+ {BIH_SIZE, 0, 0, 1, 16, mmioFOURCC('Y','U','Y','2'), 0, 0, 0, 0, 0} // bmiHeader
+ },
+ {0, 0, 0}, // mask[3]
+ VIH_NORMAL, // size
+ &MEDIASUBTYPE_YUY2 // subtype
+ },
+ // YV12
+ {
+ {
+ {0, 0, 0, 0}, {0, 0, 0, 0}, 0, 0, 0,
+ {BIH_SIZE, 0, 0, 1, 12, mmioFOURCC('Y','V','1','2'), 0, 0, 0, 0, 0} // bmiHeader
+ },
+ {0, 0, 0}, // mask[3]
+ VIH_NORMAL, // size
+ &MEDIASUBTYPE_YV12 // subtype
+ },
+ // I420
+ {
+ {
+ {0, 0, 0, 0}, {0, 0, 0, 0}, 0, 0, 0,
+ {BIH_SIZE, 0, 0, 1, 12, mmioFOURCC('I','4','2','0'), 0, 0, 0, 0, 0} // bmiHeader
+ },
+ {0, 0, 0}, // mask[3]
+ VIH_NORMAL, // size
+ &MEDIASUBTYPE_I420 // subtype
+ },
+ // IYUV
+ {
+ {
+ {0, 0, 0, 0}, {0, 0, 0, 0}, 0, 0, 0,
+ {BIH_SIZE, 0, 0, 1, 12, mmioFOURCC('I','Y','U','V'), 0, 0, 0, 0, 0} // bmiHeader
+ },
+ {0, 0, 0}, // mask[3]
+ VIH_NORMAL, // size
+ &MEDIASUBTYPE_IYUV // subtype
+ },
+ // 8888 normal
+ {
+ {
+ {0, 0, 0, 0}, {0, 0, 0, 0}, 0, 0, 0,
+ {BIH_SIZE, 0, 0, 1, 32, BI_RGB, 0, 0, 0, 0, 0} // bmiHeader
+ },
+ {0, 0, 0}, // mask[3]
+ VIH_NORMAL, // size
+ &MEDIASUBTYPE_RGB32 // subtype
+ },
+ // 8888 bitf
+ {
+ {
+ {0, 0, 0, 0}, {0, 0, 0, 0}, 0, 0, 0,
+ {BIH_SIZE, 0, 0, 1, 32, BI_BITFIELDS, 0, 0, 0, 0, 0} // bmiHeader
+ },
+ {0xFF0000, 0x00FF00, 0x0000FF}, // mask[3]
+ VIH_BITFIELDS, // size
+ &MEDIASUBTYPE_RGB32 // subtype
+ },
+ // A888 normal
+ {
+ {
+ {0, 0, 0, 0}, {0, 0, 0, 0}, 0, 0, 0,
+ {BIH_SIZE, 0, 0, 1, 32, BI_RGB, 0, 0, 0, 0, 0} // bmiHeader
+ },
+ {0, 0, 0}, // mask[3]
+ VIH_NORMAL, // size
+ &MEDIASUBTYPE_ARGB32 // subtype
+ },
+ // A888 bitf (I'm not sure if this exist...)
+ {
+ {
+ {0, 0, 0, 0}, {0, 0, 0, 0}, 0, 0, 0,
+ {BIH_SIZE, 0, 0, 1, 32, BI_BITFIELDS, 0, 0, 0, 0, 0} // bmiHeader
+ },
+ {0xFF0000, 0x00FF00, 0x0000FF}, // mask[3]
+ VIH_BITFIELDS, // size
+ &MEDIASUBTYPE_ARGB32 // subtype
+ },
+ // 888 normal
+ {
+ {
+ {0, 0, 0, 0}, {0, 0, 0, 0}, 0, 0, 0,
+ {BIH_SIZE, 0, 0, 1, 24, BI_RGB, 0, 0, 0, 0, 0} // bmiHeader
+ },
+ {0, 0, 0}, // mask[3]
+ VIH_NORMAL, // size
+ &MEDIASUBTYPE_RGB24 // subtype
+ },
+ // 888 bitf
+ {
+ {
+ {0, 0, 0, 0}, {0, 0, 0, 0}, 0, 0, 0,
+ {BIH_SIZE, 0, 0, 1, 24, BI_BITFIELDS, 0, 0, 0, 0, 0} // bmiHeader
+ },
+ {0xFF0000, 0x00FF00, 0x0000FF}, // mask[3]
+ VIH_BITFIELDS, // size
+ &MEDIASUBTYPE_RGB24 // subtype
+ },
+ // 565 normal
+ {
+ {
+ {0, 0, 0, 0}, {0, 0, 0, 0}, 0, 0, 0,
+ {BIH_SIZE, 0, 0, 1, 16, BI_RGB, 0, 0, 0, 0, 0} // bmiHeader
+ },
+ {0, 0, 0}, // mask[3]
+ VIH_NORMAL, // size
+ &MEDIASUBTYPE_RGB565 // subtype
+ },
+ // 565 bitf
+ {
+ {
+ {0, 0, 0, 0}, {0, 0, 0, 0}, 0, 0, 0,
+ {BIH_SIZE, 0, 0, 1, 16, BI_BITFIELDS, 0, 0, 0, 0, 0} // bmiHeader
+ },
+ {0xF800, 0x07E0, 0x001F}, // mask[3]
+ VIH_BITFIELDS, // size
+ &MEDIASUBTYPE_RGB565 // subtype
+ },
+ // 555 normal
+ {
+ {
+ {0, 0, 0, 0}, {0, 0, 0, 0}, 0, 0, 0,
+ {BIH_SIZE, 0, 0, 1, 16, BI_RGB, 0, 0, 0, 0, 0} // bmiHeader
+ },
+ {0, 0, 0}, // mask[3]
+ VIH_NORMAL, // size
+ &MEDIASUBTYPE_RGB555 // subtype
+ },
+ // 555 bitf
+ {
+ {
+ {0, 0, 0, 0}, {0, 0, 0, 0}, 0, 0, 0,
+ {BIH_SIZE, 0, 0, 1, 16, BI_BITFIELDS, 0, 0, 0, 0, 0} // bmiHeader
+ },
+ {0x7C00, 0x03E0, 0x001F}, // mask[3]
+ VIH_BITFIELDS, // size
+ &MEDIASUBTYPE_RGB555 // subtype
+ },
};
VIH2 vih2s[] =
{
- // YUY2
- {
- {
- {0, 0, 0, 0}, {0, 0, 0, 0}, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- {BIH_SIZE, 0, 0, 1, 16, mmioFOURCC('Y', 'U', 'Y', '2'), 0, 0, 0, 0, 0} // bmiHeader
- },
- {0, 0, 0}, // mask[3]
- VIH2_NORMAL, // size
- &MEDIASUBTYPE_YUY2 // subtype
- },
- // YV12
- {
- {
- {0, 0, 0, 0}, {0, 0, 0, 0}, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- {BIH_SIZE, 0, 0, 1, 12, mmioFOURCC('Y', 'V', '1', '2'), 0, 0, 0, 0, 0} // bmiHeader
- },
- {0, 0, 0}, // mask[3]
- VIH2_NORMAL, // size
- &MEDIASUBTYPE_YV12 // subtype
- },
- // I420
- {
- {
- {0, 0, 0, 0}, {0, 0, 0, 0}, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- {BIH_SIZE, 0, 0, 1, 12, mmioFOURCC('I', '4', '2', '0'), 0, 0, 0, 0, 0} // bmiHeader
- },
- {0, 0, 0}, // mask[3]
- VIH2_NORMAL, // size
- &MEDIASUBTYPE_I420 // subtype
- },
- // IYUV
- {
- {
- {0, 0, 0, 0}, {0, 0, 0, 0}, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- {BIH_SIZE, 0, 0, 1, 12, mmioFOURCC('I', 'Y', 'U', 'V'), 0, 0, 0, 0, 0} // bmiHeader
- },
- {0, 0, 0}, // mask[3]
- VIH2_NORMAL, // size
- &MEDIASUBTYPE_IYUV // subtype
- },
- // 8888 normal
- {
- {
- {0, 0, 0, 0}, {0, 0, 0, 0}, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- {BIH_SIZE, 0, 0, 1, 32, BI_RGB, 0, 0, 0, 0, 0} // bmiHeader
- },
- {0, 0, 0}, // mask[3]
- VIH2_NORMAL, // size
- &MEDIASUBTYPE_RGB32 // subtype
- },
- // 8888 bitf
- {
- {
- {0, 0, 0, 0}, {0, 0, 0, 0}, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- {BIH_SIZE, 0, 0, 1, 32, BI_BITFIELDS, 0, 0, 0, 0, 0} // bmiHeader
- },
- {0xFF0000, 0x00FF00, 0x0000FF}, // mask[3]
- VIH2_BITFIELDS, // size
- &MEDIASUBTYPE_RGB32 // subtype
- },
- // A888 normal
- {
- {
- {0, 0, 0, 0}, {0, 0, 0, 0}, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- {BIH_SIZE, 0, 0, 1, 32, BI_RGB, 0, 0, 0, 0, 0} // bmiHeader
- },
- {0, 0, 0}, // mask[3]
- VIH2_NORMAL, // size
- &MEDIASUBTYPE_ARGB32 // subtype
- },
- // A888 bitf (I'm not sure if this exist...)
- {
- {
- {0, 0, 0, 0}, {0, 0, 0, 0}, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- {BIH_SIZE, 0, 0, 1, 32, BI_BITFIELDS, 0, 0, 0, 0, 0} // bmiHeader
- },
- {0xFF0000, 0x00FF00, 0x0000FF}, // mask[3]
- VIH2_BITFIELDS, // size
- &MEDIASUBTYPE_ARGB32 // subtype
- },
- // 888 normal
- {
- {
- {0, 0, 0, 0}, {0, 0, 0, 0}, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- {BIH_SIZE, 0, 0, 1, 24, BI_RGB, 0, 0, 0, 0, 0} // bmiHeader
- },
- {0, 0, 0}, // mask[3]
- VIH2_NORMAL, // size
- &MEDIASUBTYPE_RGB24 // subtype
- },
- // 888 bitf
- {
- {
- {0, 0, 0, 0}, {0, 0, 0, 0}, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- {BIH_SIZE, 0, 0, 1, 24, BI_BITFIELDS, 0, 0, 0, 0, 0} // bmiHeader
- },
- {0xFF0000, 0x00FF00, 0x0000FF}, // mask[3]
- VIH2_BITFIELDS, // size
- &MEDIASUBTYPE_RGB24 // subtype
- },
- // 565 normal
- {
- {
- {0, 0, 0, 0}, {0, 0, 0, 0}, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- {BIH_SIZE, 0, 0, 1, 16, BI_RGB, 0, 0, 0, 0, 0} // bmiHeader
- },
- {0, 0, 0}, // mask[3]
- VIH2_NORMAL, // size
- &MEDIASUBTYPE_RGB565 // subtype
- },
- // 565 bitf
- {
- {
- {0, 0, 0, 0}, {0, 0, 0, 0}, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- {BIH_SIZE, 0, 0, 1, 16, BI_BITFIELDS, 0, 0, 0, 0, 0} // bmiHeader
- },
- {0xF800, 0x07E0, 0x001F}, // mask[3]
- VIH2_BITFIELDS, // size
- &MEDIASUBTYPE_RGB565 // subtype
- },
- // 555 normal
- {
- {
- {0, 0, 0, 0}, {0, 0, 0, 0}, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- {BIH_SIZE, 0, 0, 1, 16, BI_RGB, 0, 0, 0, 0, 0} // bmiHeader
- },
- {0, 0, 0}, // mask[3]
- VIH2_NORMAL, // size
- &MEDIASUBTYPE_RGB555 // subtype
- },
- // 555 bitf
- {
- {
- {0, 0, 0, 0}, {0, 0, 0, 0}, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- {BIH_SIZE, 0, 0, 1, 16, BI_BITFIELDS, 0, 0, 0, 0, 0} // bmiHeader
- },
- {0x7C00, 0x03E0, 0x001F}, // mask[3]
- VIH2_BITFIELDS, // size
- &MEDIASUBTYPE_RGB555 // subtype
- },
+ // YUY2
+ {
+ {
+ {0, 0, 0, 0}, {0, 0, 0, 0}, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ {BIH_SIZE, 0, 0, 1, 16, mmioFOURCC('Y','U','Y','2'), 0, 0, 0, 0, 0} // bmiHeader
+ },
+ {0, 0, 0}, // mask[3]
+ VIH2_NORMAL, // size
+ &MEDIASUBTYPE_YUY2 // subtype
+ },
+ // YV12
+ {
+ {
+ {0, 0, 0, 0}, {0, 0, 0, 0}, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ {BIH_SIZE, 0, 0, 1, 12, mmioFOURCC('Y','V','1','2'), 0, 0, 0, 0, 0} // bmiHeader
+ },
+ {0, 0, 0}, // mask[3]
+ VIH2_NORMAL, // size
+ &MEDIASUBTYPE_YV12 // subtype
+ },
+ // I420
+ {
+ {
+ {0, 0, 0, 0}, {0, 0, 0, 0}, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ {BIH_SIZE, 0, 0, 1, 12, mmioFOURCC('I','4','2','0'), 0, 0, 0, 0, 0} // bmiHeader
+ },
+ {0, 0, 0}, // mask[3]
+ VIH2_NORMAL, // size
+ &MEDIASUBTYPE_I420 // subtype
+ },
+ // IYUV
+ {
+ {
+ {0, 0, 0, 0}, {0, 0, 0, 0}, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ {BIH_SIZE, 0, 0, 1, 12, mmioFOURCC('I','Y','U','V'), 0, 0, 0, 0, 0} // bmiHeader
+ },
+ {0, 0, 0}, // mask[3]
+ VIH2_NORMAL, // size
+ &MEDIASUBTYPE_IYUV // subtype
+ },
+ // 8888 normal
+ {
+ {
+ {0, 0, 0, 0}, {0, 0, 0, 0}, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ {BIH_SIZE, 0, 0, 1, 32, BI_RGB, 0, 0, 0, 0, 0} // bmiHeader
+ },
+ {0, 0, 0}, // mask[3]
+ VIH2_NORMAL, // size
+ &MEDIASUBTYPE_RGB32 // subtype
+ },
+ // 8888 bitf
+ {
+ {
+ {0, 0, 0, 0}, {0, 0, 0, 0}, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ {BIH_SIZE, 0, 0, 1, 32, BI_BITFIELDS, 0, 0, 0, 0, 0} // bmiHeader
+ },
+ {0xFF0000, 0x00FF00, 0x0000FF}, // mask[3]
+ VIH2_BITFIELDS, // size
+ &MEDIASUBTYPE_RGB32 // subtype
+ },
+ // A888 normal
+ {
+ {
+ {0, 0, 0, 0}, {0, 0, 0, 0}, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ {BIH_SIZE, 0, 0, 1, 32, BI_RGB, 0, 0, 0, 0, 0} // bmiHeader
+ },
+ {0, 0, 0}, // mask[3]
+ VIH2_NORMAL, // size
+ &MEDIASUBTYPE_ARGB32 // subtype
+ },
+ // A888 bitf (I'm not sure if this exist...)
+ {
+ {
+ {0, 0, 0, 0}, {0, 0, 0, 0}, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ {BIH_SIZE, 0, 0, 1, 32, BI_BITFIELDS, 0, 0, 0, 0, 0} // bmiHeader
+ },
+ {0xFF0000, 0x00FF00, 0x0000FF}, // mask[3]
+ VIH2_BITFIELDS, // size
+ &MEDIASUBTYPE_ARGB32 // subtype
+ },
+ // 888 normal
+ {
+ {
+ {0, 0, 0, 0}, {0, 0, 0, 0}, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ {BIH_SIZE, 0, 0, 1, 24, BI_RGB, 0, 0, 0, 0, 0} // bmiHeader
+ },
+ {0, 0, 0}, // mask[3]
+ VIH2_NORMAL, // size
+ &MEDIASUBTYPE_RGB24 // subtype
+ },
+ // 888 bitf
+ {
+ {
+ {0, 0, 0, 0}, {0, 0, 0, 0}, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ {BIH_SIZE, 0, 0, 1, 24, BI_BITFIELDS, 0, 0, 0, 0, 0} // bmiHeader
+ },
+ {0xFF0000, 0x00FF00, 0x0000FF}, // mask[3]
+ VIH2_BITFIELDS, // size
+ &MEDIASUBTYPE_RGB24 // subtype
+ },
+ // 565 normal
+ {
+ {
+ {0, 0, 0, 0}, {0, 0, 0, 0}, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ {BIH_SIZE, 0, 0, 1, 16, BI_RGB, 0, 0, 0, 0, 0} // bmiHeader
+ },
+ {0, 0, 0}, // mask[3]
+ VIH2_NORMAL, // size
+ &MEDIASUBTYPE_RGB565 // subtype
+ },
+ // 565 bitf
+ {
+ {
+ {0, 0, 0, 0}, {0, 0, 0, 0}, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ {BIH_SIZE, 0, 0, 1, 16, BI_BITFIELDS, 0, 0, 0, 0, 0} // bmiHeader
+ },
+ {0xF800, 0x07E0, 0x001F}, // mask[3]
+ VIH2_BITFIELDS, // size
+ &MEDIASUBTYPE_RGB565 // subtype
+ },
+ // 555 normal
+ {
+ {
+ {0, 0, 0, 0}, {0, 0, 0, 0}, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ {BIH_SIZE, 0, 0, 1, 16, BI_RGB, 0, 0, 0, 0, 0} // bmiHeader
+ },
+ {0, 0, 0}, // mask[3]
+ VIH2_NORMAL, // size
+ &MEDIASUBTYPE_RGB555 // subtype
+ },
+ // 555 bitf
+ {
+ {
+ {0, 0, 0, 0}, {0, 0, 0, 0}, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ {BIH_SIZE, 0, 0, 1, 16, BI_BITFIELDS, 0, 0, 0, 0, 0} // bmiHeader
+ },
+ {0x7C00, 0x03E0, 0x001F}, // mask[3]
+ VIH2_BITFIELDS, // size
+ &MEDIASUBTYPE_RGB555 // subtype
+ },
};
int VIHSIZE = countof(vihs);
CString VIH2String(int i)
{
- CString ret = CString(GuidNames[*vihs[i].subtype]);
- if(!ret.Left(13).CompareNoCase(_T("MEDIASUBTYPE_"))) ret = ret.Mid(13);
- if(vihs[i].vih.bmiHeader.biCompression == 3) ret += _T(" BITF");
- if(*vihs[i].subtype == MEDIASUBTYPE_I420) ret = _T("I420"); // FIXME
- return(ret);
+ CString ret = CString(GuidNames[*vihs[i].subtype]);
+ if(!ret.Left(13).CompareNoCase(_T("MEDIASUBTYPE_"))) ret = ret.Mid(13);
+ if(vihs[i].vih.bmiHeader.biCompression == 3) ret += _T(" BITF");
+ if(*vihs[i].subtype == MEDIASUBTYPE_I420) ret = _T("I420"); // FIXME
+ return(ret);
}
CString Subtype2String(const GUID& subtype)
{
- CString ret = CString(GuidNames[subtype]);
- if(!ret.Left(13).CompareNoCase(_T("MEDIASUBTYPE_"))) ret = ret.Mid(13);
- if(subtype == MEDIASUBTYPE_I420) ret = _T("I420"); // FIXME
- return(ret);
+ CString ret = CString(GuidNames[subtype]);
+ if(!ret.Left(13).CompareNoCase(_T("MEDIASUBTYPE_"))) ret = ret.Mid(13);
+ if(subtype == MEDIASUBTYPE_I420) ret = _T("I420"); // FIXME
+ return(ret);
}
void CorrectMediaType(AM_MEDIA_TYPE* pmt)
{
- if(!pmt) return;
+ if(!pmt) return;
- CMediaType mt(*pmt);
+ CMediaType mt(*pmt);
- if(mt.formattype == FORMAT_VideoInfo)
- {
- VIDEOINFOHEADER* vih = (VIDEOINFOHEADER*)mt.pbFormat;
+ if(mt.formattype == FORMAT_VideoInfo)
+ {
+ VIDEOINFOHEADER* vih = (VIDEOINFOHEADER*)mt.pbFormat;
- for(ptrdiff_t i = 0; i < VIHSIZE; i++)
- {
- if(mt.subtype == *vihs[i].subtype
- && vih->bmiHeader.biCompression == vihs[i].vih.bmiHeader.biCompression)
- {
- mt.AllocFormatBuffer(vihs[i].size);
- memcpy(mt.pbFormat, &vihs[i], vihs[i].size);
- memcpy(mt.pbFormat, pmt->pbFormat, sizeof(VIDEOINFOHEADER));
- break;
- }
- }
- }
- else if(mt.formattype == FORMAT_VideoInfo2)
- {
- VIDEOINFOHEADER2* vih2 = (VIDEOINFOHEADER2*)mt.pbFormat;
+ for(ptrdiff_t i = 0; i < VIHSIZE; i++)
+ {
+ if(mt.subtype == *vihs[i].subtype
+ && vih->bmiHeader.biCompression == vihs[i].vih.bmiHeader.biCompression)
+ {
+ mt.AllocFormatBuffer(vihs[i].size);
+ memcpy(mt.pbFormat, &vihs[i], vihs[i].size);
+ memcpy(mt.pbFormat, pmt->pbFormat, sizeof(VIDEOINFOHEADER));
+ break;
+ }
+ }
+ }
+ else if(mt.formattype == FORMAT_VideoInfo2)
+ {
+ VIDEOINFOHEADER2* vih2 = (VIDEOINFOHEADER2*)mt.pbFormat;
- for(ptrdiff_t i = 0; i < VIHSIZE; i++)
- {
- if(mt.subtype == *vih2s[i].subtype
- && vih2->bmiHeader.biCompression == vih2s[i].vih.bmiHeader.biCompression)
- {
- mt.AllocFormatBuffer(vih2s[i].size);
- memcpy(mt.pbFormat, &vih2s[i], vih2s[i].size);
- memcpy(mt.pbFormat, pmt->pbFormat, sizeof(VIDEOINFOHEADER2));
- break;
- }
- }
- }
+ for(ptrdiff_t i = 0; i < VIHSIZE; i++)
+ {
+ if(mt.subtype == *vih2s[i].subtype
+ && vih2->bmiHeader.biCompression == vih2s[i].vih.bmiHeader.biCompression)
+ {
+ mt.AllocFormatBuffer(vih2s[i].size);
+ memcpy(mt.pbFormat, &vih2s[i], vih2s[i].size);
+ memcpy(mt.pbFormat, pmt->pbFormat, sizeof(VIDEOINFOHEADER2));
+ break;
+ }
+ }
+ }
- CopyMediaType(pmt, &mt);
+ CopyMediaType(pmt, &mt);
}
diff --git a/src/DSUtil/MediaTypes.h b/src/DSUtil/MediaTypes.h index caa2584e8..609191d9d 100644 --- a/src/DSUtil/MediaTypes.h +++ b/src/DSUtil/MediaTypes.h @@ -1,4 +1,4 @@ -/*
+/*
* Copyright (C) 2003-2006 Gabest
* http://www.gabest.org
*
@@ -6,15 +6,15 @@ * it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
- *
+ *
* This Program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with GNU Make; see the file COPYING. If not, write to
- * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
+ * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
* http://www.gnu.org/copyleft/gpl.html
*
*/
@@ -24,17 +24,17 @@ #pragma pack(1)
struct VIH
{
- VIDEOINFOHEADER vih;
- UINT mask[3];
- int size;
- const GUID* subtype;
+ VIDEOINFOHEADER vih;
+ UINT mask[3];
+ int size;
+ const GUID* subtype;
};
struct VIH2
{
- VIDEOINFOHEADER2 vih;
- UINT mask[3];
- int size;
- const GUID* subtype;
+ VIDEOINFOHEADER2 vih;
+ UINT mask[3];
+ int size;
+ const GUID* subtype;
};
#pragma pack()
diff --git a/src/DSUtil/Mpeg2Def.h b/src/DSUtil/Mpeg2Def.h index a2f00396f..438224a1d 100644 --- a/src/DSUtil/Mpeg2Def.h +++ b/src/DSUtil/Mpeg2Def.h @@ -1,4 +1,4 @@ -/*
+/*
* $Id: Mpeg2Def.h 1288 2009-09-27 15:50:30Z casimir666 $
*
* (C) 2006-2010 see AUTHORS
@@ -30,22 +30,22 @@ enum PES_STREAM_TYPE VIDEO_STREAM_MPEG2 = 0x02,
AUDIO_STREAM_MPEG1 = 0x03, // all layers including mp3
AUDIO_STREAM_MPEG2 = 0x04,
- PRIVATE = 0x05, // ITU-T Rec. H.222.0 | ISO/IEC 13818-1 private_sections
- PES_PRIVATE = 0x06, // ITU-T Rec. H.222.0 | ISO/IEC 13818-1 PES packets containing private data
- PES_07 = 0x07, // ISO/IEC 13522 MHEG
- PES_08 = 0x08, // ITU-T Rec. H.222.0 | ISO/IEC 13818-1 Annex A DSM-CC
- PES_09 = 0x09, // ITU-T Rec. H.222.1
- PES_0a = 0x0a, // ISO/IEC 13818-6 type A
- PES_0b = 0x0b, // ISO/IEC 13818-6 type B
- PES_0c = 0x0c, // ISO/IEC 13818-6 type C
- PES_0d = 0x0d, // ISO/IEC 13818-6 type D
- PES_0e = 0x0e, // ITU-T Rec. H.222.0 | ISO/IEC 13818-1 auxiliary
- PES_0f = 0x0f, // ISO/IEC 13818-7 Audio with ADTS transport syntax
- PES_10 = 0x10, // ISO/IEC 14496-2 Visual
- PES_11 = 0x11, // ISO/IEC 14496-3 Audio with the LATM transport syntax as defined in ISO/IEC 14496-3 / AMD 1
- PES_12 = 0x12, // ISO/IEC 14496-1 SL-packetized stream or FlexMux stream carried in PES packets
- PES_13 = 0x13, // ISO/IEC 14496-1 SL-packetized stream or FlexMux stream carried in ISO/IEC14496_sections.
- PES_14 = 0x14, // ISO/IEC 13818-6 Synchronized Download Protocol
+ PRIVATE = 0x05, // ITU-T Rec. H.222.0 | ISO/IEC 13818-1 private_sections
+ PES_PRIVATE = 0x06, // ITU-T Rec. H.222.0 | ISO/IEC 13818-1 PES packets containing private data
+ PES_07 = 0x07, // ISO/IEC 13522 MHEG
+ PES_08 = 0x08, // ITU-T Rec. H.222.0 | ISO/IEC 13818-1 Annex A DSM-CC
+ PES_09 = 0x09, // ITU-T Rec. H.222.1
+ PES_0a = 0x0a, // ISO/IEC 13818-6 type A
+ PES_0b = 0x0b, // ISO/IEC 13818-6 type B
+ PES_0c = 0x0c, // ISO/IEC 13818-6 type C
+ PES_0d = 0x0d, // ISO/IEC 13818-6 type D
+ PES_0e = 0x0e, // ITU-T Rec. H.222.0 | ISO/IEC 13818-1 auxiliary
+ PES_0f = 0x0f, // ISO/IEC 13818-7 Audio with ADTS transport syntax
+ PES_10 = 0x10, // ISO/IEC 14496-2 Visual
+ PES_11 = 0x11, // ISO/IEC 14496-3 Audio with the LATM transport syntax as defined in ISO/IEC 14496-3 / AMD 1
+ PES_12 = 0x12, // ISO/IEC 14496-1 SL-packetized stream or FlexMux stream carried in PES packets
+ PES_13 = 0x13, // ISO/IEC 14496-1 SL-packetized stream or FlexMux stream carried in ISO/IEC14496_sections.
+ PES_14 = 0x14, // ISO/IEC 13818-6 Synchronized Download Protocol
VIDEO_STREAM_H264 = 0x1b,
AUDIO_STREAM_LPCM = 0x80,
AUDIO_STREAM_AC3 = 0x81,
@@ -65,88 +65,88 @@ enum PES_STREAM_TYPE enum MPEG2_PID
{
- PID_PAT = 0x000, // Program Association Table
- PID_CAT = 0x001, // Conditional Access Table
- PID_TSDT = 0x002, // Transport Stream Description Table
- PID_NIT = 0x010, // Network Identification Table
- PID_BAT = 0x011, // Bouquet Association Table ou ...
- PID_SDT = 0x011, // Service Description Table
- PID_EIT = 0x012, // Event Information Table
- PID_RST = 0x013, // Running Status Tection
- PID_TDT = 0x014, // Time and Date Table ou ...
- PID_TOT = 0x014, // Time Offset Table
- PID_SFN = 0x015, // SFN/MIP synchronisation
- PID_DIT = 0x01e,
- PID_SIT = 0x01f,
- PID_NULL = 0x1fff // Null packet
+ PID_PAT = 0x000, // Program Association Table
+ PID_CAT = 0x001, // Conditional Access Table
+ PID_TSDT = 0x002, // Transport Stream Description Table
+ PID_NIT = 0x010, // Network Identification Table
+ PID_BAT = 0x011, // Bouquet Association Table ou ...
+ PID_SDT = 0x011, // Service Description Table
+ PID_EIT = 0x012, // Event Information Table
+ PID_RST = 0x013, // Running Status Tection
+ PID_TDT = 0x014, // Time and Date Table ou ...
+ PID_TOT = 0x014, // Time Offset Table
+ PID_SFN = 0x015, // SFN/MIP synchronisation
+ PID_DIT = 0x01e,
+ PID_SIT = 0x01f,
+ PID_NULL = 0x1fff // Null packet
};
enum DVB_SI
{
- SI_undef = -1,
- SI_PAT = 0x00,
- SI_CAT = 0x01,
- SI_PMT = 0x02,
- SI_DSMCC_a = 0x3a,
- SI_DSMCC_b = 0x3b,
- SI_DSMCC_c = 0x3c,
- SI_DSMCC_d = 0x3d,
- SI_DSMCC_e = 0x3e,
- SI_DSMCC_f = 0x3f,
- SI_NIT = 0x40,
- SI_SDT = 0x42,
- SI_EIT_act = 0x4e,
- SI_EIT_oth = 0x4f,
- SI_EIT_as0, SI_EIT_as1, SI_EIT_as2, SI_EIT_as3, SI_EIT_as4, SI_EIT_as5, SI_EIT_as6, SI_EIT_as7,
- SI_EIT_as8, SI_EIT_as9, SI_EIT_asa, SI_EIT_asb, SI_EIT_asc, SI_EIT_asd, SI_EIT_ase, SI_EIT_asf,
- SI_EIT_os0, SI_EIT_os1, SI_EIT_os2, SI_EIT_os3, SI_EIT_os4, SI_EIT_os5, SI_EIT_os6, SI_EIT_os7,
- SI_EIT_os8, SI_EIT_os9, SI_EIT_osa, SI_EIT_osb, SI_EIT_osc, SI_EIT_osd, SI_EIT_ose, SI_EIT_osf
+ SI_undef = -1,
+ SI_PAT = 0x00,
+ SI_CAT = 0x01,
+ SI_PMT = 0x02,
+ SI_DSMCC_a = 0x3a,
+ SI_DSMCC_b = 0x3b,
+ SI_DSMCC_c = 0x3c,
+ SI_DSMCC_d = 0x3d,
+ SI_DSMCC_e = 0x3e,
+ SI_DSMCC_f = 0x3f,
+ SI_NIT = 0x40,
+ SI_SDT = 0x42,
+ SI_EIT_act = 0x4e,
+ SI_EIT_oth = 0x4f,
+ SI_EIT_as0, SI_EIT_as1, SI_EIT_as2, SI_EIT_as3, SI_EIT_as4, SI_EIT_as5, SI_EIT_as6, SI_EIT_as7,
+ SI_EIT_as8, SI_EIT_as9, SI_EIT_asa, SI_EIT_asb, SI_EIT_asc, SI_EIT_asd, SI_EIT_ase, SI_EIT_asf,
+ SI_EIT_os0, SI_EIT_os1, SI_EIT_os2, SI_EIT_os3, SI_EIT_os4, SI_EIT_os5, SI_EIT_os6, SI_EIT_os7,
+ SI_EIT_os8, SI_EIT_os9, SI_EIT_osa, SI_EIT_osb, SI_EIT_osc, SI_EIT_osd, SI_EIT_ose, SI_EIT_osf
};
enum MPEG2_DESCRIPTOR
{
- // http://www.coolstf.com/tsreader/descriptors.html
- DT_VIDEO_STREAM = 0x02,
- DT_AUDIO_STREAM = 0x03,
- DT_HIERARCHY = 0x04,
- DT_REGISTRATION = 0x05,
- DT_DATA_STREAM_ALIGNMENT = 0x06,
- DT_TARGET_BACKGROUND_GRID = 0x07,
- DT_VIDEO_WINDOW = 0x08,
- DT_CONDITIONAL_ACCESS = 0x09,
- DT_ISO_639_LANGUAGE = 0x0a,
- DT_SYSTEM_CLOCK = 0x0b,
- DT_MULTIPLEX_BUFFER_UTIL = 0x0c,
- DT_COPYRIGHT_DESCRIPTOR = 0x0d,
- DT_MAXIMUM_BITRATE = 0x0e,
- DT_PRIVATE_DATA_INDICATOR = 0x0f,
- DT_SMOOTHING_BUFFER = 0x10,
- DT_STD = 0x11, // System Target Decoder ?
- DT_IBP = 0x12,
- DT_NETWORK_NAME = 0x40,
- DT_SERVICE_LIST = 0x41,
- DT_VBI_DATA = 0x45,
- DT_SERVICE = 0x48,
- DT_LINKAGE = 0x4a,
- DT_SHORT_EVENT = 0x4d,
- DT_EXTENDED_EVENT = 0x4e,
- DT_COMPONENT = 0x50,
- DT_STREAM_IDENTIFIER = 0x52,
- DT_CONTENT = 0x54,
- DT_PARENTAL_RATING = 0x55,
- DT_TELETEXT = 0x56,
- DT_SUBTITLING = 0x59,
- DT_TERRESTRIAL_DELIV_SYS = 0x5a,
- DT_PRIVATE_DATA = 0x5f,
- //
- DT_DATA_BROADCAST_ID = 0x66,
- DT_AC3_AUDIO = 0x6a, // DVB
- DT_EXTENDED_AC3_AUDIO = 0x7a,
- //
- DT_AC3_AUDIO__2 = 0x81, // DCII ou ATSC
- DT_LOGICAL_CHANNEL = 0x83,
- DT_HD_SIMCAST_LOG_CHANNEL = 0x88
+ // http://www.coolstf.com/tsreader/descriptors.html
+ DT_VIDEO_STREAM = 0x02,
+ DT_AUDIO_STREAM = 0x03,
+ DT_HIERARCHY = 0x04,
+ DT_REGISTRATION = 0x05,
+ DT_DATA_STREAM_ALIGNMENT = 0x06,
+ DT_TARGET_BACKGROUND_GRID = 0x07,
+ DT_VIDEO_WINDOW = 0x08,
+ DT_CONDITIONAL_ACCESS = 0x09,
+ DT_ISO_639_LANGUAGE = 0x0a,
+ DT_SYSTEM_CLOCK = 0x0b,
+ DT_MULTIPLEX_BUFFER_UTIL = 0x0c,
+ DT_COPYRIGHT_DESCRIPTOR = 0x0d,
+ DT_MAXIMUM_BITRATE = 0x0e,
+ DT_PRIVATE_DATA_INDICATOR = 0x0f,
+ DT_SMOOTHING_BUFFER = 0x10,
+ DT_STD = 0x11, // System Target Decoder ?
+ DT_IBP = 0x12,
+ DT_NETWORK_NAME = 0x40,
+ DT_SERVICE_LIST = 0x41,
+ DT_VBI_DATA = 0x45,
+ DT_SERVICE = 0x48,
+ DT_LINKAGE = 0x4a,
+ DT_SHORT_EVENT = 0x4d,
+ DT_EXTENDED_EVENT = 0x4e,
+ DT_COMPONENT = 0x50,
+ DT_STREAM_IDENTIFIER = 0x52,
+ DT_CONTENT = 0x54,
+ DT_PARENTAL_RATING = 0x55,
+ DT_TELETEXT = 0x56,
+ DT_SUBTITLING = 0x59,
+ DT_TERRESTRIAL_DELIV_SYS = 0x5a,
+ DT_PRIVATE_DATA = 0x5f,
+ //
+ DT_DATA_BROADCAST_ID = 0x66,
+ DT_AC3_AUDIO = 0x6a, // DVB
+ DT_EXTENDED_AC3_AUDIO = 0x7a,
+ //
+ DT_AC3_AUDIO__2 = 0x81, // DCII ou ATSC
+ DT_LOGICAL_CHANNEL = 0x83,
+ DT_HD_SIMCAST_LOG_CHANNEL = 0x88
};
diff --git a/src/DSUtil/NullRenderers.cpp b/src/DSUtil/NullRenderers.cpp index e8801fe68..866c272c3 100644 --- a/src/DSUtil/NullRenderers.cpp +++ b/src/DSUtil/NullRenderers.cpp @@ -1,4 +1,4 @@ -/*
+/*
* Copyright (C) 2003-2006 Gabest
* http://www.gabest.org
*
@@ -6,15 +6,15 @@ * it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
- *
+ *
* This Program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with GNU Make; see the file COPYING. If not, write to
- * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
+ * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
* http://www.gnu.org/copyleft/gpl.html
*
*/
@@ -36,258 +36,213 @@ #include <Mferror.h>
// dxva.dll
-typedef HRESULT(__stdcall *PTR_DXVA2CreateDirect3DDeviceManager9)(UINT* pResetToken, IDirect3DDeviceManager9** ppDeviceManager);
-typedef HRESULT(__stdcall *PTR_DXVA2CreateVideoService)(IDirect3DDevice9* pDD, REFIID riid, void** ppService);
+typedef HRESULT (__stdcall *PTR_DXVA2CreateDirect3DDeviceManager9)(UINT* pResetToken, IDirect3DDeviceManager9** ppDeviceManager);
+typedef HRESULT (__stdcall *PTR_DXVA2CreateVideoService)(IDirect3DDevice9* pDD, REFIID riid, void** ppService);
-class CNullVideoRendererInputPin : public CRendererInputPin,
- public IMFGetService,
- public IDirectXVideoMemoryConfiguration,
- public IMFVideoDisplayControl
+class CNullVideoRendererInputPin : public CRendererInputPin,
+ public IMFGetService,
+ public IDirectXVideoMemoryConfiguration,
+ public IMFVideoDisplayControl
{
public :
CNullVideoRendererInputPin(CBaseRenderer *pRenderer, HRESULT *phr, LPCWSTR Name);
- DECLARE_IUNKNOWN
+ DECLARE_IUNKNOWN
STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
- STDMETHODIMP GetAllocator(IMemAllocator **ppAllocator)
- {
- // Renderer shouldn't manage allocator for DXVA
- return E_NOTIMPL;
- }
-
- STDMETHODIMP GetAllocatorRequirements(ALLOCATOR_PROPERTIES* pProps)
- {
- // 1 buffer required
- memset(pProps, 0, sizeof(ALLOCATOR_PROPERTIES));
- pProps->cbBuffer = 1;
- return S_OK;
- }
-
-
- // IMFGetService
- STDMETHODIMP GetService(REFGUID guidService, REFIID riid, LPVOID *ppvObject);
-
- // IDirectXVideoMemoryConfiguration
- STDMETHODIMP GetAvailableSurfaceTypeByIndex(DWORD dwTypeIndex, DXVA2_SurfaceType *pdwType);
- STDMETHODIMP SetSurfaceType(DXVA2_SurfaceType dwType);
-
-
- // IMFVideoDisplayControl
- STDMETHODIMP GetNativeVideoSize(SIZE *pszVideo, SIZE *pszARVideo)
- {
- return E_NOTIMPL;
- };
- STDMETHODIMP GetIdealVideoSize(SIZE *pszMin, SIZE *pszMax)
- {
- return E_NOTIMPL;
- };
- STDMETHODIMP SetVideoPosition(const MFVideoNormalizedRect *pnrcSource, const LPRECT prcDest)
- {
- return E_NOTIMPL;
- };
- STDMETHODIMP GetVideoPosition(MFVideoNormalizedRect *pnrcSource, LPRECT prcDest)
- {
- return E_NOTIMPL;
- };
- STDMETHODIMP SetAspectRatioMode(DWORD dwAspectRatioMode)
- {
- return E_NOTIMPL;
- };
- STDMETHODIMP GetAspectRatioMode(DWORD *pdwAspectRatioMode)
- {
- return E_NOTIMPL;
- };
- STDMETHODIMP SetVideoWindow(HWND hwndVideo)
- {
- return E_NOTIMPL;
- };
- STDMETHODIMP GetVideoWindow(HWND *phwndVideo);
- STDMETHODIMP RepaintVideo(void)
- {
- return E_NOTIMPL;
- };
- STDMETHODIMP GetCurrentImage(BITMAPINFOHEADER *pBih, BYTE **pDib, DWORD *pcbDib, LONGLONG *pTimeStamp)
- {
- return E_NOTIMPL;
- };
- STDMETHODIMP SetBorderColor(COLORREF Clr)
- {
- return E_NOTIMPL;
- };
- STDMETHODIMP GetBorderColor(COLORREF *pClr)
- {
- return E_NOTIMPL;
- };
- STDMETHODIMP SetRenderingPrefs(DWORD dwRenderFlags)
- {
- return E_NOTIMPL;
- };
- STDMETHODIMP GetRenderingPrefs(DWORD *pdwRenderFlags)
- {
- return E_NOTIMPL;
- };
- STDMETHODIMP SetFullscreen(BOOL fFullscreen)
- {
- return E_NOTIMPL;
- };
- STDMETHODIMP GetFullscreen(BOOL *pfFullscreen)
- {
- return E_NOTIMPL;
- };
+ STDMETHODIMP GetAllocator(IMemAllocator **ppAllocator)
+ {
+ // Renderer shouldn't manage allocator for DXVA
+ return E_NOTIMPL;
+ }
+
+ STDMETHODIMP GetAllocatorRequirements(ALLOCATOR_PROPERTIES* pProps)
+ {
+ // 1 buffer required
+ memset (pProps, 0, sizeof(ALLOCATOR_PROPERTIES));
+ pProps->cbBuffer = 1;
+ return S_OK;
+ }
+
+
+ // IMFGetService
+ STDMETHODIMP GetService(REFGUID guidService, REFIID riid, LPVOID *ppvObject);
+
+ // IDirectXVideoMemoryConfiguration
+ STDMETHODIMP GetAvailableSurfaceTypeByIndex(DWORD dwTypeIndex, DXVA2_SurfaceType *pdwType);
+ STDMETHODIMP SetSurfaceType(DXVA2_SurfaceType dwType);
+
+
+ // IMFVideoDisplayControl
+ STDMETHODIMP GetNativeVideoSize(SIZE *pszVideo, SIZE *pszARVideo) { return E_NOTIMPL; };
+ STDMETHODIMP GetIdealVideoSize(SIZE *pszMin, SIZE *pszMax) { return E_NOTIMPL; };
+ STDMETHODIMP SetVideoPosition(const MFVideoNormalizedRect *pnrcSource, const LPRECT prcDest) { return E_NOTIMPL; };
+ STDMETHODIMP GetVideoPosition(MFVideoNormalizedRect *pnrcSource, LPRECT prcDest) { return E_NOTIMPL; };
+ STDMETHODIMP SetAspectRatioMode(DWORD dwAspectRatioMode) { return E_NOTIMPL; };
+ STDMETHODIMP GetAspectRatioMode(DWORD *pdwAspectRatioMode) { return E_NOTIMPL; };
+ STDMETHODIMP SetVideoWindow(HWND hwndVideo) { return E_NOTIMPL; };
+ STDMETHODIMP GetVideoWindow(HWND *phwndVideo);
+ STDMETHODIMP RepaintVideo( void) { return E_NOTIMPL; };
+ STDMETHODIMP GetCurrentImage(BITMAPINFOHEADER *pBih, BYTE **pDib, DWORD *pcbDib, LONGLONG *pTimeStamp) { return E_NOTIMPL; };
+ STDMETHODIMP SetBorderColor(COLORREF Clr) { return E_NOTIMPL; };
+ STDMETHODIMP GetBorderColor(COLORREF *pClr) { return E_NOTIMPL; };
+ STDMETHODIMP SetRenderingPrefs(DWORD dwRenderFlags) { return E_NOTIMPL; };
+ STDMETHODIMP GetRenderingPrefs(DWORD *pdwRenderFlags) { return E_NOTIMPL; };
+ STDMETHODIMP SetFullscreen(BOOL fFullscreen) { return E_NOTIMPL; };
+ STDMETHODIMP GetFullscreen(BOOL *pfFullscreen) { return E_NOTIMPL; };
private :
- PTR_DXVA2CreateDirect3DDeviceManager9 pfDXVA2CreateDirect3DDeviceManager9;
- PTR_DXVA2CreateVideoService pfDXVA2CreateVideoService;
+ PTR_DXVA2CreateDirect3DDeviceManager9 pfDXVA2CreateDirect3DDeviceManager9;
+ PTR_DXVA2CreateVideoService pfDXVA2CreateVideoService;
- CComPtr<IDirect3D9> m_pD3D;
- CComPtr<IDirect3DDevice9> m_pD3DDev;
- CComPtr<IDirect3DDeviceManager9> m_pD3DDeviceManager;
- UINT m_nResetTocken;
- HANDLE m_hDevice;
- HWND m_hWnd;
+ CComPtr<IDirect3D9> m_pD3D;
+ CComPtr<IDirect3DDevice9> m_pD3DDev;
+ CComPtr<IDirect3DDeviceManager9> m_pD3DDeviceManager;
+ UINT m_nResetTocken;
+ HANDLE m_hDevice;
+ HWND m_hWnd;
- void CreateSurface();
+ void CreateSurface();
};
CNullVideoRendererInputPin::CNullVideoRendererInputPin(CBaseRenderer *pRenderer, HRESULT *phr, LPCWSTR Name)
- : CRendererInputPin(pRenderer, phr, Name)
+ : CRendererInputPin(pRenderer, phr, Name)
{
- HMODULE hLib;
+ HMODULE hLib;
- CreateSurface();
+ CreateSurface();
- hLib = LoadLibrary(L"dxva2.dll");
- pfDXVA2CreateDirect3DDeviceManager9 = hLib ? (PTR_DXVA2CreateDirect3DDeviceManager9) GetProcAddress(hLib, "DXVA2CreateDirect3DDeviceManager9") : NULL;
- pfDXVA2CreateVideoService = hLib ? (PTR_DXVA2CreateVideoService) GetProcAddress(hLib, "DXVA2CreateVideoService") : NULL;
+ hLib = LoadLibrary (L"dxva2.dll");
+ pfDXVA2CreateDirect3DDeviceManager9 = hLib ? (PTR_DXVA2CreateDirect3DDeviceManager9) GetProcAddress (hLib, "DXVA2CreateDirect3DDeviceManager9") : NULL;
+ pfDXVA2CreateVideoService = hLib ? (PTR_DXVA2CreateVideoService) GetProcAddress (hLib, "DXVA2CreateVideoService") : NULL;
- if(hLib != NULL)
- {
- pfDXVA2CreateDirect3DDeviceManager9(&m_nResetTocken, &m_pD3DDeviceManager);
- }
+ if (hLib != NULL)
+ {
+ pfDXVA2CreateDirect3DDeviceManager9 (&m_nResetTocken, &m_pD3DDeviceManager);
+ }
- // Initialize Device Manager with DX surface
- if(m_pD3DDev)
- {
- HRESULT hr;
- hr = m_pD3DDeviceManager->ResetDevice(m_pD3DDev, m_nResetTocken);
- hr = m_pD3DDeviceManager->OpenDeviceHandle(&m_hDevice);
- }
+ // Initialize Device Manager with DX surface
+ if (m_pD3DDev)
+ {
+ HRESULT hr;
+ hr = m_pD3DDeviceManager->ResetDevice (m_pD3DDev, m_nResetTocken);
+ hr = m_pD3DDeviceManager->OpenDeviceHandle(&m_hDevice);
+ }
}
void CNullVideoRendererInputPin::CreateSurface()
{
- HRESULT hr;
- m_pD3D.Attach(Direct3DCreate9(D3D_SDK_VERSION));
- if(!m_pD3D)
- {
- m_pD3D.Attach(Direct3DCreate9(D3D9b_SDK_VERSION));
- }
+ HRESULT hr;
+ m_pD3D.Attach(Direct3DCreate9(D3D_SDK_VERSION));
+ if(!m_pD3D)
+ {
+ m_pD3D.Attach(Direct3DCreate9(D3D9b_SDK_VERSION));
+ }
- m_hWnd = NULL; // TODO : put true window
+ m_hWnd = NULL; // TODO : put true window
- D3DDISPLAYMODE d3ddm;
- ZeroMemory(&d3ddm, sizeof(d3ddm));
- m_pD3D->GetAdapterDisplayMode(D3DADAPTER_DEFAULT, &d3ddm);
+ D3DDISPLAYMODE d3ddm;
+ ZeroMemory(&d3ddm, sizeof(d3ddm));
+ m_pD3D->GetAdapterDisplayMode(D3DADAPTER_DEFAULT, &d3ddm);
D3DPRESENT_PARAMETERS pp;
ZeroMemory(&pp, sizeof(pp));
- pp.Windowed = TRUE;
- pp.hDeviceWindow = m_hWnd;
- pp.SwapEffect = D3DSWAPEFFECT_COPY;
- pp.Flags = D3DPRESENTFLAG_VIDEO;
- pp.BackBufferCount = 1;
- pp.BackBufferWidth = d3ddm.Width;
- pp.BackBufferHeight = d3ddm.Height;
- pp.PresentationInterval = D3DPRESENT_INTERVAL_ONE;
-
- hr = m_pD3D->CreateDevice(
- D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, m_hWnd,
- D3DCREATE_SOFTWARE_VERTEXPROCESSING | D3DCREATE_MULTITHREADED, //D3DCREATE_MANAGED
- &pp, &m_pD3DDev);
+ pp.Windowed = TRUE;
+ pp.hDeviceWindow = m_hWnd;
+ pp.SwapEffect = D3DSWAPEFFECT_COPY;
+ pp.Flags = D3DPRESENTFLAG_VIDEO;
+ pp.BackBufferCount = 1;
+ pp.BackBufferWidth = d3ddm.Width;
+ pp.BackBufferHeight = d3ddm.Height;
+ pp.PresentationInterval = D3DPRESENT_INTERVAL_ONE;
+
+ hr = m_pD3D->CreateDevice(
+ D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, m_hWnd,
+ D3DCREATE_SOFTWARE_VERTEXPROCESSING|D3DCREATE_MULTITHREADED, //D3DCREATE_MANAGED
+ &pp, &m_pD3DDev);
}
STDMETHODIMP CNullVideoRendererInputPin::NonDelegatingQueryInterface(REFIID riid, void** ppv)
{
CheckPointer(ppv, E_POINTER);
- return
- (riid == __uuidof(IMFGetService)) ? GetInterface((IMFGetService*)this, ppv) :
- __super::NonDelegatingQueryInterface(riid, ppv);
+ return
+ (riid == __uuidof(IMFGetService)) ? GetInterface((IMFGetService*)this, ppv) :
+ __super::NonDelegatingQueryInterface(riid, ppv);
}
STDMETHODIMP CNullVideoRendererInputPin::GetService(REFGUID guidService, REFIID riid, LPVOID *ppvObject)
{
- if(m_pD3DDeviceManager != NULL && guidService == MR_VIDEO_ACCELERATION_SERVICE)
- {
- if(riid == __uuidof(IDirect3DDeviceManager9))
- {
- return m_pD3DDeviceManager->QueryInterface(riid, ppvObject);
- }
- else if(riid == __uuidof(IDirectXVideoDecoderService) || riid == __uuidof(IDirectXVideoProcessorService))
- {
- return m_pD3DDeviceManager->GetVideoService(m_hDevice, riid, ppvObject);
- }
- else if(riid == __uuidof(IDirectXVideoAccelerationService))
- {
- // TODO : to be tested....
- return pfDXVA2CreateVideoService(m_pD3DDev, riid, ppvObject);
- }
- else if(riid == __uuidof(IDirectXVideoMemoryConfiguration))
- {
- GetInterface((IDirectXVideoMemoryConfiguration*)this, ppvObject);
- return S_OK;
- }
- }
- else if(guidService == MR_VIDEO_RENDER_SERVICE)
- {
- if(riid == __uuidof(IMFVideoDisplayControl))
- {
- GetInterface((IMFVideoDisplayControl*)this, ppvObject);
- return S_OK;
- }
- }
- //else if (guidService == MR_VIDEO_MIXER_SERVICE)
- //{
- // if (riid == __uuidof(IMFVideoMixerBitmap))
- // {
- // GetInterface ((IMFVideoMixerBitmap*)this, ppvObject);
- // return S_OK;
- // }
- //}
- return E_NOINTERFACE;
+ if (m_pD3DDeviceManager != NULL && guidService == MR_VIDEO_ACCELERATION_SERVICE)
+ {
+ if (riid == __uuidof(IDirect3DDeviceManager9))
+ {
+ return m_pD3DDeviceManager->QueryInterface (riid, ppvObject);
+ }
+ else if (riid == __uuidof(IDirectXVideoDecoderService) || riid == __uuidof(IDirectXVideoProcessorService) )
+ {
+ return m_pD3DDeviceManager->GetVideoService (m_hDevice, riid, ppvObject);
+ }
+ else if (riid == __uuidof(IDirectXVideoAccelerationService))
+ {
+ // TODO : to be tested....
+ return pfDXVA2CreateVideoService(m_pD3DDev, riid, ppvObject);
+ }
+ else if (riid == __uuidof(IDirectXVideoMemoryConfiguration))
+ {
+ GetInterface ((IDirectXVideoMemoryConfiguration*)this, ppvObject);
+ return S_OK;
+ }
+ }
+ else if (guidService == MR_VIDEO_RENDER_SERVICE)
+ {
+ if (riid == __uuidof(IMFVideoDisplayControl))
+ {
+ GetInterface ((IMFVideoDisplayControl*)this, ppvObject);
+ return S_OK;
+ }
+ }
+ //else if (guidService == MR_VIDEO_MIXER_SERVICE)
+ //{
+ // if (riid == __uuidof(IMFVideoMixerBitmap))
+ // {
+ // GetInterface ((IMFVideoMixerBitmap*)this, ppvObject);
+ // return S_OK;
+ // }
+ //}
+ return E_NOINTERFACE;
}
STDMETHODIMP CNullVideoRendererInputPin::GetAvailableSurfaceTypeByIndex(DWORD dwTypeIndex, DXVA2_SurfaceType *pdwType)
{
- if(dwTypeIndex == 0)
- {
- *pdwType = DXVA2_SurfaceType_DecoderRenderTarget;
- return S_OK;
- }
- else
- return MF_E_NO_MORE_TYPES;
+ if (dwTypeIndex == 0)
+ {
+ *pdwType = DXVA2_SurfaceType_DecoderRenderTarget;
+ return S_OK;
+ }
+ else
+ return MF_E_NO_MORE_TYPES;
}
STDMETHODIMP CNullVideoRendererInputPin::SetSurfaceType(DXVA2_SurfaceType dwType)
{
- return S_OK;
+ return S_OK;
}
STDMETHODIMP CNullVideoRendererInputPin::GetVideoWindow(HWND *phwndVideo)
{
- CheckPointer(phwndVideo, E_POINTER);
- *phwndVideo = m_hWnd; // Important to implement this method (used by mpc)
- return S_OK;
+ CheckPointer(phwndVideo, E_POINTER);
+ *phwndVideo = m_hWnd; // Important to implement this method (used by mpc)
+ return S_OK;
}
@@ -297,8 +252,8 @@ STDMETHODIMP CNullVideoRendererInputPin::GetVideoWindow(HWND *phwndVideo) // CNullRenderer
//
-CNullRenderer::CNullRenderer(REFCLSID clsid, TCHAR* pName, LPUNKNOWN pUnk, HRESULT* phr)
- : CBaseRenderer(clsid, pName, pUnk, phr)
+CNullRenderer::CNullRenderer(REFCLSID clsid, TCHAR* pName, LPUNKNOWN pUnk, HRESULT* phr)
+ : CBaseRenderer(clsid, pName, pUnk, phr)
{
}
@@ -306,121 +261,121 @@ CNullRenderer::CNullRenderer(REFCLSID clsid, TCHAR* pName, LPUNKNOWN pUnk, HRESU // CNullVideoRenderer
//
-CNullVideoRenderer::CNullVideoRenderer(LPUNKNOWN pUnk, HRESULT* phr)
- : CNullRenderer(__uuidof(this), NAME("Null Video Renderer"), pUnk, phr)
+CNullVideoRenderer::CNullVideoRenderer(LPUNKNOWN pUnk, HRESULT* phr)
+ : CNullRenderer(__uuidof(this), NAME("Null Video Renderer"), pUnk, phr)
{
}
HRESULT CNullVideoRenderer::CheckMediaType(const CMediaType* pmt)
{
- return pmt->majortype == MEDIATYPE_Video
- || pmt->subtype == MEDIASUBTYPE_MPEG2_VIDEO
- ? S_OK
- : E_FAIL;
+ return pmt->majortype == MEDIATYPE_Video
+ || pmt->subtype == MEDIASUBTYPE_MPEG2_VIDEO
+ ? S_OK
+ : E_FAIL;
}
//
// CNullUVideoRenderer
//
-CNullUVideoRenderer::CNullUVideoRenderer(LPUNKNOWN pUnk, HRESULT* phr)
- : CNullRenderer(__uuidof(this), NAME("Null Video Renderer (Uncompressed)"), pUnk, phr)
+CNullUVideoRenderer::CNullUVideoRenderer(LPUNKNOWN pUnk, HRESULT* phr)
+ : CNullRenderer(__uuidof(this), NAME("Null Video Renderer (Uncompressed)"), pUnk, phr)
{
#ifdef USE_DXVA
- m_pInputPin = new CNullVideoRendererInputPin(this, phr, L"In");
+ m_pInputPin = new CNullVideoRendererInputPin(this,phr,L"In");
#endif
}
HRESULT CNullUVideoRenderer::CheckMediaType(const CMediaType* pmt)
{
- return pmt->majortype == MEDIATYPE_Video
- && (pmt->subtype == MEDIASUBTYPE_YV12
- || pmt->subtype == MEDIASUBTYPE_I420
- || pmt->subtype == MEDIASUBTYPE_YUYV
- || pmt->subtype == MEDIASUBTYPE_IYUV
- || pmt->subtype == MEDIASUBTYPE_YVU9
- || pmt->subtype == MEDIASUBTYPE_Y411
- || pmt->subtype == MEDIASUBTYPE_Y41P
- || pmt->subtype == MEDIASUBTYPE_YUY2
- || pmt->subtype == MEDIASUBTYPE_YVYU
- || pmt->subtype == MEDIASUBTYPE_UYVY
- || pmt->subtype == MEDIASUBTYPE_Y211
- || pmt->subtype == MEDIASUBTYPE_RGB1
- || pmt->subtype == MEDIASUBTYPE_RGB4
- || pmt->subtype == MEDIASUBTYPE_RGB8
- || pmt->subtype == MEDIASUBTYPE_RGB565
- || pmt->subtype == MEDIASUBTYPE_RGB555
- || pmt->subtype == MEDIASUBTYPE_RGB24
- || pmt->subtype == MEDIASUBTYPE_RGB32
- || pmt->subtype == MEDIASUBTYPE_ARGB1555
- || pmt->subtype == MEDIASUBTYPE_ARGB4444
- || pmt->subtype == MEDIASUBTYPE_ARGB32
- || pmt->subtype == MEDIASUBTYPE_A2R10G10B10
- || pmt->subtype == MEDIASUBTYPE_A2B10G10R10)
- ? S_OK
- : E_FAIL;
+ return pmt->majortype == MEDIATYPE_Video
+ && (pmt->subtype == MEDIASUBTYPE_YV12
+ || pmt->subtype == MEDIASUBTYPE_I420
+ || pmt->subtype == MEDIASUBTYPE_YUYV
+ || pmt->subtype == MEDIASUBTYPE_IYUV
+ || pmt->subtype == MEDIASUBTYPE_YVU9
+ || pmt->subtype == MEDIASUBTYPE_Y411
+ || pmt->subtype == MEDIASUBTYPE_Y41P
+ || pmt->subtype == MEDIASUBTYPE_YUY2
+ || pmt->subtype == MEDIASUBTYPE_YVYU
+ || pmt->subtype == MEDIASUBTYPE_UYVY
+ || pmt->subtype == MEDIASUBTYPE_Y211
+ || pmt->subtype == MEDIASUBTYPE_RGB1
+ || pmt->subtype == MEDIASUBTYPE_RGB4
+ || pmt->subtype == MEDIASUBTYPE_RGB8
+ || pmt->subtype == MEDIASUBTYPE_RGB565
+ || pmt->subtype == MEDIASUBTYPE_RGB555
+ || pmt->subtype == MEDIASUBTYPE_RGB24
+ || pmt->subtype == MEDIASUBTYPE_RGB32
+ || pmt->subtype == MEDIASUBTYPE_ARGB1555
+ || pmt->subtype == MEDIASUBTYPE_ARGB4444
+ || pmt->subtype == MEDIASUBTYPE_ARGB32
+ || pmt->subtype == MEDIASUBTYPE_A2R10G10B10
+ || pmt->subtype == MEDIASUBTYPE_A2B10G10R10)
+ ? S_OK
+ : E_FAIL;
}
-HRESULT CNullUVideoRenderer::DoRenderSample(IMediaSample* pSample)
+HRESULT CNullUVideoRenderer::DoRenderSample(IMediaSample* pSample)
{
#ifdef USE_DXVA
- CComQIPtr<IMFGetService> pService = pSample;
- if(pService != NULL)
- {
- CComPtr<IDirect3DSurface9> pSurface;
- pService->GetService(MR_BUFFER_SERVICE, __uuidof(IDirect3DSurface9), (void**)&pSurface);
- // TODO : render surface...
- }
+ CComQIPtr<IMFGetService> pService = pSample;
+ if (pService != NULL)
+ {
+ CComPtr<IDirect3DSurface9> pSurface;
+ pService->GetService (MR_BUFFER_SERVICE, __uuidof(IDirect3DSurface9), (void**)&pSurface);
+ // TODO : render surface...
+ }
#endif
- return S_OK;
+ return S_OK;
}
//
// CNullAudioRenderer
//
-CNullAudioRenderer::CNullAudioRenderer(LPUNKNOWN pUnk, HRESULT* phr)
- : CNullRenderer(__uuidof(this), NAME("Null Audio Renderer"), pUnk, phr)
+CNullAudioRenderer::CNullAudioRenderer(LPUNKNOWN pUnk, HRESULT* phr)
+ : CNullRenderer(__uuidof(this), NAME("Null Audio Renderer"), pUnk, phr)
{
}
HRESULT CNullAudioRenderer::CheckMediaType(const CMediaType* pmt)
{
- return pmt->majortype == MEDIATYPE_Audio
- || pmt->majortype == MEDIATYPE_Midi
- || pmt->subtype == MEDIASUBTYPE_MPEG2_AUDIO
- || pmt->subtype == MEDIASUBTYPE_DOLBY_AC3
- || pmt->subtype == MEDIASUBTYPE_DVD_LPCM_AUDIO
- || pmt->subtype == MEDIASUBTYPE_DTS
- || pmt->subtype == MEDIASUBTYPE_SDDS
- || pmt->subtype == MEDIASUBTYPE_MPEG1AudioPayload
- || pmt->subtype == MEDIASUBTYPE_MPEG1Audio
- || pmt->subtype == MEDIASUBTYPE_MPEG1Audio
- ? S_OK
- : E_FAIL;
+ return pmt->majortype == MEDIATYPE_Audio
+ || pmt->majortype == MEDIATYPE_Midi
+ || pmt->subtype == MEDIASUBTYPE_MPEG2_AUDIO
+ || pmt->subtype == MEDIASUBTYPE_DOLBY_AC3
+ || pmt->subtype == MEDIASUBTYPE_DVD_LPCM_AUDIO
+ || pmt->subtype == MEDIASUBTYPE_DTS
+ || pmt->subtype == MEDIASUBTYPE_SDDS
+ || pmt->subtype == MEDIASUBTYPE_MPEG1AudioPayload
+ || pmt->subtype == MEDIASUBTYPE_MPEG1Audio
+ || pmt->subtype == MEDIASUBTYPE_MPEG1Audio
+ ? S_OK
+ : E_FAIL;
}
//
// CNullUAudioRenderer
//
-CNullUAudioRenderer::CNullUAudioRenderer(LPUNKNOWN pUnk, HRESULT* phr)
- : CNullRenderer(__uuidof(this), NAME("Null Audio Renderer (Uncompressed)"), pUnk, phr)
+CNullUAudioRenderer::CNullUAudioRenderer(LPUNKNOWN pUnk, HRESULT* phr)
+ : CNullRenderer(__uuidof(this), NAME("Null Audio Renderer (Uncompressed)"), pUnk, phr)
{
}
HRESULT CNullUAudioRenderer::CheckMediaType(const CMediaType* pmt)
{
- return pmt->majortype == MEDIATYPE_Audio
- && (pmt->subtype == MEDIASUBTYPE_PCM
- || pmt->subtype == MEDIASUBTYPE_IEEE_FLOAT
- || pmt->subtype == MEDIASUBTYPE_DRM_Audio
- || pmt->subtype == MEDIASUBTYPE_DOLBY_AC3_SPDIF
- || pmt->subtype == MEDIASUBTYPE_RAW_SPORT
- || pmt->subtype == MEDIASUBTYPE_SPDIF_TAG_241h)
- ? S_OK
- : E_FAIL;
+ return pmt->majortype == MEDIATYPE_Audio
+ && (pmt->subtype == MEDIASUBTYPE_PCM
+ || pmt->subtype == MEDIASUBTYPE_IEEE_FLOAT
+ || pmt->subtype == MEDIASUBTYPE_DRM_Audio
+ || pmt->subtype == MEDIASUBTYPE_DOLBY_AC3_SPDIF
+ || pmt->subtype == MEDIASUBTYPE_RAW_SPORT
+ || pmt->subtype == MEDIASUBTYPE_SPDIF_TAG_241h)
+ ? S_OK
+ : E_FAIL;
}
//
@@ -429,20 +384,20 @@ HRESULT CNullUAudioRenderer::CheckMediaType(const CMediaType* pmt) HRESULT CNullTextRenderer::CTextInputPin::CheckMediaType(const CMediaType* pmt)
{
- return pmt->majortype == MEDIATYPE_Text
- || pmt->majortype == MEDIATYPE_ScriptCommand
- || pmt->majortype == MEDIATYPE_Subtitle
- || pmt->subtype == MEDIASUBTYPE_DVD_SUBPICTURE
- || pmt->subtype == MEDIASUBTYPE_CVD_SUBPICTURE
- || pmt->subtype == MEDIASUBTYPE_SVCD_SUBPICTURE
- ? S_OK
- : E_FAIL;
+ return pmt->majortype == MEDIATYPE_Text
+ || pmt->majortype == MEDIATYPE_ScriptCommand
+ || pmt->majortype == MEDIATYPE_Subtitle
+ || pmt->subtype == MEDIASUBTYPE_DVD_SUBPICTURE
+ || pmt->subtype == MEDIASUBTYPE_CVD_SUBPICTURE
+ || pmt->subtype == MEDIASUBTYPE_SVCD_SUBPICTURE
+ ? S_OK
+ : E_FAIL;
}
#pragma warning (disable : 4355)
CNullTextRenderer::CNullTextRenderer(LPUNKNOWN pUnk, HRESULT* phr)
- : CBaseFilter(NAME("CNullTextRenderer"), pUnk, this, __uuidof(this), phr)
+ : CBaseFilter(NAME("CNullTextRenderer"), pUnk, this, __uuidof(this), phr)
{
- m_pInput.Attach(DNew CTextInputPin(this, this, phr));
+ m_pInput.Attach(DNew CTextInputPin(this, this, phr));
}
#pragma warning (default : 4355)
diff --git a/src/DSUtil/NullRenderers.h b/src/DSUtil/NullRenderers.h index 60047609d..3fdbe6ea2 100644 --- a/src/DSUtil/NullRenderers.h +++ b/src/DSUtil/NullRenderers.h @@ -1,4 +1,4 @@ -/*
+/*
* Copyright (C) 2003-2006 Gabest
* http://www.gabest.org
*
@@ -6,15 +6,15 @@ * it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
- *
+ *
* This Program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with GNU Make; see the file COPYING. If not, write to
- * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
+ * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
* http://www.gnu.org/copyleft/gpl.html
*
*/
@@ -26,78 +26,69 @@ class CNullRenderer : public CBaseRenderer
{
protected:
- virtual HRESULT DoRenderSample(IMediaSample* pSample)
- {
- return S_OK;
- }
+ virtual HRESULT DoRenderSample(IMediaSample* pSample) {return S_OK;}
public:
- CNullRenderer(REFCLSID clsid, TCHAR* pName, LPUNKNOWN pUnk, HRESULT* phr);
+ CNullRenderer(REFCLSID clsid, TCHAR* pName, LPUNKNOWN pUnk, HRESULT* phr);
};
[uuid("579883A0-4E2D-481F-9436-467AAFAB7DE8")]
class CNullVideoRenderer : public CNullRenderer
{
protected:
- HRESULT CheckMediaType(const CMediaType* pmt);
+ HRESULT CheckMediaType(const CMediaType* pmt);
public:
- CNullVideoRenderer(LPUNKNOWN pUnk, HRESULT* phr);
+ CNullVideoRenderer(LPUNKNOWN pUnk, HRESULT* phr);
};
[uuid("DD9ED57D-6ABF-42E8-89A2-11D04798DC58")]
class CNullUVideoRenderer : public CNullRenderer
{
protected:
- HRESULT CheckMediaType(const CMediaType* pmt);
+ HRESULT CheckMediaType(const CMediaType* pmt);
public:
- CNullUVideoRenderer(LPUNKNOWN pUnk, HRESULT* phr);
- virtual HRESULT DoRenderSample(IMediaSample* pSample);
+ CNullUVideoRenderer(LPUNKNOWN pUnk, HRESULT* phr);
+ virtual HRESULT DoRenderSample(IMediaSample* pSample);
};
[uuid("0C38BDFD-8C17-4E00-A344-F89397D3E22A")]
class CNullAudioRenderer : public CNullRenderer
{
protected:
- HRESULT CheckMediaType(const CMediaType* pmt);
+ HRESULT CheckMediaType(const CMediaType* pmt);
public:
- CNullAudioRenderer(LPUNKNOWN pUnk, HRESULT* phr);
+ CNullAudioRenderer(LPUNKNOWN pUnk, HRESULT* phr);
};
[uuid("64A45125-7343-4772-9DA4-179FAC9D462C")]
class CNullUAudioRenderer : public CNullRenderer
{
protected:
- HRESULT CheckMediaType(const CMediaType* pmt);
+ HRESULT CheckMediaType(const CMediaType* pmt);
public:
- CNullUAudioRenderer(LPUNKNOWN pUnk, HRESULT* phr);
+ CNullUAudioRenderer(LPUNKNOWN pUnk, HRESULT* phr);
};
[uuid("655D7613-C26C-4A25-BBBD-3C9C516122CC")]
class CNullTextRenderer : public CBaseFilter, public CCritSec
{
- class CTextInputPin : public CBaseInputPin
- {
- public:
- CTextInputPin(CBaseFilter* pFilter, CCritSec* pLock, HRESULT* phr)
- : CBaseInputPin(NAME("CTextInputPin"), pFilter, pLock, phr, L"In") {}
- HRESULT CheckMediaType(const CMediaType* pmt);
- };
+ class CTextInputPin : public CBaseInputPin
+ {
+ public:
+ CTextInputPin(CBaseFilter* pFilter, CCritSec* pLock, HRESULT* phr)
+ : CBaseInputPin(NAME("CTextInputPin"), pFilter, pLock, phr, L"In") {}
+ HRESULT CheckMediaType(const CMediaType* pmt);
+ };
- CAutoPtr<CTextInputPin> m_pInput;
+ CAutoPtr<CTextInputPin> m_pInput;
public:
- CNullTextRenderer(LPUNKNOWN pUnk, HRESULT* phr);
- int GetPinCount()
- {
- return (int)!!m_pInput;
- }
- CBasePin* GetPin(int n)
- {
- return n == 0 ? (CBasePin*)m_pInput : NULL;
- }
+ CNullTextRenderer(LPUNKNOWN pUnk, HRESULT* phr);
+ int GetPinCount() {return (int)!!m_pInput;}
+ CBasePin* GetPin(int n) {return n == 0 ? (CBasePin*)m_pInput : NULL;}
};
diff --git a/src/DSUtil/SharedInclude.h b/src/DSUtil/SharedInclude.h index b47d2d91f..7a2ca07ac 100644 --- a/src/DSUtil/SharedInclude.h +++ b/src/DSUtil/SharedInclude.h @@ -14,13 +14,13 @@ #pragma warning(disable:4267)
#ifdef _DEBUG
-#define _CRTDBG_MAP_ALLOC // include Microsoft memory leak detection procedures
+ #define _CRTDBG_MAP_ALLOC // include Microsoft memory leak detection procedures
#if 0
-#include <crtdbg.h>
-#define DNew new(_NORMAL_BLOCK, __FILE__, __LINE__)
+ #include <crtdbg.h>
+ #define DNew new(_NORMAL_BLOCK, __FILE__, __LINE__)
#else
-#define DNew new(__FILE__, __LINE__)
+ #define DNew new(__FILE__, __LINE__)
#endif
#else
diff --git a/src/DSUtil/cpuid_32_64.h b/src/DSUtil/cpuid_32_64.h index 9954952bf..29990b681 100644 --- a/src/DSUtil/cpuid_32_64.h +++ b/src/DSUtil/cpuid_32_64.h @@ -1,16 +1,15 @@ -#pragma once
+#pragma once
-typedef struct cpuid_args_s
-{
- DWORD eax;
- DWORD ebx;
- DWORD ecx;
- DWORD edx;
-} CPUID_ARGS;
+typedef struct cpuid_args_s {
+DWORD eax;
+DWORD ebx;
+DWORD ecx;
+DWORD edx;
+} CPUID_ARGS;
-extern "C" {
+extern "C" {
#ifdef _WIN64 // For 64-bit apps
- void cpuid64(CPUID_ARGS* p);
+ void cpuid64(CPUID_ARGS* p);
#define _CPUID cpuid64
#endif
}
\ No newline at end of file diff --git a/src/DSUtil/csimd.h b/src/DSUtil/csimd.h index 67758ded9..db940ccd4 100644 --- a/src/DSUtil/csimd.h +++ b/src/DSUtil/csimd.h @@ -25,146 +25,44 @@ namespace csimd #undef MMX_INSTRUCTION
#undef SSE2I_INSTRUCTION
-static __forceinline void movq(const __m64 &src, __m64 &dst)
-{
- dst = src;
-}
-static __forceinline void movq(const void *src , __m64 &dst)
-{
- dst = *(__m64*)src;
-}
-static __forceinline void movq(const long long &src , __m64 &dst)
-{
- dst = *(__m64*)&src;
-}
-static __forceinline void movq(const __m64 &src, void *dst)
-{
- *(__m64*)dst = src;
-}
+static __forceinline void movq(const __m64 &src,__m64 &dst) {dst=src;}
+static __forceinline void movq(const void *src ,__m64 &dst) {dst=*(__m64*)src;}
+static __forceinline void movq(const long long &src ,__m64 &dst) {dst=*(__m64*)&src;}
+static __forceinline void movq(const __m64 &src,void *dst ) {*(__m64*)dst=src;}
-static __forceinline void movd(int src , __m64 &dst)
-{
- dst = _mm_cvtsi32_si64(src);
-}
-static __forceinline void movd(const __m64 &src, int &dst)
-{
- dst = _mm_cvtsi64_si32(src);
-}
-static __forceinline void movd(const void *src , __m64 &dst)
-{
- dst = _mm_cvtsi32_si64(*(const int*)src);
-}
-static __forceinline void movd(const __m64 &src, void *dst)
-{
- *(int*)dst = _mm_cvtsi64_si32(src);
-}
+static __forceinline void movd(int src ,__m64 &dst) {dst=_mm_cvtsi32_si64(src);}
+static __forceinline void movd(const __m64 &src,int &dst ) {dst=_mm_cvtsi64_si32(src);}
+static __forceinline void movd(const void *src ,__m64 &dst) {dst=_mm_cvtsi32_si64(*(const int*)src);}
+static __forceinline void movd(const __m64 &src,void *dst ) {*(int*)dst=_mm_cvtsi64_si32(src);}
-static __forceinline void psllw(int i, __m64 &dst)
-{
- dst = _mm_slli_pi16(dst, i);
-}
-static __forceinline void psrlw(int i, __m64 &dst)
-{
- dst = _mm_srli_pi16(dst, i);
-}
-static __forceinline void pslld(int i, __m64 &dst)
-{
- dst = _mm_slli_pi32(dst, i);
-}
-static __forceinline void psrld(int i, __m64 &dst)
-{
- dst = _mm_srli_pi32(dst, i);
-}
-static __forceinline void psrad(int i, __m64 &dst)
-{
- dst = _mm_srai_pi32(dst, i);
-}
-static __forceinline void psraw(int i, __m64 &dst)
-{
- dst = _mm_srai_pi16(dst, i);
-}
-static __forceinline void psraw(const __m64 &src, __m64 &dst)
-{
- dst = _mm_sra_pi16(dst, src);
-}
-static __forceinline void psrlq(int i, __m64 &dst)
-{
- dst = _mm_srli_si64(dst, i);
-}
+static __forceinline void psllw(int i,__m64 &dst) {dst=_mm_slli_pi16(dst,i);}
+static __forceinline void psrlw(int i,__m64 &dst) {dst=_mm_srli_pi16(dst,i);}
+static __forceinline void pslld(int i,__m64 &dst) {dst=_mm_slli_pi32(dst,i);}
+static __forceinline void psrld(int i,__m64 &dst) {dst=_mm_srli_pi32(dst,i);}
+static __forceinline void psrad(int i,__m64 &dst) {dst=_mm_srai_pi32(dst,i);}
+static __forceinline void psraw(int i,__m64 &dst) {dst=_mm_srai_pi16(dst,i);}
+static __forceinline void psraw(const __m64 &src,__m64 &dst) {dst=_mm_sra_pi16(dst,src);}
+static __forceinline void psrlq(int i,__m64 &dst) {dst=_mm_srli_si64(dst,i);}
-static __forceinline void movlps(const void *src, __m128 &dst)
-{
- dst = _mm_loadl_pi(dst, (__m64*)src);
-}
-static __forceinline void movhps(const void *src, __m128 &dst)
-{
- dst = _mm_loadh_pi(dst, (__m64*)src);
-}
-static __forceinline void movlps(const __m128 &src, void *dst)
-{
- _mm_storel_pi((__m64*)dst, src);
-}
-static __forceinline void movhps(const __m128 &src, void *dst)
-{
- _mm_storeh_pi((__m64*)dst, src);
-}
-static __forceinline void movaps(const void *src, __m128 &dst)
-{
- dst = _mm_load_ps((const float*)src);
-}
-static __forceinline void movaps(const __m128 &src, void *dst)
-{
- _mm_store_ps((float*)dst, src);
-}
-static __forceinline void movaps(const __m128 &src, __m128 &dst)
-{
- dst = src;
-}
-static __forceinline void mulps(const __m128 &src, __m128 &dst)
-{
- dst = _mm_mul_ps(dst, src);
-}
-static __forceinline void mulps(const void *src, __m128 &dst)
-{
- dst = _mm_mul_ps(dst, *(__m128*)src);
-}
-static __forceinline void addps(const __m128 &src, __m128 &dst)
-{
- dst = _mm_add_ps(dst, src);
-}
-static __forceinline void addps(const void *src, __m128 &dst)
-{
- dst = _mm_add_ps(dst, *(__m128*)src);
-}
-static __forceinline void subps(const __m128 &src, __m128 &dst)
-{
- dst = _mm_sub_ps(dst, src);
-}
-static __forceinline void xorps(const __m128 &src, __m128 &dst)
-{
- dst = _mm_xor_ps(dst, src);
-}
-static __forceinline void movss(const float &src, __m128 &dst)
-{
- dst = _mm_load_ss(&src);
-}
+static __forceinline void movlps(const void *src,__m128 &dst) {dst=_mm_loadl_pi(dst,(__m64*)src);}
+static __forceinline void movhps(const void *src,__m128 &dst) {dst=_mm_loadh_pi(dst,(__m64*)src);}
+static __forceinline void movlps(const __m128 &src,void *dst) {_mm_storel_pi((__m64*)dst,src);}
+static __forceinline void movhps(const __m128 &src,void *dst) {_mm_storeh_pi((__m64*)dst,src);}
+static __forceinline void movaps(const void *src,__m128 &dst) {dst=_mm_load_ps((const float*)src);}
+static __forceinline void movaps(const __m128 &src,void *dst) {_mm_store_ps((float*)dst,src);}
+static __forceinline void movaps(const __m128 &src,__m128 &dst) {dst=src;}
+static __forceinline void mulps(const __m128 &src,__m128 &dst) {dst=_mm_mul_ps(dst,src);}
+static __forceinline void mulps(const void *src,__m128 &dst) {dst=_mm_mul_ps(dst,*(__m128*)src);}
+static __forceinline void addps(const __m128 &src,__m128 &dst) {dst=_mm_add_ps(dst,src);}
+static __forceinline void addps(const void *src,__m128 &dst) {dst=_mm_add_ps(dst,*(__m128*)src);}
+static __forceinline void subps(const __m128 &src,__m128 &dst) {dst=_mm_sub_ps(dst,src);}
+static __forceinline void xorps(const __m128 &src,__m128 &dst) {dst=_mm_xor_ps(dst,src);}
+static __forceinline void movss(const float &src,__m128 &dst) {dst=_mm_load_ss(&src);}
-static __forceinline void movdqu(const void *src, __m128i &dst)
-{
- dst = _mm_loadu_si128((__m128i*)src);
-}
-static __forceinline void movdqu(const __m128i &src, __m128i &dst)
-{
- dst = _mm_loadu_si128(&src);
-}
-static __forceinline void movdqu(const __m128i &src, void *dst)
-{
- _mm_storeu_si128((__m128i*)dst, src);
-}
-static __forceinline void psraw(int i, __m128i &dst)
-{
- dst = _mm_srai_epi16(dst, i);
-}
+static __forceinline void movdqu(const void *src,__m128i &dst) {dst=_mm_loadu_si128((__m128i*)src);}
+static __forceinline void movdqu(const __m128i &src,__m128i &dst) {dst=_mm_loadu_si128(&src);}
+static __forceinline void movdqu(const __m128i &src,void *dst) {_mm_storeu_si128((__m128i*)dst,src);}
+static __forceinline void psraw(int i,__m128i &dst) {dst=_mm_srai_epi16(dst,i);}
}
#pragma warning(pop)
diff --git a/src/DSUtil/mmintrin64.c b/src/DSUtil/mmintrin64.c index afcd96c5c..07b70b16a 100644 --- a/src/DSUtil/mmintrin64.c +++ b/src/DSUtil/mmintrin64.c @@ -27,1491 +27,979 @@ // MMX
__m64 _mm_setzero_si64(void)
{
- __m64 rv = {0};
- return rv;
+ __m64 rv = {0};
+ return rv;
}
__m64 _mm_set_pi32(int _I1, int _I0)
{
- __m64 rv = {0};
- rv.m64_i32[0] = _I0;
- rv.m64_i32[1] = _I1;
- return rv;
+ __m64 rv = {0};
+ rv.m64_i32[0] = _I0;
+ rv.m64_i32[1] = _I1;
+ return rv;
}
__m64 _mm_set_pi16(short _S3, short _S2, short _S1, short _S0)
{
- __m64 rv = {0};
- rv.m64_i16[0] = _S0;
- rv.m64_i16[1] = _S1;
- rv.m64_i16[2] = _S2;
- rv.m64_i16[3] = _S3;
- return rv;
+ __m64 rv = {0};
+ rv.m64_i16[0] = _S0;
+ rv.m64_i16[1] = _S1;
+ rv.m64_i16[2] = _S2;
+ rv.m64_i16[3] = _S3;
+ return rv;
}
__m64 _mm_set_pi8(char _B7, char _B6, char _B5, char _B4, char _B3, char _B2, char _B1, char _B0)
{
- __m64 rv = {0};
- rv.m64_i8[0] = _B0;
- rv.m64_i8[1] = _B1;
- rv.m64_i8[2] = _B2;
- rv.m64_i8[3] = _B3;
- rv.m64_i8[4] = _B4;
- rv.m64_i8[5] = _B5;
- rv.m64_i8[6] = _B6;
- rv.m64_i8[7] = _B7;
- return rv;
+ __m64 rv = {0};
+ rv.m64_i8[0] = _B0;
+ rv.m64_i8[1] = _B1;
+ rv.m64_i8[2] = _B2;
+ rv.m64_i8[3] = _B3;
+ rv.m64_i8[4] = _B4;
+ rv.m64_i8[5] = _B5;
+ rv.m64_i8[6] = _B6;
+ rv.m64_i8[7] = _B7;
+ return rv;
}
__m64 _mm_set1_pi32(int _I)
{
- __m64 rv = {0};
- rv.m64_i32[0] = rv.m64_i32[1] = _I;
- return rv;
+ __m64 rv = {0};
+ rv.m64_i32[0] = rv.m64_i32[1] = _I;
+ return rv;
}
__m64 _mm_set1_pi16(short _S)
{
- __m64 rv = {0};
- rv.m64_i16[0] = rv.m64_i16[1] = rv.m64_i16[2] = rv.m64_i16[3] = _S;
- return rv;
+ __m64 rv = {0};
+ rv.m64_i16[0] = rv.m64_i16[1] = rv.m64_i16[2] = rv.m64_i16[3] = _S;
+ return rv;
}
__m64 _mm_set1_pi8(char _B)
{
- __m64 rv = {0};
- rv.m64_i8[0] = rv.m64_i8[1] = rv.m64_i8[2] = rv.m64_i8[3] = rv.m64_i8[4] = rv.m64_i8[5] = rv.m64_i8[6] = rv.m64_i8[7] = _B;
- return rv;
+ __m64 rv = {0};
+ rv.m64_i8[0] = rv.m64_i8[1] = rv.m64_i8[2] = rv.m64_i8[3] = rv.m64_i8[4] = rv.m64_i8[5] = rv.m64_i8[6] = rv.m64_i8[7] = _B;
+ return rv;
}
__m64 _m_psubb(__m64 _MM1, __m64 _MM2)
{
- __m128i lhs = {0}, rhs = {0};
- lhs.m128i_i64[0] = _MM1.m64_i64;
+ __m128i lhs = {0}, rhs = {0};
+ lhs.m128i_i64[0] = _MM1.m64_i64;
- rhs.m128i_i64[0] = _MM2.m64_i64;
+ rhs.m128i_i64[0] = _MM2.m64_i64;
- lhs = _mm_sub_epi8(lhs, rhs);
+ lhs = _mm_sub_epi8(lhs, rhs);
- _MM1.m64_i64 = lhs.m128i_i64[0];
- return _MM1;
+ _MM1.m64_i64 = lhs.m128i_i64[0];
+ return _MM1;
}
__m64 _m_paddusb(__m64 _MM1, __m64 _MM2)
{
- __m128i lhs = {0}, rhs = {0};
- lhs.m128i_i64[0] = _MM1.m64_i64;
+ __m128i lhs = {0}, rhs = {0};
+ lhs.m128i_i64[0] = _MM1.m64_i64;
- rhs.m128i_i64[0] = _MM2.m64_i64;
+ rhs.m128i_i64[0] = _MM2.m64_i64;
- lhs = _mm_adds_epu8(lhs, rhs);
+ lhs = _mm_adds_epu8(lhs, rhs);
- _MM1.m64_i64 = lhs.m128i_i64[0];
- return _MM1;
+ _MM1.m64_i64 = lhs.m128i_i64[0];
+ return _MM1;
}
__m64 _m_psubsw(__m64 _MM1, __m64 _MM2)
{
- __m128i lhs = {0}, rhs = {0};
- lhs.m128i_i64[0] = _MM1.m64_i64;
+ __m128i lhs = {0}, rhs = {0};
+ lhs.m128i_i64[0] = _MM1.m64_i64;
- rhs.m128i_i64[0] = _MM2.m64_i64;
+ rhs.m128i_i64[0] = _MM2.m64_i64;
- lhs = _mm_subs_epi16(lhs, rhs);
+ lhs = _mm_subs_epi16(lhs, rhs);
- _MM1.m64_i64 = lhs.m128i_i64[0];
- return _MM1;
+ _MM1.m64_i64 = lhs.m128i_i64[0];
+ return _MM1;
}
__m64 _m_psubsb(__m64 _MM1, __m64 _MM2)
{
- __m128i lhs = {0}, rhs = {0};
- lhs.m128i_i64[0] = _MM1.m64_i64;
+ __m128i lhs = {0}, rhs = {0};
+ lhs.m128i_i64[0] = _MM1.m64_i64;
- rhs.m128i_i64[0] = _MM2.m64_i64;
+ rhs.m128i_i64[0] = _MM2.m64_i64;
- lhs = _mm_subs_epi8(lhs, rhs);
+ lhs = _mm_subs_epi8(lhs, rhs);
- _MM1.m64_i64 = lhs.m128i_i64[0];
- return _MM1;
+ _MM1.m64_i64 = lhs.m128i_i64[0];
+ return _MM1;
}
__m64 _m_paddw(__m64 _MM1, __m64 _MM2)
{
- __m128i lhs = {0}, rhs = {0};
- lhs.m128i_i64[0] = _MM1.m64_i64;
+ __m128i lhs = {0}, rhs = {0};
+ lhs.m128i_i64[0] = _MM1.m64_i64;
- rhs.m128i_i64[0] = _MM2.m64_i64;
+ rhs.m128i_i64[0] = _MM2.m64_i64;
- lhs = _mm_add_epi16(lhs, rhs);
+ lhs = _mm_add_epi16(lhs, rhs);
- _MM1.m64_i64 = lhs.m128i_i64[0];
- return _MM1;
+ _MM1.m64_i64 = lhs.m128i_i64[0];
+ return _MM1;
}
void _m_empty(void)
{
}
__m64 _m_packuswb(__m64 _MM1, __m64 _MM2)
{
- __m128i lhs = {0}, rhs = {0};
- lhs.m128i_i64[0] = _MM1.m64_i64;
- lhs.m128i_i64[1] = _MM2.m64_i64;
+ __m128i lhs = {0}, rhs = {0};
+ lhs.m128i_i64[0] = _MM1.m64_i64;
+ lhs.m128i_i64[1] = _MM2.m64_i64;
- lhs = _mm_packus_epi16(lhs, rhs);
+ lhs = _mm_packus_epi16(lhs, rhs);
- _MM1.m64_i64 = lhs.m128i_i64[0];
- return _MM1;
+ _MM1.m64_i64 = lhs.m128i_i64[0];
+ return _MM1;
}
__m64 _m_psrlwi(__m64 _M, int _Count)
{
- __m128i lhs = {0};
- lhs.m128i_i64[0] = _M.m64_i64;
+ __m128i lhs = {0};
+ lhs.m128i_i64[0] = _M.m64_i64;
- lhs = _mm_srli_epi16(lhs, _Count);
+ lhs = _mm_srli_epi16(lhs, _Count);
- _M.m64_i64 = lhs.m128i_i64[0];
- return _M;
+ _M.m64_i64 = lhs.m128i_i64[0];
+ return _M;
}
__m64 _m_pmullw(__m64 _MM1, __m64 _MM2)
{
- __m128i lhs = {0}, rhs = {0};
- lhs.m128i_i64[0] = _MM1.m64_i64;
+ __m128i lhs = {0}, rhs = {0};
+ lhs.m128i_i64[0] = _MM1.m64_i64;
- rhs.m128i_i64[0] = _MM2.m64_i64;
+ rhs.m128i_i64[0] = _MM2.m64_i64;
- lhs = _mm_mullo_epi16(lhs, rhs);
+ lhs = _mm_mullo_epi16(lhs, rhs);
- _MM1.m64_i64 = lhs.m128i_i64[0];
- return _MM1;
+ _MM1.m64_i64 = lhs.m128i_i64[0];
+ return _MM1;
}
__m64 _m_from_int(int _I)
{
- __m64 rv = {0};
- rv.m64_i32[0] = _I;
- return rv;
+ __m64 rv = {0};
+ rv.m64_i32[0] = _I;
+ return rv;
}
int _m_to_int(__m64 _M)
{
- return (int)(_M.m64_u64 & 0xffffffff);
+ return (int)(_M.m64_u64 & 0xffffffff);
}
__m64 _m_psrlqi(__m64 _M, int _Count)
{
- __m128i lhs = {0};
- lhs.m128i_i64[0] = _M.m64_i64;
+ __m128i lhs = {0};
+ lhs.m128i_i64[0] = _M.m64_i64;
- lhs = _mm_srli_epi64(lhs, _Count);
+ lhs = _mm_srli_epi64(lhs, _Count);
- _M.m64_i64 = lhs.m128i_i64[0];
- return _M;
+ _M.m64_i64 = lhs.m128i_i64[0];
+ return _M;
}
__m64 _m_paddd(__m64 _MM1, __m64 _MM2)
{
- __m128i lhs = {0}, rhs = {0};
- lhs.m128i_i64[0] = _MM1.m64_i64;
+ __m128i lhs = {0}, rhs = {0};
+ lhs.m128i_i64[0] = _MM1.m64_i64;
- rhs.m128i_i64[0] = _MM2.m64_i64;
+ rhs.m128i_i64[0] = _MM2.m64_i64;
- lhs = _mm_add_epi32(lhs, rhs);
+ lhs = _mm_add_epi32(lhs, rhs);
- _MM1.m64_i64 = lhs.m128i_i64[0];
- return _MM1;
+ _MM1.m64_i64 = lhs.m128i_i64[0];
+ return _MM1;
}
__m64 _m_pmaddwd(__m64 _MM1, __m64 _MM2)
{
- __m128i lhs = {0}, rhs = {0};
- lhs.m128i_i64[0] = _MM1.m64_i64;
+ __m128i lhs = {0}, rhs = {0};
+ lhs.m128i_i64[0] = _MM1.m64_i64;
- rhs.m128i_i64[0] = _MM2.m64_i64;
+ rhs.m128i_i64[0] = _MM2.m64_i64;
- lhs = _mm_madd_epi16(lhs, rhs);
+ lhs = _mm_madd_epi16(lhs, rhs);
- _MM1.m64_i64 = lhs.m128i_i64[0];
- return _MM1;
+ _MM1.m64_i64 = lhs.m128i_i64[0];
+ return _MM1;
}
__m64 _m_punpcklbw(__m64 _MM1, __m64 _MM2)
{
- __m128i lhs = {0}, rhs = {0};
- lhs.m128i_i64[0] = _MM1.m64_i64;
+ __m128i lhs = {0}, rhs = {0};
+ lhs.m128i_i64[0] = _MM1.m64_i64;
- rhs.m128i_i64[0] = _MM2.m64_i64;
+ rhs.m128i_i64[0] = _MM2.m64_i64;
- lhs = _mm_unpacklo_epi8(lhs, rhs);
+ lhs = _mm_unpacklo_epi8(lhs, rhs);
- _MM1.m64_i64 = lhs.m128i_i64[0];
- return _MM1;
+ _MM1.m64_i64 = lhs.m128i_i64[0];
+ return _MM1;
}
__m64 _m_paddb(__m64 _MM1, __m64 _MM2)
{
- __m128i lhs = {0}, rhs = {0};
- lhs.m128i_i64[0] = _MM1.m64_i64;
+ __m128i lhs = {0}, rhs = {0};
+ lhs.m128i_i64[0] = _MM1.m64_i64;
- rhs.m128i_i64[0] = _MM2.m64_i64;
+ rhs.m128i_i64[0] = _MM2.m64_i64;
- lhs = _mm_add_epi8(lhs, rhs);
+ lhs = _mm_add_epi8(lhs, rhs);
- _MM1.m64_i64 = lhs.m128i_i64[0];
- return _MM1;
+ _MM1.m64_i64 = lhs.m128i_i64[0];
+ return _MM1;
}
__m64 _m_por(__m64 _MM1, __m64 _MM2)
{
- __m128i lhs = {0}, rhs = {0};
- lhs.m128i_i64[0] = _MM1.m64_i64;
+ __m128i lhs = {0}, rhs = {0};
+ lhs.m128i_i64[0] = _MM1.m64_i64;
- rhs.m128i_i64[0] = _MM2.m64_i64;
+ rhs.m128i_i64[0] = _MM2.m64_i64;
- lhs = _mm_or_si128(lhs, rhs);
+ lhs = _mm_or_si128(lhs, rhs);
- _MM1.m64_i64 = lhs.m128i_i64[0];
- return _MM1;
+ _MM1.m64_i64 = lhs.m128i_i64[0];
+ return _MM1;
}
__m64 _m_pand(__m64 _MM1, __m64 _MM2)
{
- __m128i lhs, rhs;
- lhs.m128i_i64[0] = _MM1.m64_i64;
+ __m128i lhs, rhs;
+ lhs.m128i_i64[0] = _MM1.m64_i64;
- rhs.m128i_i64[0] = _MM2.m64_i64;
+ rhs.m128i_i64[0] = _MM2.m64_i64;
- lhs = _mm_and_si128(lhs, rhs);
+ lhs = _mm_and_si128(lhs, rhs);
- _MM1.m64_i64 = lhs.m128i_i64[0];
- return _MM1;
+ _MM1.m64_i64 = lhs.m128i_i64[0];
+ return _MM1;
}
__m64 _m_pandn(__m64 _MM1, __m64 _MM2)
{
- __m128i lhs = {0}, rhs = {0};
- lhs.m128i_i64[0] = _MM1.m64_i64;
+ __m128i lhs = {0}, rhs = {0};
+ lhs.m128i_i64[0] = _MM1.m64_i64;
- rhs.m128i_i64[0] = _MM2.m64_i64;
+ rhs.m128i_i64[0] = _MM2.m64_i64;
- lhs = _mm_andnot_si128(lhs, rhs);
+ lhs = _mm_andnot_si128(lhs, rhs);
- _MM1.m64_i64 = lhs.m128i_i64[0];
- return _MM1;
+ _MM1.m64_i64 = lhs.m128i_i64[0];
+ return _MM1;
}
__m64 _m_pcmpgtb(__m64 _MM1, __m64 _MM2)
{
- __m128i lhs = {0}, rhs = {0};
- lhs.m128i_i64[0] = _MM1.m64_i64;
+ __m128i lhs = {0}, rhs = {0};
+ lhs.m128i_i64[0] = _MM1.m64_i64;
- rhs.m128i_i64[0] = _MM2.m64_i64;
+ rhs.m128i_i64[0] = _MM2.m64_i64;
- lhs = _mm_cmpgt_epi8(lhs, rhs);
+ lhs = _mm_cmpgt_epi8(lhs, rhs);
- _MM1.m64_i64 = lhs.m128i_i64[0];
- return _MM1;
+ _MM1.m64_i64 = lhs.m128i_i64[0];
+ return _MM1;
}
__m64 _m_psubusb(__m64 _MM1, __m64 _MM2)
{
- __m128i lhs = {0}, rhs = {0};
- lhs.m128i_i64[0] = _MM1.m64_i64;
+ __m128i lhs = {0}, rhs = {0};
+ lhs.m128i_i64[0] = _MM1.m64_i64;
- rhs.m128i_i64[0] = _MM2.m64_i64;
+ rhs.m128i_i64[0] = _MM2.m64_i64;
- lhs = _mm_subs_epu8(lhs, rhs);
+ lhs = _mm_subs_epu8(lhs, rhs);
- _MM1.m64_i64 = lhs.m128i_i64[0];
- return _MM1;
+ _MM1.m64_i64 = lhs.m128i_i64[0];
+ return _MM1;
}
__m64 _m_psrawi(__m64 _M, int _Count)
{
- __m128i lhs = {0};
- lhs.m128i_i64[0] = _M.m64_i64;
+ __m128i lhs = {0};
+ lhs.m128i_i64[0] = _M.m64_i64;
- lhs = _mm_srai_epi16(lhs, _Count);
+ lhs = _mm_srai_epi16(lhs, _Count);
- _M.m64_i64 = lhs.m128i_i64[0];
- return _M;
+ _M.m64_i64 = lhs.m128i_i64[0];
+ return _M;
}
__m64 _m_psubw(__m64 _MM1, __m64 _MM2)
{
- __m128i lhs = {0}, rhs = {0};
- lhs.m128i_i64[0] = _MM1.m64_i64;
+ __m128i lhs = {0}, rhs = {0};
+ lhs.m128i_i64[0] = _MM1.m64_i64;
- rhs.m128i_i64[0] = _MM2.m64_i64;
+ rhs.m128i_i64[0] = _MM2.m64_i64;
- lhs = _mm_sub_epi16(lhs, rhs);
+ lhs = _mm_sub_epi16(lhs, rhs);
- _MM1.m64_i64 = lhs.m128i_i64[0];
- return _MM1;
+ _MM1.m64_i64 = lhs.m128i_i64[0];
+ return _MM1;
}
__m64 _m_psllwi(__m64 _M, int _Count)
{
- __m128i lhs = {0};
- lhs.m128i_i64[0] = _M.m64_i64;
+ __m128i lhs = {0};
+ lhs.m128i_i64[0] = _M.m64_i64;
- lhs = _mm_slli_epi16(lhs, _Count);
+ lhs = _mm_slli_epi16(lhs, _Count);
- _M.m64_i64 = lhs.m128i_i64[0];
- return _M;
+ _M.m64_i64 = lhs.m128i_i64[0];
+ return _M;
}
__m64 _m_paddusw(__m64 _MM1, __m64 _MM2)
{
- __m128i lhs = {0}, rhs = {0};
- lhs.m128i_i64[0] = _MM1.m64_i64;
+ __m128i lhs = {0}, rhs = {0};
+ lhs.m128i_i64[0] = _MM1.m64_i64;
- rhs.m128i_i64[0] = _MM2.m64_i64;
+ rhs.m128i_i64[0] = _MM2.m64_i64;
- lhs = _mm_adds_epu16(lhs, rhs);
+ lhs = _mm_adds_epu16(lhs, rhs);
- _MM1.m64_i64 = lhs.m128i_i64[0];
- return _MM1;
+ _MM1.m64_i64 = lhs.m128i_i64[0];
+ return _MM1;
}
__m64 _m_pxor(__m64 _MM1, __m64 _MM2)
{
- __m128i lhs = {0}, rhs = {0};
- lhs.m128i_i64[0] = _MM1.m64_i64;
+ __m128i lhs = {0}, rhs = {0};
+ lhs.m128i_i64[0] = _MM1.m64_i64;
- rhs.m128i_i64[0] = _MM2.m64_i64;
+ rhs.m128i_i64[0] = _MM2.m64_i64;
- lhs = _mm_xor_si128(lhs, rhs);
+ lhs = _mm_xor_si128(lhs, rhs);
- _MM1.m64_i64 = lhs.m128i_i64[0];
- return _MM1;
+ _MM1.m64_i64 = lhs.m128i_i64[0];
+ return _MM1;
}
__m64 _m_pslldi(__m64 _M, int _Count)
{
- __m128i lhs = {0};
- lhs.m128i_i64[0] = _M.m64_i64;
+ __m128i lhs = {0};
+ lhs.m128i_i64[0] = _M.m64_i64;
- lhs = _mm_slli_epi32(lhs, _Count);
+ lhs = _mm_slli_epi32(lhs, _Count);
- _M.m64_i64 = lhs.m128i_i64[0];
- return _M;
+ _M.m64_i64 = lhs.m128i_i64[0];
+ return _M;
}
__m64 _m_punpckhbw(__m64 _MM1, __m64 _MM2)
{
- __m128i lhs = {0}, rhs = {0};
- lhs.m128i_i8[ 8] = _MM1.m64_i8[4];
- lhs.m128i_i8[ 9] = _MM1.m64_i8[5];
- lhs.m128i_i8[10] = _MM1.m64_i8[6];
- lhs.m128i_i8[11] = _MM1.m64_i8[7];
+ __m128i lhs = {0}, rhs = {0};
+ lhs.m128i_i8[ 8] = _MM1.m64_i8[4];
+ lhs.m128i_i8[ 9] = _MM1.m64_i8[5];
+ lhs.m128i_i8[10] = _MM1.m64_i8[6];
+ lhs.m128i_i8[11] = _MM1.m64_i8[7];
- rhs.m128i_i8[ 8] = _MM2.m64_i8[4];
- rhs.m128i_i8[ 9] = _MM2.m64_i8[5];
- rhs.m128i_i8[10] = _MM2.m64_i8[6];
- rhs.m128i_i8[11] = _MM2.m64_i8[7];
+ rhs.m128i_i8[ 8] = _MM2.m64_i8[4];
+ rhs.m128i_i8[ 9] = _MM2.m64_i8[5];
+ rhs.m128i_i8[10] = _MM2.m64_i8[6];
+ rhs.m128i_i8[11] = _MM2.m64_i8[7];
- lhs = _mm_unpackhi_epi8(lhs, rhs);
+ lhs = _mm_unpackhi_epi8(lhs, rhs);
- _MM1.m64_i64 = lhs.m128i_i64[0];
- return _MM1;
+ _MM1.m64_i64 = lhs.m128i_i64[0];
+ return _MM1;
}
__m64 _m_punpcklwd(__m64 _MM1, __m64 _MM2)
{
- __m128i lhs = {0}, rhs = {0};
- lhs.m128i_i64[0] = _MM1.m64_i64;
+ __m128i lhs = {0}, rhs = {0};
+ lhs.m128i_i64[0] = _MM1.m64_i64;
- rhs.m128i_i64[0] = _MM2.m64_i64;
+ rhs.m128i_i64[0] = _MM2.m64_i64;
- lhs = _mm_unpacklo_epi16(lhs, rhs);
+ lhs = _mm_unpacklo_epi16(lhs, rhs);
- _MM1.m64_i64 = lhs.m128i_i64[0];
- return _MM1;
+ _MM1.m64_i64 = lhs.m128i_i64[0];
+ return _MM1;
}
__m64 _m_punpckldq(__m64 _MM1, __m64 _MM2)
{
- __m128i lhs = {0}, rhs = {0};
- lhs.m128i_i64[0] = _MM1.m64_i64;
+ __m128i lhs = {0}, rhs = {0};
+ lhs.m128i_i64[0] = _MM1.m64_i64;
- rhs.m128i_i64[0] = _MM2.m64_i64;
+ rhs.m128i_i64[0] = _MM2.m64_i64;
- lhs = _mm_unpacklo_epi32(lhs, rhs);
+ lhs = _mm_unpacklo_epi32(lhs, rhs);
- _MM1.m64_i64 = lhs.m128i_i64[0];
- return _MM1;
+ _MM1.m64_i64 = lhs.m128i_i64[0];
+ return _MM1;
}
__m64 _m_pcmpgtw(__m64 _MM1, __m64 _MM2)
{
- __m128i lhs = {0}, rhs = {0};
- lhs.m128i_i64[0] = _MM1.m64_i64;
+ __m128i lhs = {0}, rhs = {0};
+ lhs.m128i_i64[0] = _MM1.m64_i64;
- rhs.m128i_i64[0] = _MM2.m64_i64;
+ rhs.m128i_i64[0] = _MM2.m64_i64;
- lhs = _mm_cmpgt_epi16(lhs, rhs);
+ lhs = _mm_cmpgt_epi16(lhs, rhs);
- _MM1.m64_i64 = lhs.m128i_i64[0];
- return _MM1;
+ _MM1.m64_i64 = lhs.m128i_i64[0];
+ return _MM1;
}
__m64 _m_pcmpgtd(__m64 _MM1, __m64 _MM2)
{
- __m128i lhs = {0}, rhs = {0};
- lhs.m128i_i64[0] = _MM1.m64_i64;
+ __m128i lhs = {0}, rhs = {0};
+ lhs.m128i_i64[0] = _MM1.m64_i64;
- rhs.m128i_i64[0] = _MM2.m64_i64;
+ rhs.m128i_i64[0] = _MM2.m64_i64;
- lhs = _mm_cmpgt_epi32(lhs, rhs);
+ lhs = _mm_cmpgt_epi32(lhs, rhs);
- _MM1.m64_i64 = lhs.m128i_i64[0];
- return _MM1;
+ _MM1.m64_i64 = lhs.m128i_i64[0];
+ return _MM1;
}
__m64 _m_pcmpeqb(__m64 _MM1, __m64 _MM2)
{
- __m128i lhs = {0}, rhs = {0};
- lhs.m128i_i64[0] = _MM1.m64_i64;
+ __m128i lhs = {0}, rhs = {0};
+ lhs.m128i_i64[0] = _MM1.m64_i64;
- rhs.m128i_i64[0] = _MM2.m64_i64;
+ rhs.m128i_i64[0] = _MM2.m64_i64;
- lhs = _mm_cmpeq_epi8(lhs, rhs);
+ lhs = _mm_cmpeq_epi8(lhs, rhs);
- _MM1.m64_i64 = lhs.m128i_i64[0];
- return _MM1;
+ _MM1.m64_i64 = lhs.m128i_i64[0];
+ return _MM1;
}
__m64 _m_pcmpeqd(__m64 _MM1, __m64 _MM2)
{
- __m128i lhs = {0}, rhs = {0};
- lhs.m128i_i64[0] = _MM1.m64_i64;
+ __m128i lhs = {0}, rhs = {0};
+ lhs.m128i_i64[0] = _MM1.m64_i64;
- rhs.m128i_i64[0] = _MM2.m64_i64;
+ rhs.m128i_i64[0] = _MM2.m64_i64;
- lhs = _mm_cmpeq_epi32(lhs, rhs);
+ lhs = _mm_cmpeq_epi32(lhs, rhs);
- _MM1.m64_i64 = lhs.m128i_i64[0];
- return _MM1;
+ _MM1.m64_i64 = lhs.m128i_i64[0];
+ return _MM1;
}
__m64 _m_punpckhwd(__m64 _MM1, __m64 _MM2)
{
- __m128i lhs = {0}, rhs = {0};
- lhs.m128i_i16[4] = _MM1.m64_i16[2];
- lhs.m128i_i16[5] = _MM1.m64_i16[3];
+ __m128i lhs = {0}, rhs = {0};
+ lhs.m128i_i16[4] = _MM1.m64_i16[2];
+ lhs.m128i_i16[5] = _MM1.m64_i16[3];
- rhs.m128i_i16[4] = _MM2.m64_i16[2];
- rhs.m128i_i16[5] = _MM2.m64_i16[3];
+ rhs.m128i_i16[4] = _MM2.m64_i16[2];
+ rhs.m128i_i16[5] = _MM2.m64_i16[3];
- lhs = _mm_unpackhi_epi16(lhs, rhs);
+ lhs = _mm_unpackhi_epi16(lhs, rhs);
- _MM1.m64_i64 = lhs.m128i_i64[0];
- return _MM1;
+ _MM1.m64_i64 = lhs.m128i_i64[0];
+ return _MM1;
}
__m64 _m_punpckhdq(__m64 _MM1, __m64 _MM2)
{
- __m128i lhs = {0}, rhs = {0};
- lhs.m128i_i32[2] = _MM1.m64_i32[1];
+ __m128i lhs = {0}, rhs = {0};
+ lhs.m128i_i32[2] = _MM1.m64_i32[1];
- rhs.m128i_i32[2] = _MM2.m64_i32[1];
+ rhs.m128i_i32[2] = _MM2.m64_i32[1];
- lhs = _mm_unpackhi_epi32(lhs, rhs);
+ lhs = _mm_unpackhi_epi32(lhs, rhs);
- _MM1.m64_i64 = lhs.m128i_i64[0];
- return _MM1;
+ _MM1.m64_i64 = lhs.m128i_i64[0];
+ return _MM1;
}
__m64 _m_psrldi(__m64 _M, int _Count)
{
- __m128i lhs = {0};
- lhs.m128i_i64[0] = _M.m64_i64;
+ __m128i lhs = {0};
+ lhs.m128i_i64[0] = _M.m64_i64;
- lhs = _mm_srli_epi32(lhs, _Count);
+ lhs = _mm_srli_epi32(lhs, _Count);
- _M.m64_i64 = lhs.m128i_i64[0];
- return _M;
+ _M.m64_i64 = lhs.m128i_i64[0];
+ return _M;
}
__m64 _m_psubd(__m64 _MM1, __m64 _MM2)
{
- __m128i lhs = {0}, rhs = {0};
- lhs.m128i_i64[0] = _MM1.m64_i64;
+ __m128i lhs = {0}, rhs = {0};
+ lhs.m128i_i64[0] = _MM1.m64_i64;
- rhs.m128i_i64[0] = _MM2.m64_i64;
+ rhs.m128i_i64[0] = _MM2.m64_i64;
- lhs = _mm_sub_epi32(lhs, rhs);
+ lhs = _mm_sub_epi32(lhs, rhs);
- _MM1.m64_i64 = lhs.m128i_i64[0];
- return _MM1;
+ _MM1.m64_i64 = lhs.m128i_i64[0];
+ return _MM1;
}
__m64 _m_pmulhw(__m64 _MM1, __m64 _MM2)
{
- __m128i lhs = {0}, rhs = {0};
- lhs.m128i_i64[0] = _MM1.m64_i64;
+ __m128i lhs = {0}, rhs = {0};
+ lhs.m128i_i64[0] = _MM1.m64_i64;
- rhs.m128i_i64[0] = _MM2.m64_i64;
+ rhs.m128i_i64[0] = _MM2.m64_i64;
- lhs = _mm_mulhi_epi16(lhs, rhs);
+ lhs = _mm_mulhi_epi16(lhs, rhs);
- _MM1.m64_i64 = lhs.m128i_i64[0];
- return _MM1;
+ _MM1.m64_i64 = lhs.m128i_i64[0];
+ return _MM1;
}
__m64 _m_psllqi(__m64 _M, int _Count)
{
- __m128i lhs = {0};
- lhs.m128i_i64[0] = _M.m64_i64;
+ __m128i lhs = {0};
+ lhs.m128i_i64[0] = _M.m64_i64;
- lhs = _mm_slli_epi64(lhs, _Count);
+ lhs = _mm_slli_epi64(lhs, _Count);
- _M.m64_i64 = lhs.m128i_i64[0];
- return _M;
+ _M.m64_i64 = lhs.m128i_i64[0];
+ return _M;
}
__m64 _m_pcmpeqw(__m64 _MM1, __m64 _MM2)
{
- __m128i lhs = {0}, rhs = {0};
- lhs.m128i_i64[0] = _MM1.m64_i64;
+ __m128i lhs = {0}, rhs = {0};
+ lhs.m128i_i64[0] = _MM1.m64_i64;
- rhs.m128i_i64[0] = _MM2.m64_i64;
+ rhs.m128i_i64[0] = _MM2.m64_i64;
- lhs = _mm_cmpeq_epi16(lhs, rhs);
+ lhs = _mm_cmpeq_epi16(lhs, rhs);
- _MM1.m64_i64 = lhs.m128i_i64[0];
- return _MM1;
+ _MM1.m64_i64 = lhs.m128i_i64[0];
+ return _MM1;
}
__m64 _m_paddsb(__m64 _MM1, __m64 _MM2)
{
- __m128i lhs = {0}, rhs = {0};
- lhs.m128i_i64[0] = _MM1.m64_i64;
+ __m128i lhs = {0}, rhs = {0};
+ lhs.m128i_i64[0] = _MM1.m64_i64;
- rhs.m128i_i64[0] = _MM2.m64_i64;
+ rhs.m128i_i64[0] = _MM2.m64_i64;
- lhs = _mm_adds_epi8(lhs, rhs);
+ lhs = _mm_adds_epi8(lhs, rhs);
- _MM1.m64_i64 = lhs.m128i_i64[0];
- return _MM1;
+ _MM1.m64_i64 = lhs.m128i_i64[0];
+ return _MM1;
}
__m64 _m_packsswb(__m64 _MM1, __m64 _MM2)
{
- __m128i lhs = {0}, rhs = {0};
- lhs.m128i_i64[0] = _MM1.m64_i64;
+ __m128i lhs = {0}, rhs = {0};
+ lhs.m128i_i64[0] = _MM1.m64_i64;
- rhs.m128i_i64[0] = _MM2.m64_i64;
+ rhs.m128i_i64[0] = _MM2.m64_i64;
- lhs = _mm_packs_epi16(lhs, rhs);
+ lhs = _mm_packs_epi16(lhs, rhs);
- _MM1.m64_i32[0] = lhs.m128i_i32[0];
- _MM1.m64_i32[1] = lhs.m128i_i32[2];
- return _MM1;
+ _MM1.m64_i32[0] = lhs.m128i_i32[0];
+ _MM1.m64_i32[1] = lhs.m128i_i32[2];
+ return _MM1;
}
__m64 _m_psradi(__m64 _M, int _Count)
{
- __m128i lhs = {0};
- lhs.m128i_i64[0] = _M.m64_i64;
+ __m128i lhs = {0};
+ lhs.m128i_i64[0] = _M.m64_i64;
- lhs = _mm_srai_epi32(lhs, _Count);
+ lhs = _mm_srai_epi32(lhs, _Count);
- _M.m64_i64 = lhs.m128i_i64[0];
- return _M;
+ _M.m64_i64 = lhs.m128i_i64[0];
+ return _M;
}
__m64 _m_paddsw(__m64 _MM1, __m64 _MM2)
{
- __m128i lhs = {0}, rhs = {0};
- lhs.m128i_i64[0] = _MM1.m64_i64;
+ __m128i lhs = {0}, rhs = {0};
+ lhs.m128i_i64[0] = _MM1.m64_i64;
- rhs.m128i_i64[0] = _MM2.m64_i64;
+ rhs.m128i_i64[0] = _MM2.m64_i64;
- lhs = _mm_adds_epi16(lhs, rhs);
+ lhs = _mm_adds_epi16(lhs, rhs);
- _MM1.m64_i64 = lhs.m128i_i64[0];
- return _MM1;
+ _MM1.m64_i64 = lhs.m128i_i64[0];
+ return _MM1;
}
__m64 _m_psubusw(__m64 _MM1, __m64 _MM2)
{
- __m128i lhs = {0}, rhs = {0};
- lhs.m128i_i64[0] = _MM1.m64_i64;
+ __m128i lhs = {0}, rhs = {0};
+ lhs.m128i_i64[0] = _MM1.m64_i64;
- rhs.m128i_i64[0] = _MM2.m64_i64;
+ rhs.m128i_i64[0] = _MM2.m64_i64;
- lhs = _mm_subs_epu16(lhs, rhs);
+ lhs = _mm_subs_epu16(lhs, rhs);
- _MM1.m64_i64 = lhs.m128i_i64[0];
- return _MM1;
+ _MM1.m64_i64 = lhs.m128i_i64[0];
+ return _MM1;
}
__m64 _m_packssdw(__m64 _MM1, __m64 _MM2)
{
- __m128i lhs = {0}, rhs = {0};
- lhs.m128i_i32[0] = _MM1.m64_i32[0];
- lhs.m128i_i32[1] = _MM1.m64_i32[1];
- lhs.m128i_i32[2] = _MM2.m64_i32[0];
- lhs.m128i_i32[3] = _MM2.m64_i32[1];
+ __m128i lhs = {0}, rhs = {0};
+ lhs.m128i_i32[0] = _MM1.m64_i32[0];
+ lhs.m128i_i32[1] = _MM1.m64_i32[1];
+ lhs.m128i_i32[2] = _MM2.m64_i32[0];
+ lhs.m128i_i32[3] = _MM2.m64_i32[1];
- lhs = _mm_packs_epi32(lhs, rhs);
+ lhs = _mm_packs_epi32(lhs, rhs);
- _MM1.m64_i64 = lhs.m128i_i64[0];
- return _MM1;
+ _MM1.m64_i64 = lhs.m128i_i64[0];
+ return _MM1;
}
__m64 _m_psraw(__m64 _MM1, __m64 _MM2)
{
- __m128i lhs = {0}, rhs = {0};
- lhs.m128i_i64[0] = _MM1.m64_i64;
+ __m128i lhs = {0}, rhs = {0};
+ lhs.m128i_i64[0] = _MM1.m64_i64;
- rhs.m128i_i64[0] = _MM2.m64_i64;
+ rhs.m128i_i64[0] = _MM2.m64_i64;
- lhs = _mm_sra_epi16(lhs, rhs);
+ lhs = _mm_sra_epi16(lhs, rhs);
- _MM1.m64_i64 = lhs.m128i_i64[0];
- return _MM1;
+ _MM1.m64_i64 = lhs.m128i_i64[0];
+ return _MM1;
}
// SSE
__m64 _m_pmaxub(__m64 _MM1, __m64 _MM2)
{
- __m128i lhs = {0}, rhs = {0};
- lhs.m128i_i64[0] = _MM1.m64_i64;
+ __m128i lhs = {0}, rhs = {0};
+ lhs.m128i_i64[0] = _MM1.m64_i64;
- rhs.m128i_i64[0] = _MM2.m64_i64;
+ rhs.m128i_i64[0] = _MM2.m64_i64;
- lhs = _mm_max_epu8(lhs, rhs);
+ lhs = _mm_max_epu8(lhs, rhs);
- _MM1.m64_i64 = lhs.m128i_i64[0];
- return _MM1;
+ _MM1.m64_i64 = lhs.m128i_i64[0];
+ return _MM1;
}
__m64 _m_pminub(__m64 _MM1, __m64 _MM2)
{
- __m128i lhs = {0}, rhs = {0};
- lhs.m128i_i64[0] = _MM1.m64_i64;
+ __m128i lhs = {0}, rhs = {0};
+ lhs.m128i_i64[0] = _MM1.m64_i64;
- rhs.m128i_i64[0] = _MM2.m64_i64;
+ rhs.m128i_i64[0] = _MM2.m64_i64;
- lhs = _mm_min_epu8(lhs, rhs);
+ lhs = _mm_min_epu8(lhs, rhs);
- _MM1.m64_i64 = lhs.m128i_i64[0];
- return _MM1;
+ _MM1.m64_i64 = lhs.m128i_i64[0];
+ return _MM1;
}
__m64 _m_pavgb(__m64 _MM1, __m64 _MM2)
{
- __m128i lhs = {0}, rhs = {0};
- lhs.m128i_i64[0] = _MM1.m64_i64;
+ __m128i lhs = {0}, rhs = {0};
+ lhs.m128i_i64[0] = _MM1.m64_i64;
- rhs.m128i_i64[0] = _MM2.m64_i64;
+ rhs.m128i_i64[0] = _MM2.m64_i64;
- lhs = _mm_avg_epu8(lhs, rhs);
+ lhs = _mm_avg_epu8(lhs, rhs);
- _MM1.m64_i64 = lhs.m128i_i64[0];
- return _MM1;
+ _MM1.m64_i64 = lhs.m128i_i64[0];
+ return _MM1;
}
__m64 _m_pshufw(__m64 _MM1, int _Imm)
{
- __m128i lhs = {0};
- lhs.m128i_i64[0] = _MM1.m64_i64;
-
- switch(_Imm)
- {
- case 0:
- lhs = _mm_shufflelo_epi16(lhs, 0);
- break;
- case 1:
- lhs = _mm_shufflelo_epi16(lhs, 1);
- break;
- case 2:
- lhs = _mm_shufflelo_epi16(lhs, 2);
- break;
- case 3:
- lhs = _mm_shufflelo_epi16(lhs, 3);
- break;
- case 4:
- lhs = _mm_shufflelo_epi16(lhs, 4);
- break;
- case 5:
- lhs = _mm_shufflelo_epi16(lhs, 5);
- break;
- case 6:
- lhs = _mm_shufflelo_epi16(lhs, 6);
- break;
- case 7:
- lhs = _mm_shufflelo_epi16(lhs, 7);
- break;
- case 8:
- lhs = _mm_shufflelo_epi16(lhs, 8);
- break;
- case 9:
- lhs = _mm_shufflelo_epi16(lhs, 9);
- break;
- case 10:
- lhs = _mm_shufflelo_epi16(lhs, 10);
- break;
- case 11:
- lhs = _mm_shufflelo_epi16(lhs, 11);
- break;
- case 12:
- lhs = _mm_shufflelo_epi16(lhs, 12);
- break;
- case 13:
- lhs = _mm_shufflelo_epi16(lhs, 13);
- break;
- case 14:
- lhs = _mm_shufflelo_epi16(lhs, 14);
- break;
- case 15:
- lhs = _mm_shufflelo_epi16(lhs, 15);
- break;
- case 16:
- lhs = _mm_shufflelo_epi16(lhs, 16);
- break;
- case 17:
- lhs = _mm_shufflelo_epi16(lhs, 17);
- break;
- case 18:
- lhs = _mm_shufflelo_epi16(lhs, 18);
- break;
- case 19:
- lhs = _mm_shufflelo_epi16(lhs, 19);
- break;
- case 20:
- lhs = _mm_shufflelo_epi16(lhs, 20);
- break;
- case 21:
- lhs = _mm_shufflelo_epi16(lhs, 21);
- break;
- case 22:
- lhs = _mm_shufflelo_epi16(lhs, 22);
- break;
- case 23:
- lhs = _mm_shufflelo_epi16(lhs, 23);
- break;
- case 24:
- lhs = _mm_shufflelo_epi16(lhs, 24);
- break;
- case 25:
- lhs = _mm_shufflelo_epi16(lhs, 25);
- break;
- case 26:
- lhs = _mm_shufflelo_epi16(lhs, 26);
- break;
- case 27:
- lhs = _mm_shufflelo_epi16(lhs, 27);
- break;
- case 28:
- lhs = _mm_shufflelo_epi16(lhs, 28);
- break;
- case 29:
- lhs = _mm_shufflelo_epi16(lhs, 29);
- break;
- case 30:
- lhs = _mm_shufflelo_epi16(lhs, 30);
- break;
- case 31:
- lhs = _mm_shufflelo_epi16(lhs, 31);
- break;
- case 32:
- lhs = _mm_shufflelo_epi16(lhs, 32);
- break;
- case 33:
- lhs = _mm_shufflelo_epi16(lhs, 33);
- break;
- case 34:
- lhs = _mm_shufflelo_epi16(lhs, 34);
- break;
- case 35:
- lhs = _mm_shufflelo_epi16(lhs, 35);
- break;
- case 36:
- lhs = _mm_shufflelo_epi16(lhs, 36);
- break;
- case 37:
- lhs = _mm_shufflelo_epi16(lhs, 37);
- break;
- case 38:
- lhs = _mm_shufflelo_epi16(lhs, 38);
- break;
- case 39:
- lhs = _mm_shufflelo_epi16(lhs, 39);
- break;
- case 40:
- lhs = _mm_shufflelo_epi16(lhs, 40);
- break;
- case 41:
- lhs = _mm_shufflelo_epi16(lhs, 41);
- break;
- case 42:
- lhs = _mm_shufflelo_epi16(lhs, 42);
- break;
- case 43:
- lhs = _mm_shufflelo_epi16(lhs, 43);
- break;
- case 44:
- lhs = _mm_shufflelo_epi16(lhs, 44);
- break;
- case 45:
- lhs = _mm_shufflelo_epi16(lhs, 45);
- break;
- case 46:
- lhs = _mm_shufflelo_epi16(lhs, 46);
- break;
- case 47:
- lhs = _mm_shufflelo_epi16(lhs, 47);
- break;
- case 48:
- lhs = _mm_shufflelo_epi16(lhs, 48);
- break;
- case 49:
- lhs = _mm_shufflelo_epi16(lhs, 49);
- break;
- case 50:
- lhs = _mm_shufflelo_epi16(lhs, 50);
- break;
- case 51:
- lhs = _mm_shufflelo_epi16(lhs, 51);
- break;
- case 52:
- lhs = _mm_shufflelo_epi16(lhs, 52);
- break;
- case 53:
- lhs = _mm_shufflelo_epi16(lhs, 53);
- break;
- case 54:
- lhs = _mm_shufflelo_epi16(lhs, 54);
- break;
- case 55:
- lhs = _mm_shufflelo_epi16(lhs, 55);
- break;
- case 56:
- lhs = _mm_shufflelo_epi16(lhs, 56);
- break;
- case 57:
- lhs = _mm_shufflelo_epi16(lhs, 57);
- break;
- case 58:
- lhs = _mm_shufflelo_epi16(lhs, 58);
- break;
- case 59:
- lhs = _mm_shufflelo_epi16(lhs, 59);
- break;
- case 60:
- lhs = _mm_shufflelo_epi16(lhs, 60);
- break;
- case 61:
- lhs = _mm_shufflelo_epi16(lhs, 61);
- break;
- case 62:
- lhs = _mm_shufflelo_epi16(lhs, 62);
- break;
- case 63:
- lhs = _mm_shufflelo_epi16(lhs, 63);
- break;
- case 64:
- lhs = _mm_shufflelo_epi16(lhs, 64);
- break;
- case 65:
- lhs = _mm_shufflelo_epi16(lhs, 65);
- break;
- case 66:
- lhs = _mm_shufflelo_epi16(lhs, 66);
- break;
- case 67:
- lhs = _mm_shufflelo_epi16(lhs, 67);
- break;
- case 68:
- lhs = _mm_shufflelo_epi16(lhs, 68);
- break;
- case 69:
- lhs = _mm_shufflelo_epi16(lhs, 69);
- break;
- case 70:
- lhs = _mm_shufflelo_epi16(lhs, 70);
- break;
- case 71:
- lhs = _mm_shufflelo_epi16(lhs, 71);
- break;
- case 72:
- lhs = _mm_shufflelo_epi16(lhs, 72);
- break;
- case 73:
- lhs = _mm_shufflelo_epi16(lhs, 73);
- break;
- case 74:
- lhs = _mm_shufflelo_epi16(lhs, 74);
- break;
- case 75:
- lhs = _mm_shufflelo_epi16(lhs, 75);
- break;
- case 76:
- lhs = _mm_shufflelo_epi16(lhs, 76);
- break;
- case 77:
- lhs = _mm_shufflelo_epi16(lhs, 77);
- break;
- case 78:
- lhs = _mm_shufflelo_epi16(lhs, 78);
- break;
- case 79:
- lhs = _mm_shufflelo_epi16(lhs, 79);
- break;
- case 80:
- lhs = _mm_shufflelo_epi16(lhs, 80);
- break;
- case 81:
- lhs = _mm_shufflelo_epi16(lhs, 81);
- break;
- case 82:
- lhs = _mm_shufflelo_epi16(lhs, 82);
- break;
- case 83:
- lhs = _mm_shufflelo_epi16(lhs, 83);
- break;
- case 84:
- lhs = _mm_shufflelo_epi16(lhs, 84);
- break;
- case 85:
- lhs = _mm_shufflelo_epi16(lhs, 85);
- break;
- case 86:
- lhs = _mm_shufflelo_epi16(lhs, 86);
- break;
- case 87:
- lhs = _mm_shufflelo_epi16(lhs, 87);
- break;
- case 88:
- lhs = _mm_shufflelo_epi16(lhs, 88);
- break;
- case 89:
- lhs = _mm_shufflelo_epi16(lhs, 89);
- break;
- case 90:
- lhs = _mm_shufflelo_epi16(lhs, 90);
- break;
- case 91:
- lhs = _mm_shufflelo_epi16(lhs, 91);
- break;
- case 92:
- lhs = _mm_shufflelo_epi16(lhs, 92);
- break;
- case 93:
- lhs = _mm_shufflelo_epi16(lhs, 93);
- break;
- case 94:
- lhs = _mm_shufflelo_epi16(lhs, 94);
- break;
- case 95:
- lhs = _mm_shufflelo_epi16(lhs, 95);
- break;
- case 96:
- lhs = _mm_shufflelo_epi16(lhs, 96);
- break;
- case 97:
- lhs = _mm_shufflelo_epi16(lhs, 97);
- break;
- case 98:
- lhs = _mm_shufflelo_epi16(lhs, 98);
- break;
- case 99:
- lhs = _mm_shufflelo_epi16(lhs, 99);
- break;
- case 100:
- lhs = _mm_shufflelo_epi16(lhs, 100);
- break;
- case 101:
- lhs = _mm_shufflelo_epi16(lhs, 101);
- break;
- case 102:
- lhs = _mm_shufflelo_epi16(lhs, 102);
- break;
- case 103:
- lhs = _mm_shufflelo_epi16(lhs, 103);
- break;
- case 104:
- lhs = _mm_shufflelo_epi16(lhs, 104);
- break;
- case 105:
- lhs = _mm_shufflelo_epi16(lhs, 105);
- break;
- case 106:
- lhs = _mm_shufflelo_epi16(lhs, 106);
- break;
- case 107:
- lhs = _mm_shufflelo_epi16(lhs, 107);
- break;
- case 108:
- lhs = _mm_shufflelo_epi16(lhs, 108);
- break;
- case 109:
- lhs = _mm_shufflelo_epi16(lhs, 109);
- break;
- case 110:
- lhs = _mm_shufflelo_epi16(lhs, 110);
- break;
- case 111:
- lhs = _mm_shufflelo_epi16(lhs, 111);
- break;
- case 112:
- lhs = _mm_shufflelo_epi16(lhs, 112);
- break;
- case 113:
- lhs = _mm_shufflelo_epi16(lhs, 113);
- break;
- case 114:
- lhs = _mm_shufflelo_epi16(lhs, 114);
- break;
- case 115:
- lhs = _mm_shufflelo_epi16(lhs, 115);
- break;
- case 116:
- lhs = _mm_shufflelo_epi16(lhs, 116);
- break;
- case 117:
- lhs = _mm_shufflelo_epi16(lhs, 117);
- break;
- case 118:
- lhs = _mm_shufflelo_epi16(lhs, 118);
- break;
- case 119:
- lhs = _mm_shufflelo_epi16(lhs, 119);
- break;
- case 120:
- lhs = _mm_shufflelo_epi16(lhs, 120);
- break;
- case 121:
- lhs = _mm_shufflelo_epi16(lhs, 121);
- break;
- case 122:
- lhs = _mm_shufflelo_epi16(lhs, 122);
- break;
- case 123:
- lhs = _mm_shufflelo_epi16(lhs, 123);
- break;
- case 124:
- lhs = _mm_shufflelo_epi16(lhs, 124);
- break;
- case 125:
- lhs = _mm_shufflelo_epi16(lhs, 125);
- break;
- case 126:
- lhs = _mm_shufflelo_epi16(lhs, 126);
- break;
- case 127:
- lhs = _mm_shufflelo_epi16(lhs, 127);
- break;
- case 128:
- lhs = _mm_shufflelo_epi16(lhs, 128);
- break;
- case 129:
- lhs = _mm_shufflelo_epi16(lhs, 129);
- break;
- case 130:
- lhs = _mm_shufflelo_epi16(lhs, 130);
- break;
- case 131:
- lhs = _mm_shufflelo_epi16(lhs, 131);
- break;
- case 132:
- lhs = _mm_shufflelo_epi16(lhs, 132);
- break;
- case 133:
- lhs = _mm_shufflelo_epi16(lhs, 133);
- break;
- case 134:
- lhs = _mm_shufflelo_epi16(lhs, 134);
- break;
- case 135:
- lhs = _mm_shufflelo_epi16(lhs, 135);
- break;
- case 136:
- lhs = _mm_shufflelo_epi16(lhs, 136);
- break;
- case 137:
- lhs = _mm_shufflelo_epi16(lhs, 137);
- break;
- case 138:
- lhs = _mm_shufflelo_epi16(lhs, 138);
- break;
- case 139:
- lhs = _mm_shufflelo_epi16(lhs, 139);
- break;
- case 140:
- lhs = _mm_shufflelo_epi16(lhs, 140);
- break;
- case 141:
- lhs = _mm_shufflelo_epi16(lhs, 141);
- break;
- case 142:
- lhs = _mm_shufflelo_epi16(lhs, 142);
- break;
- case 143:
- lhs = _mm_shufflelo_epi16(lhs, 143);
- break;
- case 144:
- lhs = _mm_shufflelo_epi16(lhs, 144);
- break;
- case 145:
- lhs = _mm_shufflelo_epi16(lhs, 145);
- break;
- case 146:
- lhs = _mm_shufflelo_epi16(lhs, 146);
- break;
- case 147:
- lhs = _mm_shufflelo_epi16(lhs, 147);
- break;
- case 148:
- lhs = _mm_shufflelo_epi16(lhs, 148);
- break;
- case 149:
- lhs = _mm_shufflelo_epi16(lhs, 149);
- break;
- case 150:
- lhs = _mm_shufflelo_epi16(lhs, 150);
- break;
- case 151:
- lhs = _mm_shufflelo_epi16(lhs, 151);
- break;
- case 152:
- lhs = _mm_shufflelo_epi16(lhs, 152);
- break;
- case 153:
- lhs = _mm_shufflelo_epi16(lhs, 153);
- break;
- case 154:
- lhs = _mm_shufflelo_epi16(lhs, 154);
- break;
- case 155:
- lhs = _mm_shufflelo_epi16(lhs, 155);
- break;
- case 156:
- lhs = _mm_shufflelo_epi16(lhs, 156);
- break;
- case 157:
- lhs = _mm_shufflelo_epi16(lhs, 157);
- break;
- case 158:
- lhs = _mm_shufflelo_epi16(lhs, 158);
- break;
- case 159:
- lhs = _mm_shufflelo_epi16(lhs, 159);
- break;
- case 160:
- lhs = _mm_shufflelo_epi16(lhs, 160);
- break;
- case 161:
- lhs = _mm_shufflelo_epi16(lhs, 161);
- break;
- case 162:
- lhs = _mm_shufflelo_epi16(lhs, 162);
- break;
- case 163:
- lhs = _mm_shufflelo_epi16(lhs, 163);
- break;
- case 164:
- lhs = _mm_shufflelo_epi16(lhs, 164);
- break;
- case 165:
- lhs = _mm_shufflelo_epi16(lhs, 165);
- break;
- case 166:
- lhs = _mm_shufflelo_epi16(lhs, 166);
- break;
- case 167:
- lhs = _mm_shufflelo_epi16(lhs, 167);
- break;
- case 168:
- lhs = _mm_shufflelo_epi16(lhs, 168);
- break;
- case 169:
- lhs = _mm_shufflelo_epi16(lhs, 169);
- break;
- case 170:
- lhs = _mm_shufflelo_epi16(lhs, 170);
- break;
- case 171:
- lhs = _mm_shufflelo_epi16(lhs, 171);
- break;
- case 172:
- lhs = _mm_shufflelo_epi16(lhs, 172);
- break;
- case 173:
- lhs = _mm_shufflelo_epi16(lhs, 173);
- break;
- case 174:
- lhs = _mm_shufflelo_epi16(lhs, 174);
- break;
- case 175:
- lhs = _mm_shufflelo_epi16(lhs, 175);
- break;
- case 176:
- lhs = _mm_shufflelo_epi16(lhs, 176);
- break;
- case 177:
- lhs = _mm_shufflelo_epi16(lhs, 177);
- break;
- case 178:
- lhs = _mm_shufflelo_epi16(lhs, 178);
- break;
- case 179:
- lhs = _mm_shufflelo_epi16(lhs, 179);
- break;
- case 180:
- lhs = _mm_shufflelo_epi16(lhs, 180);
- break;
- case 181:
- lhs = _mm_shufflelo_epi16(lhs, 181);
- break;
- case 182:
- lhs = _mm_shufflelo_epi16(lhs, 182);
- break;
- case 183:
- lhs = _mm_shufflelo_epi16(lhs, 183);
- break;
- case 184:
- lhs = _mm_shufflelo_epi16(lhs, 184);
- break;
- case 185:
- lhs = _mm_shufflelo_epi16(lhs, 185);
- break;
- case 186:
- lhs = _mm_shufflelo_epi16(lhs, 186);
- break;
- case 187:
- lhs = _mm_shufflelo_epi16(lhs, 187);
- break;
- case 188:
- lhs = _mm_shufflelo_epi16(lhs, 188);
- break;
- case 189:
- lhs = _mm_shufflelo_epi16(lhs, 189);
- break;
- case 190:
- lhs = _mm_shufflelo_epi16(lhs, 190);
- break;
- case 191:
- lhs = _mm_shufflelo_epi16(lhs, 191);
- break;
- case 192:
- lhs = _mm_shufflelo_epi16(lhs, 192);
- break;
- case 193:
- lhs = _mm_shufflelo_epi16(lhs, 193);
- break;
- case 194:
- lhs = _mm_shufflelo_epi16(lhs, 194);
- break;
- case 195:
- lhs = _mm_shufflelo_epi16(lhs, 195);
- break;
- case 196:
- lhs = _mm_shufflelo_epi16(lhs, 196);
- break;
- case 197:
- lhs = _mm_shufflelo_epi16(lhs, 197);
- break;
- case 198:
- lhs = _mm_shufflelo_epi16(lhs, 198);
- break;
- case 199:
- lhs = _mm_shufflelo_epi16(lhs, 199);
- break;
- case 200:
- lhs = _mm_shufflelo_epi16(lhs, 200);
- break;
- case 201:
- lhs = _mm_shufflelo_epi16(lhs, 201);
- break;
- case 202:
- lhs = _mm_shufflelo_epi16(lhs, 202);
- break;
- case 203:
- lhs = _mm_shufflelo_epi16(lhs, 203);
- break;
- case 204:
- lhs = _mm_shufflelo_epi16(lhs, 204);
- break;
- case 205:
- lhs = _mm_shufflelo_epi16(lhs, 205);
- break;
- case 206:
- lhs = _mm_shufflelo_epi16(lhs, 206);
- break;
- case 207:
- lhs = _mm_shufflelo_epi16(lhs, 207);
- break;
- case 208:
- lhs = _mm_shufflelo_epi16(lhs, 208);
- break;
- case 209:
- lhs = _mm_shufflelo_epi16(lhs, 209);
- break;
- case 210:
- lhs = _mm_shufflelo_epi16(lhs, 210);
- break;
- case 211:
- lhs = _mm_shufflelo_epi16(lhs, 211);
- break;
- case 212:
- lhs = _mm_shufflelo_epi16(lhs, 212);
- break;
- case 213:
- lhs = _mm_shufflelo_epi16(lhs, 213);
- break;
- case 214:
- lhs = _mm_shufflelo_epi16(lhs, 214);
- break;
- case 215:
- lhs = _mm_shufflelo_epi16(lhs, 215);
- break;
- case 216:
- lhs = _mm_shufflelo_epi16(lhs, 216);
- break;
- case 217:
- lhs = _mm_shufflelo_epi16(lhs, 217);
- break;
- case 218:
- lhs = _mm_shufflelo_epi16(lhs, 218);
- break;
- case 219:
- lhs = _mm_shufflelo_epi16(lhs, 219);
- break;
- case 220:
- lhs = _mm_shufflelo_epi16(lhs, 220);
- break;
- case 221:
- lhs = _mm_shufflelo_epi16(lhs, 221);
- break;
- case 222:
- lhs = _mm_shufflelo_epi16(lhs, 222);
- break;
- case 223:
- lhs = _mm_shufflelo_epi16(lhs, 223);
- break;
- case 224:
- lhs = _mm_shufflelo_epi16(lhs, 224);
- break;
- case 225:
- lhs = _mm_shufflelo_epi16(lhs, 225);
- break;
- case 226:
- lhs = _mm_shufflelo_epi16(lhs, 226);
- break;
- case 227:
- lhs = _mm_shufflelo_epi16(lhs, 227);
- break;
- case 228:
- lhs = _mm_shufflelo_epi16(lhs, 228);
- break;
- case 229:
- lhs = _mm_shufflelo_epi16(lhs, 229);
- break;
- case 230:
- lhs = _mm_shufflelo_epi16(lhs, 230);
- break;
- case 231:
- lhs = _mm_shufflelo_epi16(lhs, 231);
- break;
- case 232:
- lhs = _mm_shufflelo_epi16(lhs, 232);
- break;
- case 233:
- lhs = _mm_shufflelo_epi16(lhs, 233);
- break;
- case 234:
- lhs = _mm_shufflelo_epi16(lhs, 234);
- break;
- case 235:
- lhs = _mm_shufflelo_epi16(lhs, 235);
- break;
- case 236:
- lhs = _mm_shufflelo_epi16(lhs, 236);
- break;
- case 237:
- lhs = _mm_shufflelo_epi16(lhs, 237);
- break;
- case 238:
- lhs = _mm_shufflelo_epi16(lhs, 238);
- break;
- case 239:
- lhs = _mm_shufflelo_epi16(lhs, 239);
- break;
- case 240:
- lhs = _mm_shufflelo_epi16(lhs, 240);
- break;
- case 241:
- lhs = _mm_shufflelo_epi16(lhs, 241);
- break;
- case 242:
- lhs = _mm_shufflelo_epi16(lhs, 242);
- break;
- case 243:
- lhs = _mm_shufflelo_epi16(lhs, 243);
- break;
- case 244:
- lhs = _mm_shufflelo_epi16(lhs, 244);
- break;
- case 245:
- lhs = _mm_shufflelo_epi16(lhs, 245);
- break;
- case 246:
- lhs = _mm_shufflelo_epi16(lhs, 246);
- break;
- case 247:
- lhs = _mm_shufflelo_epi16(lhs, 247);
- break;
- case 248:
- lhs = _mm_shufflelo_epi16(lhs, 248);
- break;
- case 249:
- lhs = _mm_shufflelo_epi16(lhs, 249);
- break;
- case 250:
- lhs = _mm_shufflelo_epi16(lhs, 250);
- break;
- case 251:
- lhs = _mm_shufflelo_epi16(lhs, 251);
- break;
- case 252:
- lhs = _mm_shufflelo_epi16(lhs, 252);
- break;
- case 253:
- lhs = _mm_shufflelo_epi16(lhs, 253);
- break;
- case 254:
- lhs = _mm_shufflelo_epi16(lhs, 254);
- break;
- case 255:
- lhs = _mm_shufflelo_epi16(lhs, 255);
- break;
- }
-
- _MM1.m64_i64 = lhs.m128i_i64[0];
- return _MM1;
+ __m128i lhs = {0};
+ lhs.m128i_i64[0] = _MM1.m64_i64;
+
+ switch(_Imm)
+ {
+ case 0: lhs = _mm_shufflelo_epi16(lhs, 0); break;
+ case 1: lhs = _mm_shufflelo_epi16(lhs, 1); break;
+ case 2: lhs = _mm_shufflelo_epi16(lhs, 2); break;
+ case 3: lhs = _mm_shufflelo_epi16(lhs, 3); break;
+ case 4: lhs = _mm_shufflelo_epi16(lhs, 4); break;
+ case 5: lhs = _mm_shufflelo_epi16(lhs, 5); break;
+ case 6: lhs = _mm_shufflelo_epi16(lhs, 6); break;
+ case 7: lhs = _mm_shufflelo_epi16(lhs, 7); break;
+ case 8: lhs = _mm_shufflelo_epi16(lhs, 8); break;
+ case 9: lhs = _mm_shufflelo_epi16(lhs, 9); break;
+ case 10: lhs = _mm_shufflelo_epi16(lhs, 10); break;
+ case 11: lhs = _mm_shufflelo_epi16(lhs, 11); break;
+ case 12: lhs = _mm_shufflelo_epi16(lhs, 12); break;
+ case 13: lhs = _mm_shufflelo_epi16(lhs, 13); break;
+ case 14: lhs = _mm_shufflelo_epi16(lhs, 14); break;
+ case 15: lhs = _mm_shufflelo_epi16(lhs, 15); break;
+ case 16: lhs = _mm_shufflelo_epi16(lhs, 16); break;
+ case 17: lhs = _mm_shufflelo_epi16(lhs, 17); break;
+ case 18: lhs = _mm_shufflelo_epi16(lhs, 18); break;
+ case 19: lhs = _mm_shufflelo_epi16(lhs, 19); break;
+ case 20: lhs = _mm_shufflelo_epi16(lhs, 20); break;
+ case 21: lhs = _mm_shufflelo_epi16(lhs, 21); break;
+ case 22: lhs = _mm_shufflelo_epi16(lhs, 22); break;
+ case 23: lhs = _mm_shufflelo_epi16(lhs, 23); break;
+ case 24: lhs = _mm_shufflelo_epi16(lhs, 24); break;
+ case 25: lhs = _mm_shufflelo_epi16(lhs, 25); break;
+ case 26: lhs = _mm_shufflelo_epi16(lhs, 26); break;
+ case 27: lhs = _mm_shufflelo_epi16(lhs, 27); break;
+ case 28: lhs = _mm_shufflelo_epi16(lhs, 28); break;
+ case 29: lhs = _mm_shufflelo_epi16(lhs, 29); break;
+ case 30: lhs = _mm_shufflelo_epi16(lhs, 30); break;
+ case 31: lhs = _mm_shufflelo_epi16(lhs, 31); break;
+ case 32: lhs = _mm_shufflelo_epi16(lhs, 32); break;
+ case 33: lhs = _mm_shufflelo_epi16(lhs, 33); break;
+ case 34: lhs = _mm_shufflelo_epi16(lhs, 34); break;
+ case 35: lhs = _mm_shufflelo_epi16(lhs, 35); break;
+ case 36: lhs = _mm_shufflelo_epi16(lhs, 36); break;
+ case 37: lhs = _mm_shufflelo_epi16(lhs, 37); break;
+ case 38: lhs = _mm_shufflelo_epi16(lhs, 38); break;
+ case 39: lhs = _mm_shufflelo_epi16(lhs, 39); break;
+ case 40: lhs = _mm_shufflelo_epi16(lhs, 40); break;
+ case 41: lhs = _mm_shufflelo_epi16(lhs, 41); break;
+ case 42: lhs = _mm_shufflelo_epi16(lhs, 42); break;
+ case 43: lhs = _mm_shufflelo_epi16(lhs, 43); break;
+ case 44: lhs = _mm_shufflelo_epi16(lhs, 44); break;
+ case 45: lhs = _mm_shufflelo_epi16(lhs, 45); break;
+ case 46: lhs = _mm_shufflelo_epi16(lhs, 46); break;
+ case 47: lhs = _mm_shufflelo_epi16(lhs, 47); break;
+ case 48: lhs = _mm_shufflelo_epi16(lhs, 48); break;
+ case 49: lhs = _mm_shufflelo_epi16(lhs, 49); break;
+ case 50: lhs = _mm_shufflelo_epi16(lhs, 50); break;
+ case 51: lhs = _mm_shufflelo_epi16(lhs, 51); break;
+ case 52: lhs = _mm_shufflelo_epi16(lhs, 52); break;
+ case 53: lhs = _mm_shufflelo_epi16(lhs, 53); break;
+ case 54: lhs = _mm_shufflelo_epi16(lhs, 54); break;
+ case 55: lhs = _mm_shufflelo_epi16(lhs, 55); break;
+ case 56: lhs = _mm_shufflelo_epi16(lhs, 56); break;
+ case 57: lhs = _mm_shufflelo_epi16(lhs, 57); break;
+ case 58: lhs = _mm_shufflelo_epi16(lhs, 58); break;
+ case 59: lhs = _mm_shufflelo_epi16(lhs, 59); break;
+ case 60: lhs = _mm_shufflelo_epi16(lhs, 60); break;
+ case 61: lhs = _mm_shufflelo_epi16(lhs, 61); break;
+ case 62: lhs = _mm_shufflelo_epi16(lhs, 62); break;
+ case 63: lhs = _mm_shufflelo_epi16(lhs, 63); break;
+ case 64: lhs = _mm_shufflelo_epi16(lhs, 64); break;
+ case 65: lhs = _mm_shufflelo_epi16(lhs, 65); break;
+ case 66: lhs = _mm_shufflelo_epi16(lhs, 66); break;
+ case 67: lhs = _mm_shufflelo_epi16(lhs, 67); break;
+ case 68: lhs = _mm_shufflelo_epi16(lhs, 68); break;
+ case 69: lhs = _mm_shufflelo_epi16(lhs, 69); break;
+ case 70: lhs = _mm_shufflelo_epi16(lhs, 70); break;
+ case 71: lhs = _mm_shufflelo_epi16(lhs, 71); break;
+ case 72: lhs = _mm_shufflelo_epi16(lhs, 72); break;
+ case 73: lhs = _mm_shufflelo_epi16(lhs, 73); break;
+ case 74: lhs = _mm_shufflelo_epi16(lhs, 74); break;
+ case 75: lhs = _mm_shufflelo_epi16(lhs, 75); break;
+ case 76: lhs = _mm_shufflelo_epi16(lhs, 76); break;
+ case 77: lhs = _mm_shufflelo_epi16(lhs, 77); break;
+ case 78: lhs = _mm_shufflelo_epi16(lhs, 78); break;
+ case 79: lhs = _mm_shufflelo_epi16(lhs, 79); break;
+ case 80: lhs = _mm_shufflelo_epi16(lhs, 80); break;
+ case 81: lhs = _mm_shufflelo_epi16(lhs, 81); break;
+ case 82: lhs = _mm_shufflelo_epi16(lhs, 82); break;
+ case 83: lhs = _mm_shufflelo_epi16(lhs, 83); break;
+ case 84: lhs = _mm_shufflelo_epi16(lhs, 84); break;
+ case 85: lhs = _mm_shufflelo_epi16(lhs, 85); break;
+ case 86: lhs = _mm_shufflelo_epi16(lhs, 86); break;
+ case 87: lhs = _mm_shufflelo_epi16(lhs, 87); break;
+ case 88: lhs = _mm_shufflelo_epi16(lhs, 88); break;
+ case 89: lhs = _mm_shufflelo_epi16(lhs, 89); break;
+ case 90: lhs = _mm_shufflelo_epi16(lhs, 90); break;
+ case 91: lhs = _mm_shufflelo_epi16(lhs, 91); break;
+ case 92: lhs = _mm_shufflelo_epi16(lhs, 92); break;
+ case 93: lhs = _mm_shufflelo_epi16(lhs, 93); break;
+ case 94: lhs = _mm_shufflelo_epi16(lhs, 94); break;
+ case 95: lhs = _mm_shufflelo_epi16(lhs, 95); break;
+ case 96: lhs = _mm_shufflelo_epi16(lhs, 96); break;
+ case 97: lhs = _mm_shufflelo_epi16(lhs, 97); break;
+ case 98: lhs = _mm_shufflelo_epi16(lhs, 98); break;
+ case 99: lhs = _mm_shufflelo_epi16(lhs, 99); break;
+ case 100: lhs = _mm_shufflelo_epi16(lhs, 100); break;
+ case 101: lhs = _mm_shufflelo_epi16(lhs, 101); break;
+ case 102: lhs = _mm_shufflelo_epi16(lhs, 102); break;
+ case 103: lhs = _mm_shufflelo_epi16(lhs, 103); break;
+ case 104: lhs = _mm_shufflelo_epi16(lhs, 104); break;
+ case 105: lhs = _mm_shufflelo_epi16(lhs, 105); break;
+ case 106: lhs = _mm_shufflelo_epi16(lhs, 106); break;
+ case 107: lhs = _mm_shufflelo_epi16(lhs, 107); break;
+ case 108: lhs = _mm_shufflelo_epi16(lhs, 108); break;
+ case 109: lhs = _mm_shufflelo_epi16(lhs, 109); break;
+ case 110: lhs = _mm_shufflelo_epi16(lhs, 110); break;
+ case 111: lhs = _mm_shufflelo_epi16(lhs, 111); break;
+ case 112: lhs = _mm_shufflelo_epi16(lhs, 112); break;
+ case 113: lhs = _mm_shufflelo_epi16(lhs, 113); break;
+ case 114: lhs = _mm_shufflelo_epi16(lhs, 114); break;
+ case 115: lhs = _mm_shufflelo_epi16(lhs, 115); break;
+ case 116: lhs = _mm_shufflelo_epi16(lhs, 116); break;
+ case 117: lhs = _mm_shufflelo_epi16(lhs, 117); break;
+ case 118: lhs = _mm_shufflelo_epi16(lhs, 118); break;
+ case 119: lhs = _mm_shufflelo_epi16(lhs, 119); break;
+ case 120: lhs = _mm_shufflelo_epi16(lhs, 120); break;
+ case 121: lhs = _mm_shufflelo_epi16(lhs, 121); break;
+ case 122: lhs = _mm_shufflelo_epi16(lhs, 122); break;
+ case 123: lhs = _mm_shufflelo_epi16(lhs, 123); break;
+ case 124: lhs = _mm_shufflelo_epi16(lhs, 124); break;
+ case 125: lhs = _mm_shufflelo_epi16(lhs, 125); break;
+ case 126: lhs = _mm_shufflelo_epi16(lhs, 126); break;
+ case 127: lhs = _mm_shufflelo_epi16(lhs, 127); break;
+ case 128: lhs = _mm_shufflelo_epi16(lhs, 128); break;
+ case 129: lhs = _mm_shufflelo_epi16(lhs, 129); break;
+ case 130: lhs = _mm_shufflelo_epi16(lhs, 130); break;
+ case 131: lhs = _mm_shufflelo_epi16(lhs, 131); break;
+ case 132: lhs = _mm_shufflelo_epi16(lhs, 132); break;
+ case 133: lhs = _mm_shufflelo_epi16(lhs, 133); break;
+ case 134: lhs = _mm_shufflelo_epi16(lhs, 134); break;
+ case 135: lhs = _mm_shufflelo_epi16(lhs, 135); break;
+ case 136: lhs = _mm_shufflelo_epi16(lhs, 136); break;
+ case 137: lhs = _mm_shufflelo_epi16(lhs, 137); break;
+ case 138: lhs = _mm_shufflelo_epi16(lhs, 138); break;
+ case 139: lhs = _mm_shufflelo_epi16(lhs, 139); break;
+ case 140: lhs = _mm_shufflelo_epi16(lhs, 140); break;
+ case 141: lhs = _mm_shufflelo_epi16(lhs, 141); break;
+ case 142: lhs = _mm_shufflelo_epi16(lhs, 142); break;
+ case 143: lhs = _mm_shufflelo_epi16(lhs, 143); break;
+ case 144: lhs = _mm_shufflelo_epi16(lhs, 144); break;
+ case 145: lhs = _mm_shufflelo_epi16(lhs, 145); break;
+ case 146: lhs = _mm_shufflelo_epi16(lhs, 146); break;
+ case 147: lhs = _mm_shufflelo_epi16(lhs, 147); break;
+ case 148: lhs = _mm_shufflelo_epi16(lhs, 148); break;
+ case 149: lhs = _mm_shufflelo_epi16(lhs, 149); break;
+ case 150: lhs = _mm_shufflelo_epi16(lhs, 150); break;
+ case 151: lhs = _mm_shufflelo_epi16(lhs, 151); break;
+ case 152: lhs = _mm_shufflelo_epi16(lhs, 152); break;
+ case 153: lhs = _mm_shufflelo_epi16(lhs, 153); break;
+ case 154: lhs = _mm_shufflelo_epi16(lhs, 154); break;
+ case 155: lhs = _mm_shufflelo_epi16(lhs, 155); break;
+ case 156: lhs = _mm_shufflelo_epi16(lhs, 156); break;
+ case 157: lhs = _mm_shufflelo_epi16(lhs, 157); break;
+ case 158: lhs = _mm_shufflelo_epi16(lhs, 158); break;
+ case 159: lhs = _mm_shufflelo_epi16(lhs, 159); break;
+ case 160: lhs = _mm_shufflelo_epi16(lhs, 160); break;
+ case 161: lhs = _mm_shufflelo_epi16(lhs, 161); break;
+ case 162: lhs = _mm_shufflelo_epi16(lhs, 162); break;
+ case 163: lhs = _mm_shufflelo_epi16(lhs, 163); break;
+ case 164: lhs = _mm_shufflelo_epi16(lhs, 164); break;
+ case 165: lhs = _mm_shufflelo_epi16(lhs, 165); break;
+ case 166: lhs = _mm_shufflelo_epi16(lhs, 166); break;
+ case 167: lhs = _mm_shufflelo_epi16(lhs, 167); break;
+ case 168: lhs = _mm_shufflelo_epi16(lhs, 168); break;
+ case 169: lhs = _mm_shufflelo_epi16(lhs, 169); break;
+ case 170: lhs = _mm_shufflelo_epi16(lhs, 170); break;
+ case 171: lhs = _mm_shufflelo_epi16(lhs, 171); break;
+ case 172: lhs = _mm_shufflelo_epi16(lhs, 172); break;
+ case 173: lhs = _mm_shufflelo_epi16(lhs, 173); break;
+ case 174: lhs = _mm_shufflelo_epi16(lhs, 174); break;
+ case 175: lhs = _mm_shufflelo_epi16(lhs, 175); break;
+ case 176: lhs = _mm_shufflelo_epi16(lhs, 176); break;
+ case 177: lhs = _mm_shufflelo_epi16(lhs, 177); break;
+ case 178: lhs = _mm_shufflelo_epi16(lhs, 178); break;
+ case 179: lhs = _mm_shufflelo_epi16(lhs, 179); break;
+ case 180: lhs = _mm_shufflelo_epi16(lhs, 180); break;
+ case 181: lhs = _mm_shufflelo_epi16(lhs, 181); break;
+ case 182: lhs = _mm_shufflelo_epi16(lhs, 182); break;
+ case 183: lhs = _mm_shufflelo_epi16(lhs, 183); break;
+ case 184: lhs = _mm_shufflelo_epi16(lhs, 184); break;
+ case 185: lhs = _mm_shufflelo_epi16(lhs, 185); break;
+ case 186: lhs = _mm_shufflelo_epi16(lhs, 186); break;
+ case 187: lhs = _mm_shufflelo_epi16(lhs, 187); break;
+ case 188: lhs = _mm_shufflelo_epi16(lhs, 188); break;
+ case 189: lhs = _mm_shufflelo_epi16(lhs, 189); break;
+ case 190: lhs = _mm_shufflelo_epi16(lhs, 190); break;
+ case 191: lhs = _mm_shufflelo_epi16(lhs, 191); break;
+ case 192: lhs = _mm_shufflelo_epi16(lhs, 192); break;
+ case 193: lhs = _mm_shufflelo_epi16(lhs, 193); break;
+ case 194: lhs = _mm_shufflelo_epi16(lhs, 194); break;
+ case 195: lhs = _mm_shufflelo_epi16(lhs, 195); break;
+ case 196: lhs = _mm_shufflelo_epi16(lhs, 196); break;
+ case 197: lhs = _mm_shufflelo_epi16(lhs, 197); break;
+ case 198: lhs = _mm_shufflelo_epi16(lhs, 198); break;
+ case 199: lhs = _mm_shufflelo_epi16(lhs, 199); break;
+ case 200: lhs = _mm_shufflelo_epi16(lhs, 200); break;
+ case 201: lhs = _mm_shufflelo_epi16(lhs, 201); break;
+ case 202: lhs = _mm_shufflelo_epi16(lhs, 202); break;
+ case 203: lhs = _mm_shufflelo_epi16(lhs, 203); break;
+ case 204: lhs = _mm_shufflelo_epi16(lhs, 204); break;
+ case 205: lhs = _mm_shufflelo_epi16(lhs, 205); break;
+ case 206: lhs = _mm_shufflelo_epi16(lhs, 206); break;
+ case 207: lhs = _mm_shufflelo_epi16(lhs, 207); break;
+ case 208: lhs = _mm_shufflelo_epi16(lhs, 208); break;
+ case 209: lhs = _mm_shufflelo_epi16(lhs, 209); break;
+ case 210: lhs = _mm_shufflelo_epi16(lhs, 210); break;
+ case 211: lhs = _mm_shufflelo_epi16(lhs, 211); break;
+ case 212: lhs = _mm_shufflelo_epi16(lhs, 212); break;
+ case 213: lhs = _mm_shufflelo_epi16(lhs, 213); break;
+ case 214: lhs = _mm_shufflelo_epi16(lhs, 214); break;
+ case 215: lhs = _mm_shufflelo_epi16(lhs, 215); break;
+ case 216: lhs = _mm_shufflelo_epi16(lhs, 216); break;
+ case 217: lhs = _mm_shufflelo_epi16(lhs, 217); break;
+ case 218: lhs = _mm_shufflelo_epi16(lhs, 218); break;
+ case 219: lhs = _mm_shufflelo_epi16(lhs, 219); break;
+ case 220: lhs = _mm_shufflelo_epi16(lhs, 220); break;
+ case 221: lhs = _mm_shufflelo_epi16(lhs, 221); break;
+ case 222: lhs = _mm_shufflelo_epi16(lhs, 222); break;
+ case 223: lhs = _mm_shufflelo_epi16(lhs, 223); break;
+ case 224: lhs = _mm_shufflelo_epi16(lhs, 224); break;
+ case 225: lhs = _mm_shufflelo_epi16(lhs, 225); break;
+ case 226: lhs = _mm_shufflelo_epi16(lhs, 226); break;
+ case 227: lhs = _mm_shufflelo_epi16(lhs, 227); break;
+ case 228: lhs = _mm_shufflelo_epi16(lhs, 228); break;
+ case 229: lhs = _mm_shufflelo_epi16(lhs, 229); break;
+ case 230: lhs = _mm_shufflelo_epi16(lhs, 230); break;
+ case 231: lhs = _mm_shufflelo_epi16(lhs, 231); break;
+ case 232: lhs = _mm_shufflelo_epi16(lhs, 232); break;
+ case 233: lhs = _mm_shufflelo_epi16(lhs, 233); break;
+ case 234: lhs = _mm_shufflelo_epi16(lhs, 234); break;
+ case 235: lhs = _mm_shufflelo_epi16(lhs, 235); break;
+ case 236: lhs = _mm_shufflelo_epi16(lhs, 236); break;
+ case 237: lhs = _mm_shufflelo_epi16(lhs, 237); break;
+ case 238: lhs = _mm_shufflelo_epi16(lhs, 238); break;
+ case 239: lhs = _mm_shufflelo_epi16(lhs, 239); break;
+ case 240: lhs = _mm_shufflelo_epi16(lhs, 240); break;
+ case 241: lhs = _mm_shufflelo_epi16(lhs, 241); break;
+ case 242: lhs = _mm_shufflelo_epi16(lhs, 242); break;
+ case 243: lhs = _mm_shufflelo_epi16(lhs, 243); break;
+ case 244: lhs = _mm_shufflelo_epi16(lhs, 244); break;
+ case 245: lhs = _mm_shufflelo_epi16(lhs, 245); break;
+ case 246: lhs = _mm_shufflelo_epi16(lhs, 246); break;
+ case 247: lhs = _mm_shufflelo_epi16(lhs, 247); break;
+ case 248: lhs = _mm_shufflelo_epi16(lhs, 248); break;
+ case 249: lhs = _mm_shufflelo_epi16(lhs, 249); break;
+ case 250: lhs = _mm_shufflelo_epi16(lhs, 250); break;
+ case 251: lhs = _mm_shufflelo_epi16(lhs, 251); break;
+ case 252: lhs = _mm_shufflelo_epi16(lhs, 252); break;
+ case 253: lhs = _mm_shufflelo_epi16(lhs, 253); break;
+ case 254: lhs = _mm_shufflelo_epi16(lhs, 254); break;
+ case 255: lhs = _mm_shufflelo_epi16(lhs, 255); break;
+ }
+
+ _MM1.m64_i64 = lhs.m128i_i64[0];
+ return _MM1;
}
__m64 _m_pmulhuw(__m64 _MM1, __m64 _MM2)
{
- __m128i lhs = {0}, rhs = {0};
- lhs.m128i_i64[0] = _MM1.m64_i64;
+ __m128i lhs = {0}, rhs = {0};
+ lhs.m128i_i64[0] = _MM1.m64_i64;
- rhs.m128i_i64[0] = _MM2.m64_i64;
+ rhs.m128i_i64[0] = _MM2.m64_i64;
- lhs = _mm_mulhi_epu16(lhs, rhs);
+ lhs = _mm_mulhi_epu16(lhs, rhs);
- _MM1.m64_i64 = lhs.m128i_i64[0];
- return _MM1;
+ _MM1.m64_i64 = lhs.m128i_i64[0];
+ return _MM1;
}
__m64 _m_psadbw(__m64 _MM1, __m64 _MM2)
{
- __m128i lhs = {0}, rhs = {0};
- lhs.m128i_i64[0] = _MM1.m64_i64;
+ __m128i lhs = {0}, rhs = {0};
+ lhs.m128i_i64[0] = _MM1.m64_i64;
- rhs.m128i_i64[0] = _MM2.m64_i64;
+ rhs.m128i_i64[0] = _MM2.m64_i64;
- lhs = _mm_sad_epu8(lhs, rhs);
+ lhs = _mm_sad_epu8(lhs, rhs);
- _MM1.m64_i64 = lhs.m128i_i64[0];
- return _MM1;
+ _MM1.m64_i64 = lhs.m128i_i64[0];
+ return _MM1;
}
__m64 _m_pminsw(__m64 _MM1, __m64 _MM2)
{
- __m128i lhs = {0}, rhs = {0};
- lhs.m128i_i64[0] = _MM1.m64_i64;
+ __m128i lhs = {0}, rhs = {0};
+ lhs.m128i_i64[0] = _MM1.m64_i64;
- rhs.m128i_i64[0] = _MM2.m64_i64;
+ rhs.m128i_i64[0] = _MM2.m64_i64;
- lhs = _mm_min_epi16(lhs, rhs);
+ lhs = _mm_min_epi16(lhs, rhs);
- _MM1.m64_i64 = lhs.m128i_i64[0];
- return _MM1;
+ _MM1.m64_i64 = lhs.m128i_i64[0];
+ return _MM1;
}
__m64 _m_pmaxsw(__m64 _MM1, __m64 _MM2)
{
- __m128i lhs = {0}, rhs = {0};
- lhs.m128i_i64[0] = _MM1.m64_i64;
+ __m128i lhs = {0}, rhs = {0};
+ lhs.m128i_i64[0] = _MM1.m64_i64;
- rhs.m128i_i64[0] = _MM2.m64_i64;
+ rhs.m128i_i64[0] = _MM2.m64_i64;
- lhs = _mm_max_epi16(lhs, rhs);
+ lhs = _mm_max_epi16(lhs, rhs);
- _MM1.m64_i64 = lhs.m128i_i64[0];
- return _MM1;
+ _MM1.m64_i64 = lhs.m128i_i64[0];
+ return _MM1;
}
void _mm_stream_pi(__m64* _MM1, __m64 _MM2)
{
- _mm_stream_si32(&(_MM1->m64_i32[0]), _MM2.m64_i32[0]);
- _mm_stream_si32(&(_MM1->m64_i32[1]), _MM2.m64_i32[1]);
+ _mm_stream_si32(&(_MM1->m64_i32[0]), _MM2.m64_i32[0]);
+ _mm_stream_si32(&(_MM1->m64_i32[1]), _MM2.m64_i32[1]);
}
__m64 _mm_cvt_ps2pi(__m128 _A)
{
- __m64 rv = {0};
- rv.m64_i32[0] = (int)_A.m128_f32[0];
- rv.m64_i32[1] = (int)_A.m128_f32[1];
- return rv;
+ __m64 rv = {0};
+ rv.m64_i32[0] = (int)_A.m128_f32[0];
+ rv.m64_i32[1] = (int)_A.m128_f32[1];
+ return rv;
}
__m128 _mm_cvt_pi2ps(__m128 _MM1, __m64 _MM2)
{
- _MM1.m128_f32[0] = (float)_MM2.m64_i32[0];
- _MM1.m128_f32[1] = (float)_MM2.m64_i32[1];
- return _MM1;
+ _MM1.m128_f32[0] = (float)_MM2.m64_i32[0];
+ _MM1.m128_f32[1] = (float)_MM2.m64_i32[1];
+ return _MM1;
}
// SSE2
__m64 _mm_movepi64_pi64(__m128i _Q)
{
- __m64 rv = {0};
- rv.m64_i64 = _Q.m128i_i64[0];
- return rv;
+ __m64 rv = {0};
+ rv.m64_i64 = _Q.m128i_i64[0];
+ return rv;
}
diff --git a/src/DSUtil/simd.h b/src/DSUtil/simd.h index 46950db59..0d6d68a29 100644 --- a/src/DSUtil/simd.h +++ b/src/DSUtil/simd.h @@ -22,372 +22,114 @@ #undef MMX_INSTRUCTION
#undef SSE2I_INSTRUCTION
-static __forceinline void movq(__m64 &dst, const __m64 &src)
-{
- dst = src;
-}
-static __forceinline void movq(__m64 &dst, const void *src)
-{
- dst = *(__m64*)src;
-}
-static __forceinline void movq(__m64 &dst, const __int64 &src)
-{
- dst = *(__m64*)&src;
-}
-static __forceinline void movq(void *dst, const __m64 &src)
-{
- *(__m64*)dst = src;
-}
-static __forceinline void movntq(void *dst, const __m64 &src)
-{
- _mm_stream_pi((__m64*)dst, src);
-}
-
-static __forceinline void movdqu(__m64 &dst, const void *src)
-{
- dst = *(__m64*)src;
-}
-
-static __forceinline void movd(__m64 &dst, int src)
-{
- dst = _mm_cvtsi32_si64(src);
-}
-static __forceinline void movd(int &dst, const __m64 &src)
-{
- dst = _mm_cvtsi64_si32(src);
-}
-static __forceinline void movd(__m64 &dst, const void *src)
-{
- dst = _mm_cvtsi32_si64(*(const int*)src);
-}
-static __forceinline void movd(void *dst, const __m64 &src)
-{
- *(int*)dst = _mm_cvtsi64_si32(src);
-}
-
-static __forceinline void psllq(__m64 &dst, int i)
-{
- dst = _mm_slli_si64(dst, i);
-}
-static __forceinline void pslld(__m64 &dst, int i)
-{
- dst = _mm_slli_pi32(dst, i);
-}
-static __forceinline void psllw(__m64 &dst, int i)
-{
- dst = _mm_slli_pi16(dst, i);
-}
-static __forceinline void psrlq(__m64 &dst, int i)
-{
- dst = _mm_srli_si64(dst, i);
-}
-static __forceinline void psrld(__m64 &dst, int i)
-{
- dst = _mm_srli_pi32(dst, i);
-}
-static __forceinline void psrlw(__m64 &dst, int i)
-{
- dst = _mm_srli_pi16(dst, i);
-}
-static __forceinline void psraw(__m64 &dst, int i)
-{
- dst = _mm_srai_pi16(dst, i);
-}
-static __forceinline void psraw(__m64 &dst, const __m64 &src)
-{
- dst = _mm_sra_pi16(dst, src);
-}
-static __forceinline void psrad(__m64 &dst, int i)
-{
- dst = _mm_srai_pi32(dst, i);
-}
-
-static __forceinline void prefetcht0(const void *a)
-{
- _mm_prefetch((char*)a, _MM_HINT_T0);
-}
-
-static __forceinline void movaps(__m128 &dst, const __m128 &src)
-{
- dst = src;
-}
-static __forceinline void movaps(void *dst, const __m128 &src)
-{
- *(__m128*)dst = src;
-}
-static __forceinline void movups(__m128 &dst, const void *src)
-{
- dst = _mm_loadu_ps((float*)src);
-}
-static __forceinline void movups(void *dst, const __m128 &src)
-{
- _mm_storeu_ps((float*)dst, src);
-}
-static __forceinline void movss(__m128 &dst, const void *src)
-{
- dst = _mm_load_ss((float*)src);
-}
-static __forceinline void movss(void *dst, const __m128 &src)
-{
- _mm_store_ss((float*)dst, src);
-}
-static __forceinline void movhlps(__m128 &dst, const __m128 &src)
-{
- dst = _mm_movehl_ps(dst, src);
-}
-static __forceinline void movlhps(__m128 &dst, const __m128 &src)
-{
- dst = _mm_movelh_ps(dst, src);
-}
-static __forceinline void movlps(__m128 &dst, const void *src)
-{
- dst = _mm_loadl_pi(dst, (const __m64*)src);
-}
-static __forceinline void movlps(void *dst, const __m128 &src)
-{
- _mm_storel_pi((__m64*)dst, src);
-}
-static __forceinline void movhps(__m128 &dst, const void *src)
-{
- dst = _mm_loadh_pi(dst, (const __m64*)src);
-}
-static __forceinline void movhps(void *dst, const __m128 &src)
-{
- _mm_storeh_pi((__m64*)dst, src);
-}
-
-static __forceinline void xorps(__m128 &dst, const __m128 &src)
-{
- dst = _mm_xor_ps(dst, src);
-}
-static __forceinline void addps(__m128 &dst, const __m128 &src)
-{
- dst = _mm_add_ps(dst, src);
-}
-static __forceinline void addss(__m128 &dst, const __m128 &src)
-{
- dst = _mm_add_ss(dst, src);
-}
-static __forceinline void mulps(__m128 &dst, const __m128 &src)
-{
- dst = _mm_mul_ps(dst, src);
-}
-static __forceinline void mulss(__m128 &dst, const __m128 &src)
-{
- dst = _mm_mul_ss(dst, src);
-}
-static __forceinline void minps(__m128 &dst, const __m128 &src)
-{
- dst = _mm_min_ps(dst, src);
-}
-static __forceinline void cvtps2pi(__m64 &dst, const __m128 &src)
-{
- dst = _mm_cvtps_pi32(src);
-}
-static __forceinline void cmpnltps(__m128 &dst, const __m128 &src)
-{
- dst = _mm_cmpnlt_ps(dst, src);
-}
-static __forceinline void cvtpi2ps(__m128 &dst, const __m64 &src)
-{
- dst = _mm_cvtpi32_ps(dst, src);
-}
-
-static __forceinline void movq(__m128i &dst, const __m128i &src)
-{
- dst = src;
-}
-static __forceinline void movq(__m128i &dst, const void *src)
-{
- dst = *(__m128i*)src;
-}
-static __forceinline void movq(const void *dst, __m128i &src)
-{
- *(__m128i*)dst = src;
-}
-static __forceinline void movd(__m128i &dst, const void *src)
-{
- dst = _mm_loadl_epi64((__m128i*)src);
-}
-static __forceinline void movd(void *dst, const __m128i &src)
-{
- _mm_storel_epi64((__m128i*)dst, src);
-}
-
-static __forceinline void movdqu(__m128i &dst, const void *src)
-{
- dst = _mm_loadu_si128((__m128i*)src);
-}
-static __forceinline void movdqu(__m128i &dst, const __m128i &src)
-{
- dst = _mm_loadu_si128(&src);
-}
-static __forceinline void movdqa(__m128i &dst, const __m128i &src)
-{
- dst = src;
-}
-static __forceinline void movdqa(__m128i &dst, const void * src)
-{
- dst = _mm_load_si128((__m128i*)src);
-}
-static __forceinline void movdqa(void *dst, const __m128i &src)
-{
- _mm_store_si128((__m128i*)dst, src);
-}
-static __forceinline void movntdq(void *dst, const __m128i &src)
-{
- _mm_stream_si128((__m128i*)dst, src);
-}
-static __forceinline void movdq2q(__m64 &dst, const __m128i &src)
-{
- dst = _mm_movepi64_pi64(src);
-}
-
-static __forceinline void psrlw(__m128i &dst, int i)
-{
- dst = _mm_srli_epi16(dst, i);
-}
-static __forceinline void psrlq(__m128i &dst, int i)
-{
- dst = _mm_srli_epi64(dst, i);
-}
-static __forceinline void psrad(__m128i &dst, int i)
-{
- dst = _mm_srai_epi32(dst, i);
-}
-static __forceinline void psraw(__m128i &dst, int i)
-{
- dst = _mm_srai_epi16(dst, i);
-}
-static __forceinline void psraw(__m128i &dst, const __m128i &src)
-{
- dst = _mm_sra_epi16(dst, src);
-}
-static __forceinline void psllw(__m128i &dst, int i)
-{
- dst = _mm_slli_epi16(dst, i);
-}
-static __forceinline void pslld(__m128i &dst, int i)
-{
- dst = _mm_slli_epi32(dst, i);
-}
-static __forceinline void psllq(__m128i &dst, int i)
-{
- dst = _mm_slli_epi64(dst, i);
-}
+static __forceinline void movq(__m64 &dst,const __m64 &src) {dst=src;}
+static __forceinline void movq(__m64 &dst,const void *src) {dst=*(__m64*)src;}
+static __forceinline void movq(__m64 &dst,const __int64 &src) {dst=*(__m64*)&src;}
+static __forceinline void movq(void *dst,const __m64 &src) {*(__m64*)dst=src;}
+static __forceinline void movntq(void *dst,const __m64 &src) {_mm_stream_pi((__m64*)dst,src);}
+
+static __forceinline void movdqu(__m64 &dst,const void *src) {dst=*(__m64*)src;}
+
+static __forceinline void movd(__m64 &dst,int src) {dst=_mm_cvtsi32_si64(src);}
+static __forceinline void movd(int &dst,const __m64 &src) {dst=_mm_cvtsi64_si32(src);}
+static __forceinline void movd(__m64 &dst,const void *src) {dst=_mm_cvtsi32_si64(*(const int*)src);}
+static __forceinline void movd(void *dst,const __m64 &src) {*(int*)dst=_mm_cvtsi64_si32(src);}
+
+static __forceinline void psllq(__m64 &dst,int i) {dst=_mm_slli_si64(dst,i);}
+static __forceinline void pslld(__m64 &dst,int i) {dst=_mm_slli_pi32(dst,i);}
+static __forceinline void psllw(__m64 &dst,int i) {dst=_mm_slli_pi16(dst,i);}
+static __forceinline void psrlq(__m64 &dst,int i) {dst=_mm_srli_si64(dst,i);}
+static __forceinline void psrld(__m64 &dst,int i) {dst=_mm_srli_pi32(dst,i);}
+static __forceinline void psrlw(__m64 &dst,int i) {dst=_mm_srli_pi16(dst,i);}
+static __forceinline void psraw(__m64 &dst,int i) {dst=_mm_srai_pi16(dst,i);}
+static __forceinline void psraw(__m64 &dst,const __m64 &src) {dst=_mm_sra_pi16(dst,src);}
+static __forceinline void psrad(__m64 &dst,int i) {dst=_mm_srai_pi32(dst,i);}
+
+static __forceinline void prefetcht0(const void *a) {_mm_prefetch((char*)a,_MM_HINT_T0);}
+
+static __forceinline void movaps(__m128 &dst,const __m128 &src) {dst=src;}
+static __forceinline void movaps(void *dst,const __m128 &src) {*(__m128*)dst=src;}
+static __forceinline void movups(__m128 &dst,const void *src) {dst=_mm_loadu_ps((float*)src);}
+static __forceinline void movups(void *dst,const __m128 &src) {_mm_storeu_ps((float*)dst,src);}
+static __forceinline void movss(__m128 &dst,const void *src) {dst=_mm_load_ss((float*)src);}
+static __forceinline void movss(void *dst,const __m128 &src) {_mm_store_ss((float*)dst,src);}
+static __forceinline void movhlps(__m128 &dst,const __m128 &src) {dst=_mm_movehl_ps(dst,src);}
+static __forceinline void movlhps(__m128 &dst,const __m128 &src) {dst=_mm_movelh_ps(dst,src);}
+static __forceinline void movlps(__m128 &dst,const void *src) {dst=_mm_loadl_pi(dst,(const __m64*)src);}
+static __forceinline void movlps(void *dst,const __m128 &src) {_mm_storel_pi((__m64*)dst,src);}
+static __forceinline void movhps(__m128 &dst,const void *src) {dst=_mm_loadh_pi(dst,(const __m64*)src);}
+static __forceinline void movhps(void *dst,const __m128 &src) {_mm_storeh_pi((__m64*)dst,src);}
+
+static __forceinline void xorps(__m128 &dst,const __m128 &src) {dst=_mm_xor_ps(dst,src);}
+static __forceinline void addps(__m128 &dst,const __m128 &src) {dst=_mm_add_ps(dst,src);}
+static __forceinline void addss(__m128 &dst,const __m128 &src) {dst=_mm_add_ss(dst,src);}
+static __forceinline void mulps(__m128 &dst,const __m128 &src) {dst=_mm_mul_ps(dst,src);}
+static __forceinline void mulss(__m128 &dst,const __m128 &src) {dst=_mm_mul_ss(dst,src);}
+static __forceinline void minps(__m128 &dst,const __m128 &src) {dst=_mm_min_ps(dst,src);}
+static __forceinline void cvtps2pi(__m64 &dst,const __m128 &src) {dst=_mm_cvtps_pi32(src);}
+static __forceinline void cmpnltps(__m128 &dst,const __m128 &src) {dst=_mm_cmpnlt_ps(dst,src);}
+static __forceinline void cvtpi2ps(__m128 &dst,const __m64 &src) {dst=_mm_cvtpi32_ps(dst,src);}
+
+static __forceinline void movq(__m128i &dst,const __m128i &src) {dst=src;}
+static __forceinline void movq(__m128i &dst,const void *src) {dst=*(__m128i*)src;}
+static __forceinline void movq(const void *dst,__m128i &src) {*(__m128i*)dst=src;}
+static __forceinline void movd(__m128i &dst,const void *src) {dst=_mm_loadl_epi64((__m128i*)src);}
+static __forceinline void movd(void *dst,const __m128i &src) {_mm_storel_epi64((__m128i*)dst,src);}
+
+static __forceinline void movdqu(__m128i &dst,const void *src) {dst=_mm_loadu_si128((__m128i*)src);}
+static __forceinline void movdqu(__m128i &dst,const __m128i &src) {dst=_mm_loadu_si128(&src);}
+static __forceinline void movdqa(__m128i &dst,const __m128i &src) {dst=src;}
+static __forceinline void movdqa(__m128i &dst,const void * src) {dst=_mm_load_si128((__m128i*)src);}
+static __forceinline void movdqa(void *dst,const __m128i &src) {_mm_store_si128((__m128i*)dst,src);}
+static __forceinline void movntdq(void *dst,const __m128i &src) {_mm_stream_si128((__m128i*)dst,src);}
+static __forceinline void movdq2q(__m64 &dst,const __m128i &src) {dst=_mm_movepi64_pi64(src);}
+
+static __forceinline void psrlw(__m128i &dst,int i) {dst=_mm_srli_epi16(dst,i);}
+static __forceinline void psrlq(__m128i &dst,int i) {dst=_mm_srli_epi64(dst,i);}
+static __forceinline void psrad(__m128i &dst,int i) {dst=_mm_srai_epi32(dst,i);}
+static __forceinline void psraw(__m128i &dst,int i) {dst=_mm_srai_epi16(dst,i);}
+static __forceinline void psraw(__m128i &dst,const __m128i &src) {dst=_mm_sra_epi16(dst,src);}
+static __forceinline void psllw(__m128i &dst,int i) {dst=_mm_slli_epi16(dst,i);}
+static __forceinline void pslld(__m128i &dst,int i) {dst=_mm_slli_epi32(dst,i);}
+static __forceinline void psllq(__m128i &dst,int i) {dst=_mm_slli_epi64(dst,i);}
//static __forceinline void pshufd(__m128i &dst,const __m128i &src,const int i) {dst=_mm_shuffle_epi32(src,i);}
//static __forceinline void pshuflw(__m128i &dst,const __m128i &src,const int i) {dst=_mm_shufflelo_epi16(src,i);}
//static __forceinline void pshufhw(__m128i &dst,const __m128i &src,const int i) {dst=_mm_shufflehi_epi16(src,i);}
-static __forceinline void cvtps2dq(__m128i &dst, const __m128 &src)
-{
- dst = _mm_cvtps_epi32(src);
-}
-static __forceinline void cvtdq2ps(__m128 &dst, const __m128i &src)
-{
- dst = _mm_cvtepi32_ps(src);
-}
+static __forceinline void cvtps2dq(__m128i &dst,const __m128 &src) {dst=_mm_cvtps_epi32(src);}
+static __forceinline void cvtdq2ps(__m128 &dst,const __m128i &src) {dst=_mm_cvtepi32_ps(src);}
-static __forceinline void movlpd(__m128d &dst, const void *src)
-{
- dst = _mm_loadl_pd(dst, (double*)src);
-}
-static __forceinline void movhpd(__m128d &dst, const void *src)
-{
- dst = _mm_loadh_pd(dst, (double*)src);
-}
-static __forceinline void movlpd(void *dst, const __m128d &src)
-{
- _mm_storel_pd((double*)dst, src);
-}
-static __forceinline void movhpd(void *dst, const __m128d &src)
-{
- _mm_storeh_pd((double*)dst, src);
-}
+static __forceinline void movlpd(__m128d &dst,const void *src) {dst=_mm_loadl_pd(dst,(double*)src);}
+static __forceinline void movhpd(__m128d &dst,const void *src) {dst=_mm_loadh_pd(dst,(double*)src);}
+static __forceinline void movlpd(void *dst,const __m128d &src) {_mm_storel_pd((double*)dst,src);}
+static __forceinline void movhpd(void *dst,const __m128d &src) {_mm_storeh_pd((double*)dst,src);}
#if defined(__INTEL_COMPILER) || (defined(__GNUC__) && __GNUC__>=4)
-static __forceinline void movlpd(__m128i &dst, const void *src)
-{
- dst = _mm_castpd_si128(_mm_loadl_pd(_mm_castsi128_pd(dst), (double*)src));
-}
-static __forceinline void movhpd(__m128i &dst, const void *src)
-{
- dst = _mm_castpd_si128(_mm_loadh_pd(_mm_castsi128_pd(dst), (double*)src));
-}
-static __forceinline void movlpd(void *dst, const __m128i &src)
-{
- _mm_storel_pd((double*)dst, _mm_castsi128_pd(src));
-}
-static __forceinline void movhpd(void *dst, const __m128i &src)
-{
- _mm_storeh_pd((double*)dst, _mm_castsi128_pd(src));
-}
+ static __forceinline void movlpd(__m128i &dst,const void *src) {dst=_mm_castpd_si128(_mm_loadl_pd(_mm_castsi128_pd(dst),(double*)src));}
+ static __forceinline void movhpd(__m128i &dst,const void *src) {dst=_mm_castpd_si128(_mm_loadh_pd(_mm_castsi128_pd(dst),(double*)src));}
+ static __forceinline void movlpd(void *dst,const __m128i &src) {_mm_storel_pd((double*)dst,_mm_castsi128_pd(src));}
+ static __forceinline void movhpd(void *dst,const __m128i &src) {_mm_storeh_pd((double*)dst,_mm_castsi128_pd(src));}
-static __forceinline void movlps(__m128i &dst, const void *src)
-{
- dst = _mm_castps_si128(_mm_loadl_pi(_mm_castsi128_ps(dst), (const __m64*)src));
-}
-static __forceinline void movlps(void *dst, const __m128i &src)
-{
- _mm_storel_pi((__m64*)dst, _mm_castsi128_ps(src));
-}
-static __forceinline void movhps(__m128i &dst, const void *src)
-{
- dst = _mm_castps_si128(_mm_loadh_pi(_mm_castsi128_ps(dst), (const __m64*)src));
-}
-static __forceinline void movhps(void *dst, const __m128i &src)
-{
- _mm_storeh_pi((__m64*)dst, _mm_castsi128_ps(src));
-}
+ static __forceinline void movlps(__m128i &dst,const void *src) {dst=_mm_castps_si128(_mm_loadl_pi(_mm_castsi128_ps(dst),(const __m64*)src));}
+ static __forceinline void movlps(void *dst,const __m128i &src) {_mm_storel_pi((__m64*)dst,_mm_castsi128_ps(src));}
+ static __forceinline void movhps(__m128i &dst,const void *src) {dst=_mm_castps_si128(_mm_loadh_pi(_mm_castsi128_ps(dst),(const __m64*)src));}
+ static __forceinline void movhps(void *dst,const __m128i &src) {_mm_storeh_pi((__m64*)dst,_mm_castsi128_ps(src));}
-static __forceinline void movlhps(__m128i &dst, const __m128i &src)
-{
- dst = _mm_castps_si128(_mm_movelh_ps(_mm_castsi128_ps(dst), _mm_castsi128_ps(src)));
-}
+ static __forceinline void movlhps(__m128i &dst,const __m128i &src) {dst=_mm_castps_si128(_mm_movelh_ps(_mm_castsi128_ps(dst),_mm_castsi128_ps(src)));}
#else
-static __forceinline __m128i _mm_castps_si128(__m128 &src)
-{
- return (__m128i&)src;
-}
-static __forceinline void movlpd(__m128i &dst, const void *src)
-{
- (__m128d&)dst = _mm_loadl_pd((__m128d&)dst, (double*)src);
-}
-static __forceinline void movhpd(__m128i &dst, const void *src)
-{
- (__m128d&)dst = _mm_loadh_pd((__m128d&)dst, (double*)src);
-}
-static __forceinline void movlpd(void *dst, const __m128i &src)
-{
- _mm_storel_pd((double*)dst, (const __m128d&)src);
-}
-static __forceinline void movhpd(void *dst, const __m128i &src)
-{
- _mm_storeh_pd((double*)dst, (const __m128d&)src);
-}
-
-static __forceinline void movlps(__m128i &dst, const void *src)
-{
- (__m128&)dst = _mm_loadl_pi((__m128&)dst, (const __m64*)src);
-}
-static __forceinline void movlps(void *dst, const __m128i &src)
-{
- _mm_storel_pi((__m64*)dst, (const __m128&)src);
-}
-static __forceinline void movhps(__m128i &dst, const void *src)
-{
- (__m128&)dst = _mm_loadh_pi((__m128&)dst, (const __m64*)src);
-}
-static __forceinline void movhps(void *dst, const __m128i &src)
-{
- _mm_storeh_pi((__m64*)dst, (const __m128&)src);
-}
-
-static __forceinline void movlhps(__m128i &dst, const __m128i &src)
-{
- (__m128&)dst = _mm_movelh_ps((__m128&)dst, (const __m128&)src);
-}
+ static __forceinline __m128i _mm_castps_si128(__m128 &src) {return (__m128i&)src;}
+ static __forceinline void movlpd(__m128i &dst,const void *src) {(__m128d&)dst=_mm_loadl_pd((__m128d&)dst,(double*)src);}
+ static __forceinline void movhpd(__m128i &dst,const void *src) {(__m128d&)dst=_mm_loadh_pd((__m128d&)dst,(double*)src);}
+ static __forceinline void movlpd(void *dst,const __m128i &src) {_mm_storel_pd((double*)dst,(const __m128d&)src);}
+ static __forceinline void movhpd(void *dst,const __m128i &src) {_mm_storeh_pd((double*)dst,(const __m128d&)src);}
+
+ static __forceinline void movlps(__m128i &dst,const void *src) {(__m128&)dst=_mm_loadl_pi((__m128&)dst,(const __m64*)src);}
+ static __forceinline void movlps(void *dst,const __m128i &src) {_mm_storel_pi((__m64*)dst,(const __m128&)src);}
+ static __forceinline void movhps(__m128i &dst,const void *src) {(__m128&)dst=_mm_loadh_pi((__m128&)dst,(const __m64*)src);}
+ static __forceinline void movhps(void *dst,const __m128i &src) {_mm_storeh_pi((__m64*)dst,(const __m128&)src);}
+
+ static __forceinline void movlhps(__m128i &dst,const __m128i &src) {(__m128&)dst=_mm_movelh_ps((__m128&)dst,(const __m128&)src);}
#endif
//======================================= MMX ======================================
@@ -432,544 +174,401 @@ static __forceinline void movlhps(__m128i &dst, const __m128i &src) struct Tmmx
{
- typedef __m64 __m;
- typedef int32_t int2;
- typedef int32_t integer2_t;
- static const size_t size = sizeof(__m);
- static const int align = 0;
- typedef Tmmx T64;
-
- static __forceinline void pmaxub(__m64 &mmr1, const __m64 &mmr2)
- {
- mmr1 = _mm_subs_pu8(mmr1, mmr2);
- mmr1 = _mm_adds_pu8(mmr1, mmr2);
- }
- static __forceinline void pmaxub(__m64 &mmr1, const void *mmr2)
- {
- pmaxub(mmr1, *(__m64*)mmr2);
- }
- static __forceinline void pminub(__m64 &mmr1, const __m64 &mmr2)
- {
- __m64 mmrw;
- pcmpeqb(mmrw, mmrw);
- psubusb(mmrw, mmr2);
- paddusb(mmr1, mmrw);
- psubusb(mmr1, mmrw);
- }
- static __forceinline void pminub(__m64 &mmr1, const void *mmr2)
- {
- pminub(mmr1, *(__m64*)mmr2);
- }
- static __forceinline void pmaxsw(__m64 &a, const __m64 &b)
- {
- psubusw(a, b);
- paddw(a, b);
- }
- static __forceinline void pminsw(__m64 &mm4, const __m64 &mm0)
- {
- __m64 mm2;
- movq(mm2, mm4);
- psubusw(mm2, mm0);
- psubw(mm4, mm2);
- }
- static __forceinline void pavgb(__m64 ®a, __m64 regb)
- {
- __m64 regr;
- static const __int64 regfe = 0xfefefefefefefefeULL; //_mm_set1_pi8(/*0xfe*/-2);
- movq(regr, rega);
- por(regr, regb);
- pxor(regb, rega);
- pand(regb, regfe);
- psrlq(regb, 1);
- psubb(regr, regb);
- rega = regr;
- }
- static __forceinline void pavgb(__m64 ®a, const void *regb)
- {
- pavgb(rega, *(__m64*)regb);
- }
- static __forceinline void v_pavgb(__m64 &mmr1, const __m64 &mmr2, __m64 &mmrw, const __int64 &smask)
- {
- movq(mmrw, mmr2);
- pand(mmrw, smask);
- psrlw(mmrw, 1);
- pand(mmr1, smask);
- psrlw(mmr1, 1);
- paddusb(mmr1, mmrw);
- }
- static __forceinline void v_pavgb(__m64 &mmr1, const void *mmr2, __m64 &mmrw, const __int64 &smask)
- {
- v_pavgb(mmr1, *(__m64*)mmr2, mmrw, smask);
- }
- static __forceinline void sfence(void)
- {
- }
- static __forceinline void movntq(void *dst, const __m64 &src)
- {
- movq(dst, src);
- }
- static __forceinline void v_pminub(__m64 &mmr1, const __m64 &mmr2, __m64 &mmrw)
- {
- pcmpeqb(mmrw, mmrw);
- psubusb(mmrw, mmr2);
- paddusb(mmr1, mmrw);
- psubusb(mmr1, mmrw);
- }
- static __forceinline void v_pminub(__m64 &mmr1, const __int64 &mmr2, __m64 &mmrw)
- {
- v_pminub(mmr1, *(const __m64*)&mmr2, mmrw);
- }
- static __forceinline void pmulhuw(__m64 &mm3, const __m64 &mm2)
- {
- __m64 mm5;
- movq(mm5, mm2);
- psraw(mm5, 15);
- pand(mm5, mm3);
- pmulhw(mm3, mm2);
- paddw(mm3, mm5);
- }
- static __forceinline void prefetchnta(const void*)
- {
- }
- static __forceinline void prefetcht0(const void*)
- {
- }
- static __forceinline __m64 _mm_shuffle_pi16_0(__m64 mm3)
- {
- __m64 mm2;
- static const __int64 qwLowWord = 0x000000000000FFFF;
- pand(mm3, qwLowWord); // mm3 = same limited to low word
- movq(mm2, mm3); // mm2 = same
- psllq(mm3, 16); // mm3 = moved to second word
- por(mm2, mm3); // mm2 = copied to first and second words
- movq(mm3, mm2); // mm3 = same
- psllq(mm3, 32); // mm3 = moved to third and fourth words
- por(mm2, mm3); // mm2 = low word copied to all four words
- return mm2;
- }
- static __forceinline __m64 _mm_shuffle_pi16_1(const __m64 &src)
- {
- static const __int64 const1 = 0x00000000FFFF0000LL;
- static const __int64 const2 = 0x000000000000FFFFLL;
- __m64 w0 = _mm_srli_si64(_mm_and_si64(src, *(__m64*)&const1), 16);
- __m64 w1 = _mm_and_si64(src, *(__m64*)&const2);
- return _mm_or_si64(_mm_or_si64(_mm_or_si64(_mm_slli_si64(w1, 48), _mm_slli_si64(w1, 32)), _mm_slli_si64(w1, 16)), w0);
- }
- static __forceinline __m64 _mm_shuffle_pi16_14(const __m64 &src)
- {
- static const __int64 const1 = 0x000000000000FFFFLL;
- static const __int64 const2 = 0xffffffff00000000ULL;
- __m64 w34 = _mm_and_si64(src, *(__m64*)&const1);
- __m64 w12 = _mm_srli_si64(_mm_and_si64(src, *(__m64*)&const2), 32);
- return _mm_or_si64(w12, _mm_or_si64(_mm_slli_si64(w34, 32), _mm_slli_si64(w34, 48)));
- }
- static __forceinline __m64 _mm_shuffle_pi16_x50(const __m64 &src)
- {
- static const __int64 const1 = 0x00000000ffff0000LL;
- static const __int64 const2 = 0x000000000000ffffLL;
- __m64 w3 = _mm_and_si64(src, *(__m64*)&const1);
- __m64 w4 = _mm_and_si64(src, *(__m64*)&const2);
- return _mm_or_si64(_mm_or_si64(_mm_slli_si64(w3, 32), _mm_slli_si64(w3, 16)) , _mm_or_si64(_mm_slli_si64(w4, 16), w4));
- }
- static __forceinline void psadbw(__m64 &mm0, const __m64 &SourceMM)
- {
- __m64 mm1;
- movq(mm1, SourceMM);
- __m64 mm4;
- movq(mm4, mm0);
- psubusb(mm0, mm1);
- psubusb(mm1, mm4);
- por(mm0, mm1);
- __m64 mm7 = _mm_setzero_si64();
- movq(mm1, mm0);
- punpcklbw(mm0, mm7);
- punpckhbw(mm1, mm7);
- paddusw(mm0, mm1);
- static const __int64 mmx_one = 0x0001000100010001LL;
- pmaddwd(mm0, mmx_one);
- movq(mm7, mm0);
- psrlq(mm7, 32);
- paddd(mm0, mm7);
- static const __int64 mmx_ffff = 0x00000000000fffffLL;
- pand(mm0, mmx_ffff);
- }
- static __forceinline __m64 min_pu8(const __m64 &mm1, const __m64 &mm2)
- {
- __m64 mm0 = mm1;
- pminub(mm0, mm2);
- return mm0;
- }
- static __forceinline __m64 max_pu8(const __m64 &mm1, const __m64 &mm2)
- {
- __m64 mm0 = mm1;
- pmaxub(mm0, mm2);
- return mm0;
- }
- static __forceinline __m64 min_pi16(const __m64 &mm1, const __m64 &mm2)
- {
- __m64 mm0 = mm1;
- pminsw(mm0, mm2);
- return mm0;
- }
- static __forceinline __m64 max_pi16(const __m64 &mm1, const __m64 &mm2)
- {
- __m64 mm0 = mm1;
- pmaxsw(mm0, mm2);
- return mm0;
- }
- MMX_INSTRUCTIONS
+ typedef __m64 __m;
+ typedef int32_t int2;
+ typedef int32_t integer2_t;
+ static const size_t size=sizeof(__m);
+ static const int align=0;
+ typedef Tmmx T64;
+
+ static __forceinline void pmaxub(__m64 &mmr1,const __m64 &mmr2)
+ {
+ mmr1=_mm_subs_pu8(mmr1,mmr2);
+ mmr1=_mm_adds_pu8(mmr1,mmr2);
+ }
+ static __forceinline void pmaxub(__m64 &mmr1,const void *mmr2)
+ {
+ pmaxub(mmr1,*(__m64*)mmr2);
+ }
+ static __forceinline void pminub(__m64 &mmr1,const __m64 &mmr2)
+ {
+ __m64 mmrw;
+ pcmpeqb (mmrw,mmrw );
+ psubusb (mmrw,mmr2 );
+ paddusb (mmr1, mmrw);
+ psubusb (mmr1, mmrw);
+ }
+ static __forceinline void pminub(__m64 &mmr1,const void *mmr2)
+ {
+ pminub(mmr1,*(__m64*)mmr2);
+ }
+ static __forceinline void pmaxsw(__m64 &a,const __m64 &b)
+ {
+ psubusw(a,b);
+ paddw(a,b);
+ }
+ static __forceinline void pminsw(__m64 &mm4,const __m64 &mm0)
+ {
+ __m64 mm2;
+ movq (mm2,mm4);
+ psubusw(mm2,mm0);
+ psubw (mm4,mm2);
+ }
+ static __forceinline void pavgb(__m64 ®a,__m64 regb)
+ {
+ __m64 regr;
+ static const __int64 regfe=0xfefefefefefefefeULL;//_mm_set1_pi8(/*0xfe*/-2);
+ movq (regr,rega);
+ por (regr,regb);
+ pxor (regb,rega);
+ pand (regb,regfe);
+ psrlq (regb,1);
+ psubb (regr,regb);
+ rega=regr;
+ }
+ static __forceinline void pavgb(__m64 ®a,const void *regb)
+ {
+ pavgb(rega,*(__m64*)regb);
+ }
+ static __forceinline void v_pavgb(__m64 &mmr1,const __m64 &mmr2,__m64 &mmrw,const __int64 &smask)
+ {
+ movq( mmrw,mmr2 );
+ pand( mmrw, smask );
+ psrlw( mmrw,1 );
+ pand( mmr1,smask );
+ psrlw( mmr1,1 );
+ paddusb( mmr1,mmrw );
+ }
+ static __forceinline void v_pavgb(__m64 &mmr1,const void *mmr2,__m64 &mmrw,const __int64 &smask)
+ {
+ v_pavgb(mmr1,*(__m64*)mmr2,mmrw,smask);
+ }
+ static __forceinline void sfence(void)
+ {
+ }
+ static __forceinline void movntq(void *dst,const __m64 &src)
+ {
+ movq(dst,src);
+ }
+ static __forceinline void v_pminub(__m64 &mmr1,const __m64 &mmr2,__m64 &mmrw)
+ {
+ pcmpeqb (mmrw,mmrw );
+ psubusb (mmrw,mmr2 );
+ paddusb (mmr1, mmrw);
+ psubusb (mmr1, mmrw);
+ }
+ static __forceinline void v_pminub(__m64 &mmr1,const __int64 &mmr2,__m64 &mmrw)
+ {
+ v_pminub(mmr1,*(const __m64*)&mmr2,mmrw);
+ }
+ static __forceinline void pmulhuw(__m64 &mm3,const __m64 &mm2)
+ {
+ __m64 mm5;
+ movq ( mm5, mm2);
+ psraw ( mm5, 15 );
+ pand ( mm5, mm3);
+ pmulhw ( mm3, mm2);
+ paddw ( mm3, mm5);
+ }
+ static __forceinline void prefetchnta(const void*)
+ {
+ }
+ static __forceinline void prefetcht0(const void*)
+ {
+ }
+ static __forceinline __m64 _mm_shuffle_pi16_0(__m64 mm3)
+ {
+ __m64 mm2;
+ static const __int64 qwLowWord=0x000000000000FFFF;
+ pand (mm3, qwLowWord); // mm3 = same limited to low word
+ movq (mm2, mm3); // mm2 = same
+ psllq (mm3, 16 ); // mm3 = moved to second word
+ por (mm2, mm3); // mm2 = copied to first and second words
+ movq (mm3, mm2); // mm3 = same
+ psllq (mm3, 32 ); // mm3 = moved to third and fourth words
+ por (mm2, mm3); // mm2 = low word copied to all four words
+ return mm2;
+ }
+ static __forceinline __m64 _mm_shuffle_pi16_1(const __m64 &src)
+ {
+ static const __int64 const1=0x00000000FFFF0000LL;
+ static const __int64 const2=0x000000000000FFFFLL;
+ __m64 w0=_mm_srli_si64(_mm_and_si64(src,*(__m64*)&const1),16);
+ __m64 w1=_mm_and_si64(src,*(__m64*)&const2);
+ return _mm_or_si64(_mm_or_si64(_mm_or_si64(_mm_slli_si64(w1,48),_mm_slli_si64(w1,32)),_mm_slli_si64(w1,16)),w0);
+ }
+ static __forceinline __m64 _mm_shuffle_pi16_14(const __m64 &src)
+ {
+ static const __int64 const1=0x000000000000FFFFLL;
+ static const __int64 const2=0xffffffff00000000ULL;
+ __m64 w34=_mm_and_si64(src,*(__m64*)&const1);
+ __m64 w12=_mm_srli_si64(_mm_and_si64(src,*(__m64*)&const2),32);
+ return _mm_or_si64(w12,_mm_or_si64(_mm_slli_si64(w34,32),_mm_slli_si64(w34,48)));
+ }
+ static __forceinline __m64 _mm_shuffle_pi16_x50(const __m64 &src)
+ {
+ static const __int64 const1=0x00000000ffff0000LL;
+ static const __int64 const2=0x000000000000ffffLL;
+ __m64 w3=_mm_and_si64(src,*(__m64*)&const1);
+ __m64 w4=_mm_and_si64(src,*(__m64*)&const2);
+ return _mm_or_si64( _mm_or_si64(_mm_slli_si64(w3,32),_mm_slli_si64(w3,16)) , _mm_or_si64(_mm_slli_si64(w4,16),w4));
+ }
+ static __forceinline void psadbw(__m64 &mm0,const __m64 &SourceMM)
+ {
+ __m64 mm1;
+ movq (mm1, SourceMM);
+ __m64 mm4;
+ movq (mm4, mm0);
+ psubusb (mm0, mm1);
+ psubusb (mm1, mm4);
+ por (mm0, mm1);
+ __m64 mm7=_mm_setzero_si64();
+ movq (mm1,mm0);
+ punpcklbw (mm0,mm7);
+ punpckhbw (mm1,mm7);
+ paddusw (mm0,mm1);
+ static const __int64 mmx_one=0x0001000100010001LL;
+ pmaddwd (mm0, mmx_one);
+ movq (mm7, mm0);
+ psrlq (mm7, 32);
+ paddd (mm0, mm7);
+ static const __int64 mmx_ffff=0x00000000000fffffLL;
+ pand (mm0, mmx_ffff);
+ }
+ static __forceinline __m64 min_pu8(const __m64 &mm1,const __m64 &mm2)
+ {
+ __m64 mm0=mm1;
+ pminub(mm0,mm2);
+ return mm0;
+ }
+ static __forceinline __m64 max_pu8(const __m64 &mm1,const __m64 &mm2)
+ {
+ __m64 mm0=mm1;
+ pmaxub(mm0,mm2);
+ return mm0;
+ }
+ static __forceinline __m64 min_pi16(const __m64 &mm1,const __m64 &mm2)
+ {
+ __m64 mm0=mm1;
+ pminsw(mm0,mm2);
+ return mm0;
+ }
+ static __forceinline __m64 max_pi16(const __m64 &mm1,const __m64 &mm2)
+ {
+ __m64 mm0=mm1;
+ pmaxsw(mm0,mm2);
+ return mm0;
+ }
+ MMX_INSTRUCTIONS
};
//===================================== MMXEXT =====================================
struct Tmmxext
{
- typedef Tmmx::__m __m;
- typedef Tmmx::int2 int2;
- static const size_t size = Tmmx::size;
- static const int align = Tmmx::align;
- typedef Tmmxext T64;
-
- static __forceinline void pmaxub(__m64 &mmr1, const __m64 &mmr2)
- {
- mmr1 = _mm_max_pu8(mmr1, mmr2);
- }
- static __forceinline void pmaxub(__m64 &mmr1, const void *mmr2)
- {
- pmaxub(mmr1, *(__m64*)mmr2);
- }
- static __forceinline void pminub(__m64 &mmr1, const __m64 &mmr2)
- {
- mmr1 = _mm_min_pu8(mmr1, mmr2);
- }
- static __forceinline void pminub(__m64 &mmr1, const void *mmr2)
- {
- pminub(mmr1, *(__m64*)mmr2);
- }
- static __forceinline void pminsw(__m64 &mmr1, const __m64 &mmr2)
- {
- mmr1 = _mm_min_pi16(mmr1, mmr2);
- }
- static __forceinline void pavgb(__m64 &mmr1, const __m64 &mmr2)
- {
- mmr1 = _mm_avg_pu8(mmr1, mmr2);
- }
- static __forceinline void pavgb(__m64 &mmr1, const void *mmr2)
- {
- mmr1 = _mm_avg_pu8(mmr1, *(__m64*)mmr2);
- }
- static __forceinline void v_pavgb(__m64 &mmr1, const __m64 &mmr2, __m64, __int64)
- {
- mmr1 = _mm_avg_pu8(mmr1, mmr2);
- }
- static __forceinline void v_pavgb(__m64 &mmr1, const void *mmr2, __m64, __int64)
- {
- mmr1 = _mm_avg_pu8(mmr1, *(__m64*)mmr2);
- }
- static __forceinline void sfence(void)
- {
- _mm_sfence();
- }
- static __forceinline void movntq(void *dst, const __m64 &src)
- {
- _mm_stream_pi((__m64*)dst, src);
- }
- static __forceinline void v_pminub(__m64 &mmr1, const __m64 &mmr2, __m64)
- {
- mmr1 = _mm_min_pu8(mmr1, mmr2);
- }
- static __forceinline void v_pminub(__m64 &mmr1, const __int64 &mmr2, __m64 &mmrw)
- {
- v_pminub(mmr1, *(const __m64*)&mmr2, mmrw);
- }
- static __forceinline void pmulhuw(__m64 &mmr1, const __m64 &mmr2)
- {
- mmr1 = _mm_mulhi_pu16(mmr1, mmr2);
- }
- static __forceinline void prefetchnta(const void *ptr)
- {
- _mm_prefetch((const char*)ptr, _MM_HINT_NTA);
- }
- static __forceinline void prefetcht0(const void *ptr)
- {
- _mm_prefetch((const char*)ptr, _MM_HINT_T0);
- }
- static __forceinline __m64 _mm_shuffle_pi16_0(const __m64 &src)
- {
- return _mm_shuffle_pi16(src, 0);
- }
- static __forceinline __m64 _mm_shuffle_pi16_1(const __m64 &src)
- {
- return _mm_shuffle_pi16(src, 1);
- }
- static __forceinline __m64 _mm_shuffle_pi16_14(const __m64 &src)
- {
- return _mm_shuffle_pi16(src, (3 << 2) + 2);
- }
- static __forceinline __m64 _mm_shuffle_pi16_x50(const __m64 &src)
- {
- return _mm_shuffle_pi16(src, 0x50);
- }
- static __forceinline void psadbw(__m64 &mm3, const __m64 &mm2)
- {
- mm3 = _mm_sad_pu8(mm3, mm2);
- }
- static __forceinline __m64 min_pu8(const __m64 &mm1, const __m64 &mm2)
- {
- return _mm_min_pu8(mm1, mm2);
- }
- static __forceinline __m64 max_pu8(const __m64 &mm1, const __m64 &mm2)
- {
- return _mm_max_pu8(mm1, mm2);
- }
- static __forceinline __m64 min_pi16(const __m64 &mm1, const __m64 &mm2)
- {
- return _mm_min_pi16(mm1, mm2);
- }
- static __forceinline __m64 max_pi16(const __m64 &mm1, const __m64 &mm2)
- {
- return _mm_max_pi16(mm1, mm2);
- }
- static __forceinline void pmaxsw(__m64 &dst, const __m64 &src)
- {
- dst = _mm_max_pi16(dst, src);
- }
-
- MMX_INSTRUCTIONS
+ typedef Tmmx::__m __m;
+ typedef Tmmx::int2 int2;
+ static const size_t size=Tmmx::size;
+ static const int align=Tmmx::align;
+ typedef Tmmxext T64;
+
+ static __forceinline void pmaxub(__m64 &mmr1,const __m64 &mmr2)
+ {
+ mmr1=_mm_max_pu8(mmr1,mmr2);
+ }
+ static __forceinline void pmaxub(__m64 &mmr1,const void *mmr2)
+ {
+ pmaxub(mmr1,*(__m64*)mmr2);
+ }
+ static __forceinline void pminub(__m64 &mmr1,const __m64 &mmr2)
+ {
+ mmr1=_mm_min_pu8(mmr1,mmr2);
+ }
+ static __forceinline void pminub(__m64 &mmr1,const void *mmr2)
+ {
+ pminub(mmr1,*(__m64*)mmr2);
+ }
+ static __forceinline void pminsw(__m64 &mmr1,const __m64 &mmr2)
+ {
+ mmr1=_mm_min_pi16(mmr1,mmr2);
+ }
+ static __forceinline void pavgb(__m64 &mmr1,const __m64 &mmr2)
+ {
+ mmr1=_mm_avg_pu8(mmr1,mmr2);
+ }
+ static __forceinline void pavgb(__m64 &mmr1,const void *mmr2)
+ {
+ mmr1=_mm_avg_pu8(mmr1,*(__m64*)mmr2);
+ }
+ static __forceinline void v_pavgb(__m64 &mmr1,const __m64 &mmr2,__m64,__int64)
+ {
+ mmr1=_mm_avg_pu8(mmr1,mmr2);
+ }
+ static __forceinline void v_pavgb(__m64 &mmr1,const void *mmr2,__m64,__int64)
+ {
+ mmr1=_mm_avg_pu8(mmr1,*(__m64*)mmr2);
+ }
+ static __forceinline void sfence(void)
+ {
+ _mm_sfence();
+ }
+ static __forceinline void movntq(void *dst,const __m64 &src)
+ {
+ _mm_stream_pi((__m64*)dst,src);
+ }
+ static __forceinline void v_pminub(__m64 &mmr1,const __m64 &mmr2,__m64)
+ {
+ mmr1=_mm_min_pu8(mmr1,mmr2);
+ }
+ static __forceinline void v_pminub(__m64 &mmr1,const __int64 &mmr2,__m64 &mmrw)
+ {
+ v_pminub(mmr1,*(const __m64*)&mmr2,mmrw);
+ }
+ static __forceinline void pmulhuw(__m64 &mmr1,const __m64 &mmr2)
+ {
+ mmr1=_mm_mulhi_pu16(mmr1,mmr2);
+ }
+ static __forceinline void prefetchnta(const void *ptr)
+ {
+ _mm_prefetch((const char*)ptr,_MM_HINT_NTA);
+ }
+ static __forceinline void prefetcht0(const void *ptr)
+ {
+ _mm_prefetch((const char*)ptr,_MM_HINT_T0);
+ }
+ static __forceinline __m64 _mm_shuffle_pi16_0(const __m64 &src)
+ {
+ return _mm_shuffle_pi16(src,0);
+ }
+ static __forceinline __m64 _mm_shuffle_pi16_1(const __m64 &src)
+ {
+ return _mm_shuffle_pi16(src,1);
+ }
+ static __forceinline __m64 _mm_shuffle_pi16_14(const __m64 &src)
+ {
+ return _mm_shuffle_pi16(src,(3 << 2) + 2);
+ }
+ static __forceinline __m64 _mm_shuffle_pi16_x50(const __m64 &src)
+ {
+ return _mm_shuffle_pi16(src,0x50);
+ }
+ static __forceinline void psadbw(__m64 &mm3,const __m64 &mm2)
+ {
+ mm3=_mm_sad_pu8(mm3,mm2);
+ }
+ static __forceinline __m64 min_pu8(const __m64 &mm1,const __m64 &mm2)
+ {
+ return _mm_min_pu8(mm1,mm2);
+ }
+ static __forceinline __m64 max_pu8(const __m64 &mm1,const __m64 &mm2)
+ {
+ return _mm_max_pu8(mm1,mm2);
+ }
+ static __forceinline __m64 min_pi16(const __m64 &mm1,const __m64 &mm2)
+ {
+ return _mm_min_pi16(mm1,mm2);
+ }
+ static __forceinline __m64 max_pi16(const __m64 &mm1,const __m64 &mm2)
+ {
+ return _mm_max_pi16(mm1,mm2);
+ }
+ static __forceinline void pmaxsw(__m64 &dst,const __m64 &src)
+ {
+ dst=_mm_max_pi16(dst,src);
+ }
+
+ MMX_INSTRUCTIONS
};
-static __forceinline __m64 _mm_absdif_u8(__m64 mm1, __m64 mm2)
+static __forceinline __m64 _mm_absdif_u8(__m64 mm1,__m64 mm2)
{
- __m64 mm7 = mm1;
- mm1 = _mm_subs_pu8(mm1, mm2);
- mm2 = _mm_subs_pu8(mm2, mm7);
- return _mm_or_si64(mm2, mm1);
+ __m64 mm7=mm1;
+ mm1=_mm_subs_pu8(mm1,mm2);
+ mm2=_mm_subs_pu8(mm2,mm7);
+ return _mm_or_si64(mm2,mm1);
}
-static __forceinline void memadd(unsigned char *dst, const unsigned char *src, unsigned int len)
+static __forceinline void memadd(unsigned char *dst,const unsigned char *src,unsigned int len)
{
- __m64 *dst8 = (__m64*)dst;
- const __m64 *src8 = (__m64*)src;
- for(unsigned int i = 0; i < len / 8; i++, src8++, dst8++)
- *dst8 = _mm_adds_pu8(*src8, *dst8);
+ __m64 *dst8=(__m64*)dst;const __m64 *src8=(__m64*)src;
+ for (unsigned int i=0;i<len/8;i++,src8++,dst8++)
+ *dst8=_mm_adds_pu8(*src8,*dst8);
}
//====================================== SSE2 ======================================
struct Tsse2
{
- typedef __m128i __m;
- typedef __m64 int2;
- typedef int64_t integer2_t;
- static const size_t size = sizeof(__m);
- static const int align = 16;
- typedef Tmmxext T64;
- static __forceinline __m setzero_si64(void)
- {
- return _mm_setzero_si128();
- }
- static __forceinline __m set_pi8(char b7, char b6, char b5, char b4, char b3, char b2, char b1, char b0)
- {
- return _mm_set_epi8(b7, b6, b5, b4, b3, b2, b1, b0, b7, b6, b5, b4, b3, b2, b1, b0);
- }
- static __forceinline __m set_pi32(int i1, int i0)
- {
- return _mm_set_epi32(i1, i0, i1, i0);
- }
- static __forceinline __m set1_pi8(char b)
- {
- return _mm_set1_epi8(b);
- }
- static __forceinline __m set1_pi16(short s)
- {
- return _mm_set1_epi16(s);
- }
- static __forceinline __m set1_pi64(int64_t s)
- {
- __align16(int64_t, x[]) = {s, s}; //__m128i _mm_set1_epi64(*(__m64*)&s); TODO: _mm_set1_epi64x
- return *(__m*)x;
- }
- static __forceinline __m packs_pu16(const __m &m1, const __m &m2)
- {
- return _mm_packus_epi16(m1, m2);
- }
- static __forceinline __m slli_pi16(const __m &m, int count)
- {
- return _mm_slli_epi16(m, count);
- }
- static __forceinline __m srli_pi16(const __m &m, int count)
- {
- return _mm_srli_epi16(m, count);
- }
- static __forceinline __m srli_si64(const __m &m, int count)
- {
- return _mm_srli_epi64(m, count);
- }
- static __forceinline __m srai_pi16(const __m &m, int count)
- {
- return _mm_srai_epi16(m, count);
- }
- static __forceinline __m madd_pi16(const __m &m1, const __m &m2)
- {
- return _mm_madd_epi16(m1, m2);
- }
- static __forceinline __m add_pi16(const __m &m1, const __m &m2)
- {
- return _mm_add_epi16(m1, m2);
- }
- static __forceinline __m adds_pi16(const __m &m1, const __m &m2)
- {
- return _mm_adds_epi16(m1, m2);
- }
- static __forceinline __m adds_pu16(const __m &m1, const __m &m2)
- {
- return _mm_adds_epu16(m1, m2);
- }
- static __forceinline __m adds_pu8(const __m &m1, const __m &m2)
- {
- return _mm_adds_epu8(m1, m2);
- }
- static __forceinline __m sub_pi16(const __m &m1, const __m &m2)
- {
- return _mm_sub_epi16(m1, m2);
- }
- static __forceinline __m subs_pi16(const __m &m1, const __m &m2)
- {
- return _mm_subs_epi16(m1, m2);
- }
- static __forceinline __m subs_pu16(const __m &m1, const __m &m2)
- {
- return _mm_subs_epu16(m1, m2);
- }
- static __forceinline __m subs_pu8(const __m &m1, const __m &m2)
- {
- return _mm_subs_epu8(m1, m2);
- }
- static __forceinline __m or_si64(const __m &m1, const __m &m2)
- {
- return _mm_or_si128(m1, m2);
- }
- static __forceinline __m xor_si64(const __m &m1, const __m &m2)
- {
- return _mm_xor_si128(m1, m2);
- }
- static __forceinline __m and_si64(const __m &m1, const __m &m2)
- {
- return _mm_and_si128(m1, m2);
- }
- static __forceinline __m andnot_si64(const __m &m1, const __m &m2)
- {
- return _mm_andnot_si128(m1, m2);
- }
- static __forceinline __m mullo_pi16(const __m &m1, const __m &m2)
- {
- return _mm_mullo_epi16(m1, m2);
- }
- static __forceinline __m mulhi_pi16(const __m &m1, const __m &m2)
- {
- return _mm_mulhi_epi16(m1, m2);
- }
- static __forceinline __m unpacklo_pi8(const __m &m1, const __m &m2)
- {
- return _mm_unpacklo_epi8(m1, m2);
- }
- static __forceinline __m unpackhi_pi8(const __m &m1, const __m &m2)
- {
- return _mm_unpackhi_epi8(m1, m2);
- }
- static __forceinline __m cmpgt_pi16(const __m &m1, const __m &m2)
- {
- return _mm_cmpgt_epi16(m1, m2);
- }
- static __forceinline __m cmpeq_pi16(const __m &m1, const __m &m2)
- {
- return _mm_cmpeq_epi16(m1, m2);
- }
- static __forceinline __m cmpeq_pi8(const __m &m1, const __m &m2)
- {
- return _mm_cmpeq_epi8(m1, m2);
- }
- static __forceinline __m min_pi16(const __m &mm1, const __m &mm2)
- {
- return _mm_min_epi16(mm1, mm2);
- }
- static __forceinline __m max_pi16(const __m &mm1, const __m &mm2)
- {
- return _mm_max_epi16(mm1, mm2);
- }
- static __forceinline __m load2(const void *ptr)
- {
- return _mm_loadl_epi64((const __m128i*)ptr);
- }
- static __forceinline void store2(void *ptr, const __m &m)
- {
- _mm_storel_epi64((__m128i*)ptr, m);
- }
- static __forceinline void storeU(void *ptr, const __m &m)
- {
- _mm_storeu_si128((__m*)ptr, m);
- }
- static __forceinline __m loadU(const void *ptr)
- {
- return _mm_loadu_si128((const __m*)ptr);
- }
- static __forceinline void empty(void)
- {
- /*_mm_empty();*/
- }
-
- static __forceinline void psadbw(__m &mm3, const __m &mm2)
- {
- mm3 = _mm_sad_epu8(mm3, mm2);
- }
- static __forceinline void prefetchnta(const void *ptr)
- {
- _mm_prefetch((const char*)ptr, _MM_HINT_NTA);
- }
- static __forceinline __m shuffle_pi16_0(const __m &mm0)
- {
- return _mm_shufflehi_epi16(_mm_shufflelo_epi16(mm0, 0), 0);
- }
- static __forceinline void pmaxub(__m &mmr1, const __m &mmr2)
- {
- mmr1 = _mm_max_epu8(mmr1, mmr2);
- }
- static __forceinline void pmulhuw(__m &mmr1, const __m &mmr2)
- {
- mmr1 = _mm_mulhi_epu16(mmr1, mmr2);
- }
- static __forceinline void movntq(void *dst, const __m &src)
- {
- _mm_stream_si128((__m128i*)dst, src);
- }
- static __forceinline void pavgb(__m &mmr1, const __m &mmr2)
- {
- mmr1 = _mm_avg_epu8(mmr1, mmr2);
- }
- static __forceinline void pavgb(__m &mmr1, const void *mmr2)
- {
- mmr1 = _mm_avg_epu8(mmr1, *(__m*)mmr2);
- }
- static __forceinline void sfence(void)
- {
- _mm_sfence();
- }
+ typedef __m128i __m;
+ typedef __m64 int2;
+ typedef int64_t integer2_t;
+ static const size_t size=sizeof(__m);
+ static const int align=16;
+ typedef Tmmxext T64;
+ static __forceinline __m setzero_si64(void) {return _mm_setzero_si128();}
+ static __forceinline __m set_pi8(char b7,char b6,char b5,char b4,char b3,char b2,char b1,char b0) {return _mm_set_epi8(b7,b6,b5,b4,b3,b2,b1,b0,b7,b6,b5,b4,b3,b2,b1,b0);}
+ static __forceinline __m set_pi32(int i1,int i0) {return _mm_set_epi32(i1,i0,i1,i0);}
+ static __forceinline __m set1_pi8(char b) {return _mm_set1_epi8(b);}
+ static __forceinline __m set1_pi16(short s) {return _mm_set1_epi16(s);}
+ static __forceinline __m set1_pi64(int64_t s) {__align16(int64_t,x[])={s,s};return *(__m*)x;}//__m128i _mm_set1_epi64(*(__m64*)&s); TODO: _mm_set1_epi64x
+ static __forceinline __m packs_pu16(const __m &m1,const __m &m2) {return _mm_packus_epi16(m1,m2);}
+ static __forceinline __m slli_pi16(const __m &m,int count) {return _mm_slli_epi16(m,count);}
+ static __forceinline __m srli_pi16(const __m &m,int count) {return _mm_srli_epi16(m,count);}
+ static __forceinline __m srli_si64(const __m &m,int count) {return _mm_srli_epi64(m,count);}
+ static __forceinline __m srai_pi16(const __m &m,int count) {return _mm_srai_epi16(m,count);}
+ static __forceinline __m madd_pi16(const __m &m1,const __m &m2) {return _mm_madd_epi16(m1,m2);}
+ static __forceinline __m add_pi16(const __m &m1,const __m &m2) {return _mm_add_epi16(m1,m2);}
+ static __forceinline __m adds_pi16(const __m &m1,const __m &m2) {return _mm_adds_epi16(m1,m2);}
+ static __forceinline __m adds_pu16(const __m &m1,const __m &m2) {return _mm_adds_epu16(m1,m2);}
+ static __forceinline __m adds_pu8(const __m &m1,const __m &m2) {return _mm_adds_epu8(m1,m2);}
+ static __forceinline __m sub_pi16(const __m &m1,const __m &m2) {return _mm_sub_epi16(m1,m2);}
+ static __forceinline __m subs_pi16(const __m &m1,const __m &m2) {return _mm_subs_epi16(m1,m2);}
+ static __forceinline __m subs_pu16(const __m &m1,const __m &m2) {return _mm_subs_epu16(m1,m2);}
+ static __forceinline __m subs_pu8(const __m &m1,const __m &m2) {return _mm_subs_epu8(m1,m2);}
+ static __forceinline __m or_si64(const __m &m1,const __m &m2) {return _mm_or_si128(m1,m2);}
+ static __forceinline __m xor_si64(const __m &m1,const __m &m2) {return _mm_xor_si128(m1,m2);}
+ static __forceinline __m and_si64(const __m &m1,const __m &m2) {return _mm_and_si128(m1,m2);}
+ static __forceinline __m andnot_si64(const __m &m1,const __m &m2) {return _mm_andnot_si128(m1,m2);}
+ static __forceinline __m mullo_pi16(const __m &m1,const __m &m2) {return _mm_mullo_epi16(m1,m2);}
+ static __forceinline __m mulhi_pi16(const __m &m1,const __m &m2) {return _mm_mulhi_epi16(m1,m2);}
+ static __forceinline __m unpacklo_pi8(const __m &m1,const __m &m2) {return _mm_unpacklo_epi8(m1,m2);}
+ static __forceinline __m unpackhi_pi8(const __m &m1,const __m &m2) {return _mm_unpackhi_epi8(m1,m2);}
+ static __forceinline __m cmpgt_pi16(const __m &m1,const __m &m2) {return _mm_cmpgt_epi16(m1,m2);}
+ static __forceinline __m cmpeq_pi16(const __m &m1,const __m &m2) {return _mm_cmpeq_epi16(m1,m2);}
+ static __forceinline __m cmpeq_pi8(const __m &m1,const __m &m2) {return _mm_cmpeq_epi8(m1,m2);}
+ static __forceinline __m min_pi16(const __m &mm1,const __m &mm2) {return _mm_min_epi16(mm1,mm2);}
+ static __forceinline __m max_pi16(const __m &mm1,const __m &mm2) {return _mm_max_epi16(mm1,mm2);}
+ static __forceinline __m load2(const void *ptr) {return _mm_loadl_epi64((const __m128i*)ptr);}
+ static __forceinline void store2(void *ptr,const __m &m) {_mm_storel_epi64((__m128i*)ptr,m);}
+ static __forceinline void storeU(void *ptr,const __m &m) { _mm_storeu_si128((__m*)ptr,m);}
+ static __forceinline __m loadU(const void *ptr) {return _mm_loadu_si128((const __m*)ptr);}
+ static __forceinline void empty(void) {/*_mm_empty();*/}
+
+ static __forceinline void psadbw(__m &mm3,const __m &mm2) {mm3=_mm_sad_epu8(mm3,mm2);}
+ static __forceinline void prefetchnta(const void *ptr) {_mm_prefetch((const char*)ptr,_MM_HINT_NTA);}
+ static __forceinline __m shuffle_pi16_0(const __m &mm0) {return _mm_shufflehi_epi16(_mm_shufflelo_epi16(mm0,0),0);}
+ static __forceinline void pmaxub(__m &mmr1,const __m &mmr2) {mmr1=_mm_max_epu8(mmr1,mmr2);}
+ static __forceinline void pmulhuw(__m &mmr1,const __m &mmr2) {mmr1=_mm_mulhi_epu16(mmr1,mmr2);}
+ static __forceinline void movntq(void *dst,const __m &src) {_mm_stream_si128((__m128i*)dst,src);}
+ static __forceinline void pavgb(__m &mmr1,const __m &mmr2) {mmr1=_mm_avg_epu8(mmr1,mmr2);}
+ static __forceinline void pavgb(__m &mmr1,const void *mmr2) {mmr1=_mm_avg_epu8(mmr1,*(__m*)mmr2);}
+ static __forceinline void sfence(void) {_mm_sfence();}
};
template<class _mm> static __forceinline typename _mm::__m abs_16(const typename _mm::__m &mm0)
{
- typename _mm::__m mm6 = _mm::srai_pi16(mm0, 15);
- return _mm::sub_pi16(_mm::xor_si64(mm0, mm6), mm6);
+ typename _mm::__m mm6=_mm::srai_pi16(mm0,15);
+ return _mm::sub_pi16(_mm::xor_si64(mm0,mm6),mm6);
}
-template<class _mm> static __forceinline typename _mm::__m absdif_s16(typename _mm::__m mm0, typename _mm::__m mm1)
+template<class _mm> static __forceinline typename _mm::__m absdif_s16(typename _mm::__m mm0,typename _mm::__m mm1)
{
- typename _mm::__m mm2 = mm0;
- mm0 = _mm::cmpgt_pi16(mm0, mm1);
- typename _mm::__m mm4 = mm2;
- mm2 = _mm::xor_si64(mm2, mm1);
- mm2 = _mm::and_si64(mm2, mm0);
- typename _mm::__m mm3 = mm2;
- mm4 = _mm::xor_si64(mm4, mm2);
- mm1 = _mm::xor_si64(mm1, mm3);
- return _mm::sub_pi16(mm1, mm4);
+ typename _mm::__m mm2=mm0;
+ mm0=_mm::cmpgt_pi16(mm0,mm1);
+ typename _mm::__m mm4=mm2;
+ mm2=_mm::xor_si64(mm2,mm1);
+ mm2=_mm::and_si64(mm2,mm0);
+ typename _mm::__m mm3=mm2;
+ mm4=_mm::xor_si64(mm4,mm2);
+ mm1=_mm::xor_si64(mm1,mm3);
+ return _mm::sub_pi16(mm1,mm4);
}
#pragma warning(pop)
diff --git a/src/DSUtil/simd_common.h b/src/DSUtil/simd_common.h index 176217110..0b5e307e6 100644 --- a/src/DSUtil/simd_common.h +++ b/src/DSUtil/simd_common.h @@ -2,13 +2,13 @@ #define _SIMD_COMMON_H_
#ifdef __GNUC__
-#define __forceinline __attribute__((__always_inline__)) inline
+ #define __forceinline __attribute__((__always_inline__)) inline
#else
-#define inline __forceinline
+ #define inline __forceinline
#endif
#ifdef __GNUC__
-#define __inline __forceinline // GCC needs to force inlining of intrinsics functions
+ #define __inline __forceinline // GCC needs to force inlining of intrinsics functions
#endif
#include <mmintrin.h>
@@ -16,15 +16,15 @@ #include <emmintrin.h>
#ifdef __GNUC__
-#undef __inline
+ #undef __inline
#endif
#ifdef __GNUC__
-#define __align8(t,v) t v __attribute__ ((aligned (8)))
-#define __align16(t,v) t v __attribute__ ((aligned (16)))
+ #define __align8(t,v) t v __attribute__ ((aligned (8)))
+ #define __align16(t,v) t v __attribute__ ((aligned (16)))
#else
-#define __align8(t,v) __declspec(align(8)) t v
-#define __align16(t,v) __declspec(align(16)) t v
+ #define __align8(t,v) __declspec(align(8)) t v
+ #define __align16(t,v) __declspec(align(16)) t v
#endif
#endif
diff --git a/src/DSUtil/simd_instructions.h b/src/DSUtil/simd_instructions.h index 5269503dc..6ce9a2b29 100644 --- a/src/DSUtil/simd_instructions.h +++ b/src/DSUtil/simd_instructions.h @@ -1,83 +1,83 @@ -MMX_INSTRUCTION(paddb, _mm_add_pi8)
-MMX_INSTRUCTION(paddsb, _mm_adds_pi8)
-MMX_INSTRUCTION(paddusb, _mm_adds_pu8)
-MMX_INSTRUCTION(paddw, _mm_add_pi16)
-MMX_INSTRUCTION(paddsw, _mm_adds_pi16)
-MMX_INSTRUCTION(paddusw, _mm_adds_pu16)
-MMX_INSTRUCTION(paddd, _mm_add_pi32)
+MMX_INSTRUCTION(paddb,_mm_add_pi8)
+MMX_INSTRUCTION(paddsb,_mm_adds_pi8)
+MMX_INSTRUCTION(paddusb,_mm_adds_pu8)
+MMX_INSTRUCTION(paddw,_mm_add_pi16)
+MMX_INSTRUCTION(paddsw,_mm_adds_pi16)
+MMX_INSTRUCTION(paddusw,_mm_adds_pu16)
+MMX_INSTRUCTION(paddd,_mm_add_pi32)
-MMX_INSTRUCTION(pmaddwd, _mm_madd_pi16)
+MMX_INSTRUCTION(pmaddwd,_mm_madd_pi16)
-MMX_INSTRUCTION(psubb, _mm_sub_pi8)
-MMX_INSTRUCTION(psubsb, _mm_subs_pi8)
-MMX_INSTRUCTION(psubusb, _mm_subs_pu8)
-MMX_INSTRUCTION(psubw, _mm_sub_pi16)
-MMX_INSTRUCTION(psubsw, _mm_subs_pi16)
-MMX_INSTRUCTION(psubusw, _mm_subs_pu16)
-MMX_INSTRUCTION(psubd, _mm_sub_pi32)
+MMX_INSTRUCTION(psubb,_mm_sub_pi8)
+MMX_INSTRUCTION(psubsb,_mm_subs_pi8)
+MMX_INSTRUCTION(psubusb,_mm_subs_pu8)
+MMX_INSTRUCTION(psubw,_mm_sub_pi16)
+MMX_INSTRUCTION(psubsw,_mm_subs_pi16)
+MMX_INSTRUCTION(psubusw,_mm_subs_pu16)
+MMX_INSTRUCTION(psubd,_mm_sub_pi32)
-MMX_INSTRUCTION(pmullw, _mm_mullo_pi16)
-MMX_INSTRUCTION(pmulhw, _mm_mulhi_pi16)
+MMX_INSTRUCTION(pmullw,_mm_mullo_pi16)
+MMX_INSTRUCTION(pmulhw,_mm_mulhi_pi16)
-MMX_INSTRUCTION(pand, _mm_and_si64)
-MMX_INSTRUCTION(pandn, _mm_andnot_si64)
-MMX_INSTRUCTION(por, _mm_or_si64)
-MMX_INSTRUCTION(pxor, _mm_xor_si64)
+MMX_INSTRUCTION(pand,_mm_and_si64)
+MMX_INSTRUCTION(pandn,_mm_andnot_si64)
+MMX_INSTRUCTION(por,_mm_or_si64)
+MMX_INSTRUCTION(pxor,_mm_xor_si64)
-MMX_INSTRUCTION(pcmpeqb, _mm_cmpeq_pi8)
-MMX_INSTRUCTION(pcmpeqw, _mm_cmpeq_pi16)
-MMX_INSTRUCTION(pcmpeqd, _mm_cmpeq_pi32)
-MMX_INSTRUCTION(pcmpgtb, _mm_cmpgt_pi8)
-MMX_INSTRUCTION(pcmpgtw, _mm_cmpgt_pi16)
-MMX_INSTRUCTION(pcmpgtd, _mm_cmpgt_pi32)
+MMX_INSTRUCTION(pcmpeqb,_mm_cmpeq_pi8)
+MMX_INSTRUCTION(pcmpeqw,_mm_cmpeq_pi16)
+MMX_INSTRUCTION(pcmpeqd,_mm_cmpeq_pi32)
+MMX_INSTRUCTION(pcmpgtb,_mm_cmpgt_pi8)
+MMX_INSTRUCTION(pcmpgtw,_mm_cmpgt_pi16)
+MMX_INSTRUCTION(pcmpgtd,_mm_cmpgt_pi32)
-MMX_INSTRUCTION(packuswb, _mm_packs_pu16)
-MMX_INSTRUCTION(packsswb, _mm_packs_pi16)
-MMX_INSTRUCTION(packssdw, _mm_packs_pi32)
+MMX_INSTRUCTION(packuswb,_mm_packs_pu16)
+MMX_INSTRUCTION(packsswb,_mm_packs_pi16)
+MMX_INSTRUCTION(packssdw,_mm_packs_pi32)
-MMX_INSTRUCTION(punpcklbw, _mm_unpacklo_pi8)
-MMX_INSTRUCTION(punpckhbw, _mm_unpackhi_pi8)
+MMX_INSTRUCTION(punpcklbw,_mm_unpacklo_pi8)
+MMX_INSTRUCTION(punpckhbw,_mm_unpackhi_pi8)
-MMX_INSTRUCTION(punpcklwd, _mm_unpacklo_pi16)
-MMX_INSTRUCTION(punpckhwd, _mm_unpackhi_pi16)
-MMX_INSTRUCTION(punpckldq, _mm_unpacklo_pi32)
-MMX_INSTRUCTION(punpckhdq, _mm_unpackhi_pi32)
+MMX_INSTRUCTION(punpcklwd,_mm_unpacklo_pi16)
+MMX_INSTRUCTION(punpckhwd,_mm_unpackhi_pi16)
+MMX_INSTRUCTION(punpckldq,_mm_unpacklo_pi32)
+MMX_INSTRUCTION(punpckhdq,_mm_unpackhi_pi32)
-MMX_INSTRUCTION(pminub, _mm_min_pu8)
-MMX_INSTRUCTION(pminsw, _mm_min_pi16)
-MMX_INSTRUCTION(pmaxub, _mm_max_pu8)
-MMX_INSTRUCTION(pmaxsw, _mm_max_pi16)
+MMX_INSTRUCTION(pminub,_mm_min_pu8)
+MMX_INSTRUCTION(pminsw,_mm_min_pi16)
+MMX_INSTRUCTION(pmaxub,_mm_max_pu8)
+MMX_INSTRUCTION(pmaxsw,_mm_max_pi16)
-MMX_INSTRUCTION(pavgb, _mm_avg_pu8)
+MMX_INSTRUCTION(pavgb,_mm_avg_pu8)
-MMX_INSTRUCTION(psadbw, _mm_sad_pu8)
+MMX_INSTRUCTION(psadbw,_mm_sad_pu8)
-SSE2I_INSTRUCTION(pand, _mm_and_si128)
-SSE2I_INSTRUCTION(por, _mm_or_si128)
-SSE2I_INSTRUCTION(pxor, _mm_xor_si128)
-SSE2I_INSTRUCTION(packuswb, _mm_packus_epi16)
-SSE2I_INSTRUCTION(packsswb, _mm_packs_epi16)
-SSE2I_INSTRUCTION(packssdw, _mm_packs_epi32)
-SSE2I_INSTRUCTION(punpcklbw, _mm_unpacklo_epi8)
-SSE2I_INSTRUCTION(punpckhbw, _mm_unpackhi_epi8)
-SSE2I_INSTRUCTION(punpcklwd, _mm_unpacklo_epi16)
-SSE2I_INSTRUCTION(punpckhwd, _mm_unpackhi_epi16)
-SSE2I_INSTRUCTION(punpckldq, _mm_unpacklo_epi32)
-SSE2I_INSTRUCTION(pmullw, _mm_mullo_epi16)
-SSE2I_INSTRUCTION(pmulhw, _mm_mulhi_epi16)
-SSE2I_INSTRUCTION(paddsb, _mm_adds_epi8)
-SSE2I_INSTRUCTION(paddb, _mm_add_epi8)
-SSE2I_INSTRUCTION(paddw, _mm_add_epi16)
-SSE2I_INSTRUCTION(paddsw, _mm_adds_epi16)
-SSE2I_INSTRUCTION(paddusw, _mm_adds_epu16)
-SSE2I_INSTRUCTION(paddd, _mm_add_epi32)
-SSE2I_INSTRUCTION(psubw, _mm_sub_epi16)
-SSE2I_INSTRUCTION(psubsw, _mm_subs_epi16)
-SSE2I_INSTRUCTION(psubusb, _mm_subs_epu8)
-SSE2I_INSTRUCTION(psubd, _mm_sub_epi32)
-SSE2I_INSTRUCTION(pmaddwd, _mm_madd_epi16)
-SSE2I_INSTRUCTION(pavgb, _mm_avg_epu8)
-SSE2I_INSTRUCTION(pcmpeqb, _mm_cmpeq_epi8)
-SSE2I_INSTRUCTION(pcmpeqw, _mm_cmpeq_epi16)
-SSE2I_INSTRUCTION(pcmpgtb, _mm_cmpgt_epi8)
-SSE2I_INSTRUCTION(pcmpgtw, _mm_cmpgt_epi16)
+SSE2I_INSTRUCTION(pand,_mm_and_si128)
+SSE2I_INSTRUCTION(por,_mm_or_si128)
+SSE2I_INSTRUCTION(pxor,_mm_xor_si128)
+SSE2I_INSTRUCTION(packuswb,_mm_packus_epi16)
+SSE2I_INSTRUCTION(packsswb,_mm_packs_epi16)
+SSE2I_INSTRUCTION(packssdw,_mm_packs_epi32)
+SSE2I_INSTRUCTION(punpcklbw,_mm_unpacklo_epi8)
+SSE2I_INSTRUCTION(punpckhbw,_mm_unpackhi_epi8)
+SSE2I_INSTRUCTION(punpcklwd,_mm_unpacklo_epi16)
+SSE2I_INSTRUCTION(punpckhwd,_mm_unpackhi_epi16)
+SSE2I_INSTRUCTION(punpckldq,_mm_unpacklo_epi32)
+SSE2I_INSTRUCTION(pmullw,_mm_mullo_epi16)
+SSE2I_INSTRUCTION(pmulhw,_mm_mulhi_epi16)
+SSE2I_INSTRUCTION(paddsb,_mm_adds_epi8)
+SSE2I_INSTRUCTION(paddb,_mm_add_epi8)
+SSE2I_INSTRUCTION(paddw,_mm_add_epi16)
+SSE2I_INSTRUCTION(paddsw,_mm_adds_epi16)
+SSE2I_INSTRUCTION(paddusw,_mm_adds_epu16)
+SSE2I_INSTRUCTION(paddd,_mm_add_epi32)
+SSE2I_INSTRUCTION(psubw,_mm_sub_epi16)
+SSE2I_INSTRUCTION(psubsw,_mm_subs_epi16)
+SSE2I_INSTRUCTION(psubusb,_mm_subs_epu8)
+SSE2I_INSTRUCTION(psubd,_mm_sub_epi32)
+SSE2I_INSTRUCTION(pmaddwd,_mm_madd_epi16)
+SSE2I_INSTRUCTION(pavgb,_mm_avg_epu8)
+SSE2I_INSTRUCTION(pcmpeqb,_mm_cmpeq_epi8)
+SSE2I_INSTRUCTION(pcmpeqw,_mm_cmpeq_epi16)
+SSE2I_INSTRUCTION(pcmpgtb,_mm_cmpgt_epi8)
+SSE2I_INSTRUCTION(pcmpgtw,_mm_cmpgt_epi16)
diff --git a/src/DSUtil/stdafx.cpp b/src/DSUtil/stdafx.cpp index 2bcb12eea..0cde80132 100644 --- a/src/DSUtil/stdafx.cpp +++ b/src/DSUtil/stdafx.cpp @@ -1,4 +1,4 @@ -/*
+/*
* Copyright (C) 2003-2006 Gabest
* http://www.gabest.org
*
@@ -6,15 +6,15 @@ * it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
- *
+ *
* This Program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with GNU Make; see the file COPYING. If not, write to
- * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
+ * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
* http://www.gnu.org/copyleft/gpl.html
*
*/
diff --git a/src/DSUtil/stdafx.h b/src/DSUtil/stdafx.h index ccf782b7b..46da40b57 100644 --- a/src/DSUtil/stdafx.h +++ b/src/DSUtil/stdafx.h @@ -1,4 +1,4 @@ -/*
+/*
* Copyright (C) 2003-2006 Gabest
* http://www.gabest.org
*
@@ -6,15 +6,15 @@ * it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
- *
+ *
* This Program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with GNU Make; see the file COPYING. If not, write to
- * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
+ * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
* http://www.gnu.org/copyleft/gpl.html
*
*/
diff --git a/src/DSUtil/text.cpp b/src/DSUtil/text.cpp index eb4e358e5..99d61f702 100644 --- a/src/DSUtil/text.cpp +++ b/src/DSUtil/text.cpp @@ -19,7 +19,7 @@ CString Explode(CString str, CAtlList<CString>& sl, TCHAR sep, int limit) sl.AddTail(tmp);
if(limit > 0 && sl.GetCount() == limit-1)
{
- if(j+1 < str.GetLength())
+ if(j+1 < str.GetLength())
{
CString tmp = str.Mid(j+1);
tmp.TrimLeft(sep); tmp.TrimRight(sep);
@@ -44,7 +44,7 @@ CString ExplodeMin(CString str, CAtlList<CString>& sl, TCHAR sep, int limit) {
Explode(str, sl, sep, limit);
POSITION pos = sl.GetHeadPosition();
- while(pos)
+ while(pos)
{
POSITION tmp = pos;
if(sl.GetNext(pos).IsEmpty())
@@ -70,160 +70,151 @@ CString Implode(CAtlList<CString>& sl, TCHAR sep) DWORD CharSetToCodePage(DWORD dwCharSet)
{
- if(dwCharSet == CP_UTF8) return CP_UTF8;
- if(dwCharSet == CP_UTF7) return CP_UTF7;
- CHARSETINFO cs = {0};
- ::TranslateCharsetInfo((DWORD *)dwCharSet, &cs, TCI_SRCCHARSET);
- return cs.ciACP;
+ if(dwCharSet == CP_UTF8) return CP_UTF8;
+ if(dwCharSet == CP_UTF7) return CP_UTF7;
+ CHARSETINFO cs={0};
+ ::TranslateCharsetInfo((DWORD *)dwCharSet, &cs, TCI_SRCCHARSET);
+ return cs.ciACP;
}
CStringA ConvertMBCS(CStringA str, DWORD SrcCharSet, DWORD DstCharSet)
{
- WCHAR* utf16 = DNew WCHAR[str.GetLength()+1];
- memset(utf16, 0, (str.GetLength() + 1)*sizeof(WCHAR));
+ WCHAR* utf16 = DNew WCHAR[str.GetLength()+1];
+ memset(utf16, 0, (str.GetLength()+1)*sizeof(WCHAR));
- CHAR* mbcs = DNew CHAR[str.GetLength()*6+1];
- memset(mbcs, 0, str.GetLength() * 6 + 1);
+ CHAR* mbcs = DNew CHAR[str.GetLength()*6+1];
+ memset(mbcs, 0, str.GetLength()*6+1);
- int len = MultiByteToWideChar(
- CharSetToCodePage(SrcCharSet), 0,
- str.GetBuffer(str.GetLength()), str.GetLength(),
- utf16, (str.GetLength() + 1) * sizeof(WCHAR));
+ int len = MultiByteToWideChar(
+ CharSetToCodePage(SrcCharSet), 0,
+ str.GetBuffer(str.GetLength()), str.GetLength(),
+ utf16, (str.GetLength()+1)*sizeof(WCHAR));
- len = WideCharToMultiByte(
- CharSetToCodePage(DstCharSet), 0,
- utf16, len,
- mbcs, str.GetLength() * 6,
- NULL, NULL);
+ len = WideCharToMultiByte(
+ CharSetToCodePage(DstCharSet), 0,
+ utf16, len,
+ mbcs, str.GetLength()*6,
+ NULL, NULL);
- str = mbcs;
+ str = mbcs;
- delete [] utf16;
- delete [] mbcs;
+ delete [] utf16;
+ delete [] mbcs;
- return str;
+ return str;
}
CStringA UrlEncode(CStringA str, bool fRaw)
{
- CStringA urlstr;
-
- for(size_t i = 0; i < str.GetLength(); i++)
- {
- CHAR c = str[i];
- if(fRaw && c == '+') urlstr += "%2B";
- else if(c > 0x20 && c < 0x7f && c != '&') urlstr += c;
- else if(c == 0x20) urlstr += fRaw ? ' ' : '+';
- else
- {
- CStringA tmp;
- tmp.Format("%%%02x", (BYTE)c);
- urlstr += tmp;
- }
- }
-
- return urlstr;
+ CStringA urlstr;
+
+ for(size_t i = 0; i < str.GetLength(); i++)
+ {
+ CHAR c = str[i];
+ if(fRaw && c == '+') urlstr += "%2B";
+ else if(c > 0x20 && c < 0x7f && c != '&') urlstr += c;
+ else if(c == 0x20) urlstr += fRaw ? ' ' : '+';
+ else {CStringA tmp; tmp.Format("%%%02x", (BYTE)c); urlstr += tmp;}
+ }
+
+ return urlstr;
}
CStringA UrlDecode(CStringA str, bool fRaw)
{
- str.Replace("&", "&");
-
- CHAR* s = str.GetBuffer(str.GetLength());
- CHAR* e = s + str.GetLength();
- CHAR* s1 = s;
- CHAR* s2 = s;
- while(s1 < e)
- {
- CHAR s11 = (s1 < e - 1) ? (__isascii(s1[1]) && isupper(s1[1]) ? tolower(s1[1]) : s1[1]) : 0;
- CHAR s12 = (s1 < e - 2) ? (__isascii(s1[2]) && isupper(s1[2]) ? tolower(s1[2]) : s1[2]) : 0;
-
- if(*s1 == '%' && s1 < e - 2
- && (s1[1] >= '0' && s1[1] <= '9' || s11 >= 'a' && s11 <= 'f')
- && (s1[2] >= '0' && s1[2] <= '9' || s12 >= 'a' && s12 <= 'f'))
- {
- s1[1] = s11;
- s1[2] = s12;
- *s2 = 0;
- if(s1[1] >= '0' && s1[1] <= '9') *s2 |= s1[1] - '0';
- else if(s1[1] >= 'a' && s1[1] <= 'f') *s2 |= s1[1] - 'a' + 10;
- *s2 <<= 4;
- if(s1[2] >= '0' && s1[2] <= '9') *s2 |= s1[2] - '0';
- else if(s1[2] >= 'a' && s1[2] <= 'f') *s2 |= s1[2] - 'a' + 10;
- s1 += 2;
- }
- else
- {
- *s2 = *s1 == '+' && !fRaw ? ' ' : *s1;
- }
-
- s1++;
- s2++;
- }
-
- str.ReleaseBuffer(s2 - s);
-
- return str;
+ str.Replace("&", "&");
+
+ CHAR* s = str.GetBuffer(str.GetLength());
+ CHAR* e = s + str.GetLength();
+ CHAR* s1 = s;
+ CHAR* s2 = s;
+ while(s1 < e)
+ {
+ CHAR s11 = (s1 < e-1) ? (__isascii(s1[1]) && isupper(s1[1]) ? tolower(s1[1]) : s1[1]) : 0;
+ CHAR s12 = (s1 < e-2) ? (__isascii(s1[2]) && isupper(s1[2]) ? tolower(s1[2]) : s1[2]) : 0;
+
+ if(*s1 == '%' && s1 < e-2
+ && (s1[1] >= '0' && s1[1] <= '9' || s11 >= 'a' && s11 <= 'f')
+ && (s1[2] >= '0' && s1[2] <= '9' || s12 >= 'a' && s12 <= 'f'))
+ {
+ s1[1] = s11;
+ s1[2] = s12;
+ *s2 = 0;
+ if(s1[1] >= '0' && s1[1] <= '9') *s2 |= s1[1]-'0';
+ else if(s1[1] >= 'a' && s1[1] <= 'f') *s2 |= s1[1]-'a'+10;
+ *s2 <<= 4;
+ if(s1[2] >= '0' && s1[2] <= '9') *s2 |= s1[2]-'0';
+ else if(s1[2] >= 'a' && s1[2] <= 'f') *s2 |= s1[2]-'a'+10;
+ s1 += 2;
+ }
+ else
+ {
+ *s2 = *s1 == '+' && !fRaw ? ' ' : *s1;
+ }
+
+ s1++;
+ s2++;
+ }
+
+ str.ReleaseBuffer(s2 - s);
+
+ return str;
}
CString ExtractTag(CString tag, CMapStringToString& attribs, bool& fClosing)
{
- tag.Trim();
- attribs.RemoveAll();
-
- fClosing = !tag.IsEmpty() ? tag[0] == '/' : false;
- tag.TrimLeft('/');
-
- int i = tag.Find(' ');
- if(i < 0) i = tag.GetLength();
- CString type = tag.Left(i).MakeLower();
- tag = tag.Mid(i).Trim();
-
- while((i = tag.Find('=')) > 0)
- {
- CString attrib = tag.Left(i).Trim().MakeLower();
- tag = tag.Mid(i + 1);
- for(i = 0; i < tag.GetLength() && _istspace(tag[i]); i++);
- tag = i < tag.GetLength() ? tag.Mid(i) : _T("");
- if(!tag.IsEmpty() && tag[0] == '\"')
- {
- tag = tag.Mid(1);
- i = tag.Find('\"');
- }
- else i = tag.Find(' ');
- if(i < 0) i = tag.GetLength();
- CString param = tag.Left(i).Trim();
- if(!param.IsEmpty())
- attribs[attrib] = param;
- tag = i + 1 < tag.GetLength() ? tag.Mid(i + 1) : _T("");
- }
-
- return(type);
+ tag.Trim();
+ attribs.RemoveAll();
+
+ fClosing = !tag.IsEmpty() ? tag[0] == '/' : false;
+ tag.TrimLeft('/');
+
+ int i = tag.Find(' ');
+ if(i < 0) i = tag.GetLength();
+ CString type = tag.Left(i).MakeLower();
+ tag = tag.Mid(i).Trim();
+
+ while((i = tag.Find('=')) > 0)
+ {
+ CString attrib = tag.Left(i).Trim().MakeLower();
+ tag = tag.Mid(i+1);
+ for(i = 0; i < tag.GetLength() && _istspace(tag[i]); i++);
+ tag = i < tag.GetLength() ? tag.Mid(i) : _T("");
+ if(!tag.IsEmpty() && tag[0] == '\"') {tag = tag.Mid(1); i = tag.Find('\"');}
+ else i = tag.Find(' ');
+ if(i < 0) i = tag.GetLength();
+ CString param = tag.Left(i).Trim();
+ if(!param.IsEmpty())
+ attribs[attrib] = param;
+ tag = i+1 < tag.GetLength() ? tag.Mid(i+1) : _T("");
+ }
+
+ return(type);
}
CAtlList<CString>& MakeLower(CAtlList<CString>& sl)
{
- POSITION pos = sl.GetHeadPosition();
- while(pos) sl.GetNext(pos).MakeLower();
- return sl;
+ POSITION pos = sl.GetHeadPosition();
+ while(pos) sl.GetNext(pos).MakeLower();
+ return sl;
}
CAtlList<CString>& MakeUpper(CAtlList<CString>& sl)
{
- POSITION pos = sl.GetHeadPosition();
- while(pos) sl.GetNext(pos).MakeUpper();
- return sl;
+ POSITION pos = sl.GetHeadPosition();
+ while(pos) sl.GetNext(pos).MakeUpper();
+ return sl;
}
CAtlList<CString>& RemoveStrings(CAtlList<CString>& sl, int minlen, int maxlen)
{
- POSITION pos = sl.GetHeadPosition();
- while(pos)
- {
- POSITION tmp = pos;
- CString& str = sl.GetNext(pos);
- int len = str.GetLength();
- if(len < minlen || len > maxlen) sl.RemoveAt(tmp);
- }
- return sl;
+ POSITION pos = sl.GetHeadPosition();
+ while(pos)
+ {
+ POSITION tmp = pos;
+ CString& str = sl.GetNext(pos);
+ int len = str.GetLength();
+ if(len < minlen || len > maxlen) sl.RemoveAt(tmp);
+ }
+ return sl;
}
diff --git a/src/DSUtil/text.h b/src/DSUtil/text.h index 3f7a232d9..caef07a1a 100644 --- a/src/DSUtil/text.h +++ b/src/DSUtil/text.h @@ -9,53 +9,53 @@ template<class T, typename SEP>
T Explode(T str, CAtlList<T>& sl, SEP sep, size_t limit = 0)
{
- sl.RemoveAll();
+ sl.RemoveAll();
- for(ptrdiff_t i = 0, j = 0; ; i = j + 1)
- {
- j = str.Find(sep, i);
+ for(ptrdiff_t i = 0, j = 0; ; i = j+1)
+ {
+ j = str.Find(sep, i);
- if(j < 0 || sl.GetCount() == limit - 1)
- {
- sl.AddTail(str.Mid(i).Trim());
- break;
- }
- else
- {
- sl.AddTail(str.Mid(i, j - i).Trim());
- }
- }
+ if(j < 0 || sl.GetCount() == limit-1)
+ {
+ sl.AddTail(str.Mid(i).Trim());
+ break;
+ }
+ else
+ {
+ sl.AddTail(str.Mid(i, j-i).Trim());
+ }
+ }
- return sl.GetHead();
+ return sl.GetHead();
}
template<class T, typename SEP>
T ExplodeMin(T str, CAtlList<T>& sl, SEP sep, size_t limit = 0)
{
- Explode(str, sl, sep, limit);
- POSITION pos = sl.GetHeadPosition();
- while(pos)
- {
- POSITION tmp = pos;
- if(sl.GetNext(pos).IsEmpty())
- sl.RemoveAt(tmp);
- }
- if(sl.IsEmpty()) sl.AddTail(T()); // eh
+ Explode(str, sl, sep, limit);
+ POSITION pos = sl.GetHeadPosition();
+ while(pos)
+ {
+ POSITION tmp = pos;
+ if(sl.GetNext(pos).IsEmpty())
+ sl.RemoveAt(tmp);
+ }
+ if(sl.IsEmpty()) sl.AddTail(T()); // eh
- return sl.GetHead();
+ return sl.GetHead();
}
template<class T, typename SEP>
T Implode(CAtlList<T>& sl, SEP sep)
{
- T ret;
- POSITION pos = sl.GetHeadPosition();
- while(pos)
- {
- ret += sl.GetNext(pos);
- if(pos) ret += sep;
- }
- return(ret);
+ T ret;
+ POSITION pos = sl.GetHeadPosition();
+ while(pos)
+ {
+ ret += sl.GetNext(pos);
+ if(pos) ret += sep;
+ }
+ return(ret);
}
extern CString ExtractTag(CString tag, CMapStringToString& attribs, bool& fClosing);
diff --git a/src/DSUtil/vd.cpp b/src/DSUtil/vd.cpp index 2a8610cf2..0b06b043b 100644 --- a/src/DSUtil/vd.cpp +++ b/src/DSUtil/vd.cpp @@ -15,7 +15,7 @@ // along with this program; if not, write to the Free Software
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
//
-// Notes:
+// Notes:
// - BitBltFromI420ToRGB is from VirtualDub
// - The core assembly function of CCpuID is from DVD2AVI
// - sse2 yv12 to yuy2 conversion by Haali
@@ -34,608 +34,591 @@ CCpuID g_cpuid; CCpuID::CCpuID()
{
- // TODOX64 : ??
- CPUID_ARGS ca;
- ca.eax = 1;
- _CPUID(&ca);
-
- int t = ca.edx;
-
- int mflags = 0;
- mflags |= ((t & 0x00800000) != 0) ? mmx : 0; // STD MMX
- mflags |= ((t & 0x02000000) != 0) ? ssemmx + ssefpu : 0; // STD SSE
- mflags |= ((t & 0x04000000) != 0) ? sse2 : 0; // SSE2
-
- // 3dnow
- ca.eax = 0x80000001;
- _CPUID(&ca);
- t = ca.edx;
- mflags |= ((t & 0x80000000) != 0) ? _3dnow : 0; // 3D NOW
- mflags |= ((t & 0x00400000) != 0) ? ssemmx : 0; // SSE MMX
-
- // result
- //m_flags = (flag_t)7;
- m_flags = (flag_t)mflags;
+ // TODOX64 : ??
+ CPUID_ARGS ca;
+ ca.eax = 1;
+ _CPUID(&ca);
+
+ int t = ca.edx;
+
+ int mflags = 0;
+ mflags |= ((t&0x00800000)!=0) ? mmx : 0; // STD MMX
+ mflags |= ((t&0x02000000)!=0) ? ssemmx+ssefpu : 0;// STD SSE
+ mflags |= ((t&0x04000000)!=0) ? sse2 : 0; // SSE2
+
+ // 3dnow
+ ca.eax = 0x80000001;
+ _CPUID(&ca);
+ t = ca.edx;
+ mflags |= ((t&0x80000000)!=0) ? _3dnow : 0; // 3D NOW
+ mflags |= ((t&0x00400000)!=0) ? ssemmx : 0; // SSE MMX
+
+ // result
+ //m_flags = (flag_t)7;
+ m_flags = (flag_t)mflags;
}
static void yuvtoyuy2row_c(BYTE* dst, BYTE* srcy, BYTE* srcu, BYTE* srcv, DWORD width)
{
- WORD* dstw = (WORD*)dst;
- for(; width > 1; width -= 2)
- {
- *dstw++ = (*srcu++ << 8) | *srcy++;
- *dstw++ = (*srcv++ << 8) | *srcy++;
- }
+ WORD* dstw = (WORD*)dst;
+ for(; width > 1; width -= 2)
+ {
+ *dstw++ = (*srcu++<<8)|*srcy++;
+ *dstw++ = (*srcv++<<8)|*srcy++;
+ }
}
static void yuvtoyuy2row_avg_c(BYTE* dst, BYTE* srcy, BYTE* srcu, BYTE* srcv, DWORD width, DWORD pitchuv)
{
- WORD* dstw = (WORD*)dst;
- for(; width > 1; width -= 2, srcu++, srcv++)
- {
- *dstw++ = (((srcu[0] + srcu[pitchuv]) >> 1) << 8) | *srcy++;
- *dstw++ = (((srcv[0] + srcv[pitchuv]) >> 1) << 8) | *srcy++;
- }
+ WORD* dstw = (WORD*)dst;
+ for(; width > 1; width -= 2, srcu++, srcv++)
+ {
+ *dstw++ = (((srcu[0]+srcu[pitchuv])>>1)<<8)|*srcy++;
+ *dstw++ = (((srcv[0]+srcv[pitchuv])>>1)<<8)|*srcy++;
+ }
}
static void asm_blend_row_clipped_c(BYTE* dst, BYTE* src, DWORD w, DWORD srcpitch)
{
- BYTE* src2 = src + srcpitch;
- do
- {
- *dst++ = (*src++ + *src2++ + 1) >> 1;
- }
- while(w--);
+ BYTE* src2 = src + srcpitch;
+ do {*dst++ = (*src++ + *src2++ + 1) >> 1;}
+ while(w--);
}
static void asm_blend_row_c(BYTE* dst, BYTE* src, DWORD w, DWORD srcpitch)
{
- BYTE* src2 = src + srcpitch;
- BYTE* src3 = src2 + srcpitch;
- do
- {
- *dst++ = (*src++ + (*src2++ << 1) + *src3++ + 2) >> 2;
- }
- while(w--);
+ BYTE* src2 = src + srcpitch;
+ BYTE* src3 = src2 + srcpitch;
+ do {*dst++ = (*src++ + (*src2++ << 1) + *src3++ + 2) >> 2;}
+ while(w--);
}
bool BitBltFromI420ToI420(int w, int h, BYTE* dsty, BYTE* dstu, BYTE* dstv, int dstpitch, BYTE* srcy, BYTE* srcu, BYTE* srcv, int srcpitch)
{
- if((w & 1)) return(false);
+ if((w&1)) return(false);
- if(w > 0 && w == srcpitch && w == dstpitch)
- {
- memcpy(dsty, srcy, h * srcpitch);
- memcpy(dstu, srcu, h / 2 * srcpitch / 2);
- memcpy(dstv, srcv, h / 2 * srcpitch / 2);
- }
- else
- {
- int pitch = min(abs(srcpitch), abs(dstpitch));
+ if(w > 0 && w == srcpitch && w == dstpitch)
+ {
+ memcpy(dsty, srcy, h*srcpitch);
+ memcpy(dstu, srcu, h/2*srcpitch/2);
+ memcpy(dstv, srcv, h/2*srcpitch/2);
+ }
+ else
+ {
+ int pitch = min(abs(srcpitch), abs(dstpitch));
- for(ptrdiff_t y = 0; y < h; y++, srcy += srcpitch, dsty += dstpitch)
- memcpy(dsty, srcy, pitch);
+ for(ptrdiff_t y = 0; y < h; y++, srcy += srcpitch, dsty += dstpitch)
+ memcpy(dsty, srcy, pitch);
- srcpitch >>= 1;
- dstpitch >>= 1;
+ srcpitch >>= 1;
+ dstpitch >>= 1;
- pitch = min(abs(srcpitch), abs(dstpitch));
+ pitch = min(abs(srcpitch), abs(dstpitch));
- for(ptrdiff_t y = 0; y < h; y += 2, srcu += srcpitch, dstu += dstpitch)
- memcpy(dstu, srcu, pitch);
+ for(ptrdiff_t y = 0; y < h; y+=2, srcu += srcpitch, dstu += dstpitch)
+ memcpy(dstu, srcu, pitch);
- for(ptrdiff_t y = 0; y < h; y += 2, srcv += srcpitch, dstv += dstpitch)
- memcpy(dstv, srcv, pitch);
- }
+ for(ptrdiff_t y = 0; y < h; y+=2, srcv += srcpitch, dstv += dstpitch)
+ memcpy(dstv, srcv, pitch);
+ }
- return true;
+ return true;
}
bool BitBltFromI420ToYUY2(int w, int h, BYTE* dst, int dstpitch, BYTE* srcy, BYTE* srcu, BYTE* srcv, int srcpitch, bool fInterlaced)
{
- if(w <= 0 || h <= 0 || (w & 1) || (h & 1))
- return(false);
+ if(w<=0 || h<=0 || (w&1) || (h&1))
+ return(false);
- if(srcpitch == 0) srcpitch = w;
+ if(srcpitch == 0) srcpitch = w;
- do
- {
- yuvtoyuy2row_c(dst, srcy, srcu, srcv, w);
- yuvtoyuy2row_avg_c(dst + dstpitch, srcy + srcpitch, srcu, srcv, w, srcpitch / 2);
+ do
+ {
+ yuvtoyuy2row_c(dst, srcy, srcu, srcv, w);
+ yuvtoyuy2row_avg_c(dst + dstpitch, srcy + srcpitch, srcu, srcv, w, srcpitch/2);
- dst += 2 * dstpitch;
- srcy += srcpitch * 2;
- srcu += srcpitch / 2;
- srcv += srcpitch / 2;
- }
- while((h -= 2) > 2);
+ dst += 2*dstpitch;
+ srcy += srcpitch*2;
+ srcu += srcpitch/2;
+ srcv += srcpitch/2;
+ }
+ while((h -= 2) > 2);
- yuvtoyuy2row_c(dst, srcy, srcu, srcv, w);
- yuvtoyuy2row_c(dst + dstpitch, srcy + srcpitch, srcu, srcv, w);
+ yuvtoyuy2row_c(dst, srcy, srcu, srcv, w);
+ yuvtoyuy2row_c(dst + dstpitch, srcy + srcpitch, srcu, srcv, w);
- return(true);
+ return(true);
}
bool BitBltFromYUY2ToYUY2(int w, int h, BYTE* dst, int dstpitch, BYTE* src, int srcpitch)
{
- if(w > 0 && w == srcpitch && w == dstpitch)
- {
- memcpy(dst, src, h * srcpitch);
- }
- else
- {
- int pitch = min(abs(srcpitch), abs(dstpitch));
-
- for(ptrdiff_t y = 0; y < h; y++, src += srcpitch, dst += dstpitch)
- memcpy(dst, src, pitch);
- }
-
- return(true);
+ if(w > 0 && w == srcpitch && w == dstpitch)
+ {
+ memcpy(dst, src, h*srcpitch);
+ }
+ else
+ {
+ int pitch = min(abs(srcpitch), abs(dstpitch));
+
+ for(ptrdiff_t y = 0; y < h; y++, src += srcpitch, dst += dstpitch)
+ memcpy(dst, src, pitch);
+ }
+
+ return(true);
}
bool BitBltFromI420ToRGB(int w, int h, BYTE* dst, int dstpitch, int dbpp, BYTE* srcy, BYTE* srcu, BYTE* srcv, int srcpitch)
{
- ASSERT(FALSE);
- return false;
+ ASSERT(FALSE);
+ return false;
}
bool BitBltFromRGBToRGB(int w, int h, BYTE* dst, int dstpitch, int dbpp, BYTE* src, int srcpitch, int sbpp)
{
- if(dbpp == sbpp)
- {
- int rowbytes = w * dbpp >> 3;
-
- if(rowbytes > 0 && rowbytes == srcpitch && rowbytes == dstpitch)
- {
- memcpy(dst, src, h * rowbytes);
- }
- else
- {
- for(ptrdiff_t y = 0; y < h; y++, src += srcpitch, dst += dstpitch)
- memcpy(dst, src, rowbytes);
- }
-
- return(true);
- }
-
- if(sbpp != 16 && sbpp != 24 && sbpp != 32
- || dbpp != 16 && dbpp != 24 && dbpp != 32)
- return(false);
-
- if(dbpp == 16)
- {
- for(ptrdiff_t y = 0; y < h; y++, src += srcpitch, dst += dstpitch)
- {
- if(sbpp == 24)
- {
- BYTE* s = (BYTE*)src;
- WORD* d = (WORD*)dst;
- for(ptrdiff_t x = 0; x < w; x++, s += 3, d++)
- * d = (WORD)(((*((DWORD*)s) >> 8) & 0xf800) | ((*((DWORD*)s) >> 5) & 0x07e0) | ((*((DWORD*)s) >> 3) & 0x1f));
- }
- else if(sbpp == 32)
- {
- DWORD* s = (DWORD*)src;
- WORD* d = (WORD*)dst;
- for(ptrdiff_t x = 0; x < w; x++, s++, d++)
- *d = (WORD)(((*s >> 8) & 0xf800) | ((*s >> 5) & 0x07e0) | ((*s >> 3) & 0x1f));
- }
- }
- }
- else if(dbpp == 24)
- {
- for(ptrdiff_t y = 0; y < h; y++, src += srcpitch, dst += dstpitch)
- {
- if(sbpp == 16)
- {
- WORD* s = (WORD*)src;
- BYTE* d = (BYTE*)dst;
- for(ptrdiff_t x = 0; x < w; x++, s++, d += 3)
- {
- // not tested, r-g-b might be in reverse
- d[0] = (*s & 0x001f) << 3;
- d[1] = (*s & 0x07e0) << 5;
- d[2] = (*s & 0xf800) << 8;
- }
- }
- else if(sbpp == 32)
- {
- BYTE* s = (BYTE*)src;
- BYTE* d = (BYTE*)dst;
- for(ptrdiff_t x = 0; x < w; x++, s += 4, d += 3)
- {
- d[0] = s[0];
- d[1] = s[1];
- d[2] = s[2];
- }
- }
- }
- }
- else if(dbpp == 32)
- {
- for(ptrdiff_t y = 0; y < h; y++, src += srcpitch, dst += dstpitch)
- {
- if(sbpp == 16)
- {
- WORD* s = (WORD*)src;
- DWORD* d = (DWORD*)dst;
- for(ptrdiff_t x = 0; x < w; x++, s++, d++)
- *d = ((*s & 0xf800) << 8) | ((*s & 0x07e0) << 5) | ((*s & 0x001f) << 3);
- }
- else if(sbpp == 24)
- {
- BYTE* s = (BYTE*)src;
- DWORD* d = (DWORD*)dst;
- for(ptrdiff_t x = 0; x < w; x++, s += 3, d++)
- * d = *((DWORD*)s) & 0xffffff;
- }
- }
- }
-
- return(true);
+ if(dbpp == sbpp)
+ {
+ int rowbytes = w*dbpp>>3;
+
+ if(rowbytes > 0 && rowbytes == srcpitch && rowbytes == dstpitch)
+ {
+ memcpy(dst, src, h*rowbytes);
+ }
+ else
+ {
+ for(ptrdiff_t y = 0; y < h; y++, src += srcpitch, dst += dstpitch)
+ memcpy(dst, src, rowbytes);
+ }
+
+ return(true);
+ }
+
+ if(sbpp != 16 && sbpp != 24 && sbpp != 32
+ || dbpp != 16 && dbpp != 24 && dbpp != 32)
+ return(false);
+
+ if(dbpp == 16)
+ {
+ for(ptrdiff_t y = 0; y < h; y++, src += srcpitch, dst += dstpitch)
+ {
+ if(sbpp == 24)
+ {
+ BYTE* s = (BYTE*)src;
+ WORD* d = (WORD*)dst;
+ for(ptrdiff_t x = 0; x < w; x++, s+=3, d++)
+ *d = (WORD)(((*((DWORD*)s)>>8)&0xf800)|((*((DWORD*)s)>>5)&0x07e0)|((*((DWORD*)s)>>3)&0x1f));
+ }
+ else if(sbpp == 32)
+ {
+ DWORD* s = (DWORD*)src;
+ WORD* d = (WORD*)dst;
+ for(ptrdiff_t x = 0; x < w; x++, s++, d++)
+ *d = (WORD)(((*s>>8)&0xf800)|((*s>>5)&0x07e0)|((*s>>3)&0x1f));
+ }
+ }
+ }
+ else if(dbpp == 24)
+ {
+ for(ptrdiff_t y = 0; y < h; y++, src += srcpitch, dst += dstpitch)
+ {
+ if(sbpp == 16)
+ {
+ WORD* s = (WORD*)src;
+ BYTE* d = (BYTE*)dst;
+ for(ptrdiff_t x = 0; x < w; x++, s++, d+=3)
+ { // not tested, r-g-b might be in reverse
+ d[0] = (*s&0x001f)<<3;
+ d[1] = (*s&0x07e0)<<5;
+ d[2] = (*s&0xf800)<<8;
+ }
+ }
+ else if(sbpp == 32)
+ {
+ BYTE* s = (BYTE*)src;
+ BYTE* d = (BYTE*)dst;
+ for(ptrdiff_t x = 0; x < w; x++, s+=4, d+=3)
+ {d[0] = s[0]; d[1] = s[1]; d[2] = s[2];}
+ }
+ }
+ }
+ else if(dbpp == 32)
+ {
+ for(ptrdiff_t y = 0; y < h; y++, src += srcpitch, dst += dstpitch)
+ {
+ if(sbpp == 16)
+ {
+ WORD* s = (WORD*)src;
+ DWORD* d = (DWORD*)dst;
+ for(ptrdiff_t x = 0; x < w; x++, s++, d++)
+ *d = ((*s&0xf800)<<8)|((*s&0x07e0)<<5)|((*s&0x001f)<<3);
+ }
+ else if(sbpp == 24)
+ {
+ BYTE* s = (BYTE*)src;
+ DWORD* d = (DWORD*)dst;
+ for(ptrdiff_t x = 0; x < w; x++, s+=3, d++)
+ *d = *((DWORD*)s)&0xffffff;
+ }
+ }
+ }
+
+ return(true);
}
bool BitBltFromYUY2ToRGB(int w, int h, BYTE* dst, int dstpitch, int dbpp, BYTE* src, int srcpitch)
{
- ASSERT(FALSE);
- return false;
+ ASSERT(FALSE);
+ return false;
}
void DeinterlaceBlend(BYTE* dst, BYTE* src, DWORD rowbytes, DWORD h, DWORD dstpitch, DWORD srcpitch)
{
- asm_blend_row_clipped_c(dst, src, rowbytes, srcpitch);
+ asm_blend_row_clipped_c(dst, src, rowbytes, srcpitch);
- if((h -= 2) > 0) do
- {
- dst += dstpitch;
- asm_blend_row_c(dst, src, rowbytes, srcpitch);
- src += srcpitch;
- }
- while(--h);
+ if((h -= 2) > 0) do
+ {
+ dst += dstpitch;
+ asm_blend_row_c(dst, src, rowbytes, srcpitch);
+ src += srcpitch;
+ }
+ while(--h);
- asm_blend_row_clipped_c(dst + dstpitch, src, rowbytes, srcpitch);
+ asm_blend_row_clipped_c(dst + dstpitch, src, rowbytes, srcpitch);
}
void DeinterlaceBob(BYTE* dst, BYTE* src, DWORD rowbytes, DWORD h, DWORD dstpitch, DWORD srcpitch, bool topfield)
{
- if(topfield)
- {
- BitBltFromRGBToRGB(rowbytes, h / 2, dst, dstpitch * 2, 8, src, srcpitch * 2, 8);
- AvgLines8(dst, h, dstpitch);
- }
- else
- {
- BitBltFromRGBToRGB(rowbytes, h / 2, dst + dstpitch, dstpitch * 2, 8, src + srcpitch, srcpitch * 2, 8);
- AvgLines8(dst + dstpitch, h - 1, dstpitch);
- }
+ if(topfield)
+ {
+ BitBltFromRGBToRGB(rowbytes, h/2, dst, dstpitch*2, 8, src, srcpitch*2, 8);
+ AvgLines8(dst, h, dstpitch);
+ }
+ else
+ {
+ BitBltFromRGBToRGB(rowbytes, h/2, dst + dstpitch, dstpitch*2, 8, src + srcpitch, srcpitch*2, 8);
+ AvgLines8(dst + dstpitch, h-1, dstpitch);
+ }
}
void AvgLines8(BYTE* dst, DWORD h, DWORD pitch)
{
- if(h <= 1) return;
+ if(h <= 1) return;
- BYTE* s = dst;
- BYTE* d = dst + (h - 2) * pitch;
+ BYTE* s = dst;
+ BYTE* d = dst + (h-2)*pitch;
- for(; s < d; s += pitch * 2)
- {
- BYTE* tmp = s;
+ for(; s < d; s += pitch*2)
+ {
+ BYTE* tmp = s;
- {
- for(ptrdiff_t i = pitch; i--; tmp++)
- {
- tmp[pitch] = (tmp[0] + tmp[pitch<<1] + 1) >> 1;
- }
- }
- }
+ {
+ for(ptrdiff_t i = pitch; i--; tmp++)
+ {
+ tmp[pitch] = (tmp[0] + tmp[pitch<<1] + 1) >> 1;
+ }
+ }
+ }
- if(!(h & 1) && h >= 2)
- {
- dst += (h - 2) * pitch;
- memcpy(dst + pitch, dst, pitch);
- }
+ if(!(h&1) && h >= 2)
+ {
+ dst += (h-2)*pitch;
+ memcpy(dst + pitch, dst, pitch);
+ }
}
void AvgLines555(BYTE* dst, DWORD h, DWORD pitch)
{
- if(h <= 1) return;
-
- BYTE* s = dst;
- BYTE* d = dst + (h - 2) * pitch;
-
- for(; s < d; s += pitch * 2)
- {
- WORD* tmp = (WORD*)s;
-
- for(ptrdiff_t wd = (pitch >> 3); wd--; tmp++)
- {
- tmp[0] =
- ((((*tmp & 0x7c00) + (tmp[pitch<<1] & 0x7c00)) >> 1) & 0x7c00) |
- ((((*tmp & 0x03e0) + (tmp[pitch<<1] & 0x03e0)) >> 1) & 0x03e0) |
- ((((*tmp & 0x001f) + (tmp[pitch<<1] & 0x001f)) >> 1) & 0x001f);
- }
-
- 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) |
- ((((*tmp & 0x001f) + (tmp[pitch<<1] & 0x001f)) >> 1) & 0x001f);
- }
- }
-
- if(!(h & 1) && h >= 2)
- {
- dst += (h - 2) * pitch;
- memcpy(dst + pitch, dst, pitch);
- }
+ if(h <= 1) return;
+
+ BYTE* s = dst;
+ BYTE* d = dst + (h-2)*pitch;
+
+ for(; s < d; s += pitch*2)
+ {
+ WORD* tmp = (WORD*)s;
+
+ for(ptrdiff_t wd=(pitch>>3);wd--;tmp++)
+ {
+ tmp[0] =
+ ((((*tmp&0x7c00) + (tmp[pitch<<1]&0x7c00)) >> 1)&0x7c00)|
+ ((((*tmp&0x03e0) + (tmp[pitch<<1]&0x03e0)) >> 1)&0x03e0)|
+ ((((*tmp&0x001f) + (tmp[pitch<<1]&0x001f)) >> 1)&0x001f);
+ }
+
+ 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)|
+ ((((*tmp&0x001f) + (tmp[pitch<<1]&0x001f)) >> 1)&0x001f);
+ }
+ }
+
+ if(!(h&1) && h >= 2)
+ {
+ dst += (h-2)*pitch;
+ memcpy(dst + pitch, dst, pitch);
+ }
}
void AvgLines565(BYTE* dst, DWORD h, DWORD pitch)
{
- if(h <= 1) return;
-
- BYTE* s = dst;
- BYTE* d = dst + (h - 2) * pitch;
-
- for(; s < d; s += pitch * 2)
- {
- WORD* tmp = (WORD*)s;
-
- 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) |
- ((((*tmp & 0x001f) + (tmp[pitch<<1] & 0x001f)) >> 1) & 0x001f);
- }
-
- 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) |
- ((((*tmp & 0x001f) + (tmp[pitch<<1] & 0x001f)) >> 1) & 0x001f);
- }
- }
-
- if(!(h & 1) && h >= 2)
- {
- dst += (h - 2) * pitch;
- memcpy(dst + pitch, dst, pitch);
- }
+ if(h <= 1) return;
+
+ BYTE* s = dst;
+ BYTE* d = dst + (h-2)*pitch;
+
+ for(; s < d; s += pitch*2)
+ {
+ WORD* tmp = (WORD*)s;
+
+ 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)|
+ ((((*tmp&0x001f) + (tmp[pitch<<1]&0x001f)) >> 1)&0x001f);
+ }
+
+ 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)|
+ ((((*tmp&0x001f) + (tmp[pitch<<1]&0x001f)) >> 1)&0x001f);
+ }
+ }
+
+ if(!(h&1) && h >= 2)
+ {
+ dst += (h-2)*pitch;
+ memcpy(dst + pitch, dst, pitch);
+ }
}
#else // _WIN64
CCpuID::CCpuID()
{
- DWORD flags = 0;
-
- __asm
- {
- mov eax, 1
- cpuid
- test edx, 0x00800000 // STD MMX
- jz TEST_SSE
- or [flags], 1
- TEST_SSE:
- test edx, 0x02000000 // STD SSE
- jz TEST_SSE2
- or [flags], 2
- or [flags], 4
- TEST_SSE2:
- test edx, 0x04000000 // SSE2
- jz TEST_3DNOW
- or [flags], 8
- TEST_3DNOW:
- mov eax, 0x80000001
- cpuid
- test edx, 0x80000000 // 3D NOW
- jz TEST_SSEMMX
- or [flags], 16
- TEST_SSEMMX:
- test edx, 0x00400000 // SSE MMX
- jz TEST_END
- or [flags], 2
- TEST_END:
- }
-
- m_flags = (flag_t)flags;
+ DWORD flags = 0;
+
+ __asm
+ {
+ mov eax, 1
+ cpuid
+ test edx, 0x00800000 // STD MMX
+ jz TEST_SSE
+ or [flags], 1
+TEST_SSE:
+ test edx, 0x02000000 // STD SSE
+ jz TEST_SSE2
+ or [flags], 2
+ or [flags], 4
+TEST_SSE2:
+ test edx, 0x04000000 // SSE2
+ jz TEST_3DNOW
+ or [flags], 8
+TEST_3DNOW:
+ mov eax, 0x80000001
+ cpuid
+ test edx, 0x80000000 // 3D NOW
+ jz TEST_SSEMMX
+ or [flags], 16
+TEST_SSEMMX:
+ test edx, 0x00400000 // SSE MMX
+ jz TEST_END
+ or [flags], 2
+TEST_END:
+ }
+
+ m_flags = (flag_t)flags;
}
CCpuID g_cpuid;
void memcpy_accel(void* dst, const void* src, size_t len)
{
- if((g_cpuid.m_flags & CCpuID::ssefpu) && len >= 128
- && !((DWORD)src & 15) && !((DWORD)dst & 15))
- {
- __asm
- {
- mov esi, dword ptr [src]
- mov edi, dword ptr [dst]
- mov ecx, len
- shr ecx, 7
- memcpy_accel_sse_loop:
- prefetchnta [esi+16*8]
- movaps xmm0, [esi]
- movaps xmm1, [esi+16*1]
- movaps xmm2, [esi+16*2]
- movaps xmm3, [esi+16*3]
- movaps xmm4, [esi+16*4]
- movaps xmm5, [esi+16*5]
- movaps xmm6, [esi+16*6]
- movaps xmm7, [esi+16*7]
- movntps [edi], xmm0
- movntps [edi+16*1], xmm1
- movntps [edi+16*2], xmm2
- movntps [edi+16*3], xmm3
- movntps [edi+16*4], xmm4
- movntps [edi+16*5], xmm5
- movntps [edi+16*6], xmm6
- movntps [edi+16*7], xmm7
- add esi, 128
- add edi, 128
- dec ecx
- jne memcpy_accel_sse_loop
- mov ecx, len
- and ecx, 127
- cmp ecx, 0
- je memcpy_accel_sse_end
- memcpy_accel_sse_loop2:
- mov dl, byte ptr[esi]
- mov byte ptr[edi], dl
- inc esi
- inc edi
- dec ecx
- jne memcpy_accel_sse_loop2
- memcpy_accel_sse_end:
- emms
- sfence
- }
- }
- else if((g_cpuid.m_flags & CCpuID::mmx) && len >= 64
- && !((DWORD)src & 7) && !((DWORD)dst & 7))
- {
- __asm
- {
- mov esi, dword ptr [src]
- mov edi, dword ptr [dst]
- mov ecx, len
- shr ecx, 6
- memcpy_accel_mmx_loop:
- movq mm0, qword ptr [esi]
- movq mm1, qword ptr [esi+8*1]
- movq mm2, qword ptr [esi+8*2]
- movq mm3, qword ptr [esi+8*3]
- movq mm4, qword ptr [esi+8*4]
- movq mm5, qword ptr [esi+8*5]
- movq mm6, qword ptr [esi+8*6]
- movq mm7, qword ptr [esi+8*7]
- movq qword ptr [edi], mm0
- movq qword ptr [edi+8*1], mm1
- movq qword ptr [edi+8*2], mm2
- movq qword ptr [edi+8*3], mm3
- movq qword ptr [edi+8*4], mm4
- movq qword ptr [edi+8*5], mm5
- movq qword ptr [edi+8*6], mm6
- movq qword ptr [edi+8*7], mm7
- add esi, 64
- add edi, 64
- loop memcpy_accel_mmx_loop
- mov ecx, len
- and ecx, 63
- cmp ecx, 0
- je memcpy_accel_mmx_end
- memcpy_accel_mmx_loop2:
- mov dl, byte ptr [esi]
- mov byte ptr [edi], dl
- inc esi
- inc edi
- dec ecx
- jne memcpy_accel_mmx_loop2
- memcpy_accel_mmx_end:
- emms
- }
- }
- else
- {
- memcpy(dst, src, len);
- }
+ if((g_cpuid.m_flags & CCpuID::ssefpu) && len >= 128
+ && !((DWORD)src&15) && !((DWORD)dst&15))
+ {
+ __asm
+ {
+ mov esi, dword ptr [src]
+ mov edi, dword ptr [dst]
+ mov ecx, len
+ shr ecx, 7
+ memcpy_accel_sse_loop:
+ prefetchnta [esi+16*8]
+ movaps xmm0, [esi]
+ movaps xmm1, [esi+16*1]
+ movaps xmm2, [esi+16*2]
+ movaps xmm3, [esi+16*3]
+ movaps xmm4, [esi+16*4]
+ movaps xmm5, [esi+16*5]
+ movaps xmm6, [esi+16*6]
+ movaps xmm7, [esi+16*7]
+ movntps [edi], xmm0
+ movntps [edi+16*1], xmm1
+ movntps [edi+16*2], xmm2
+ movntps [edi+16*3], xmm3
+ movntps [edi+16*4], xmm4
+ movntps [edi+16*5], xmm5
+ movntps [edi+16*6], xmm6
+ movntps [edi+16*7], xmm7
+ add esi, 128
+ add edi, 128
+ dec ecx
+ jne memcpy_accel_sse_loop
+ mov ecx, len
+ and ecx, 127
+ cmp ecx, 0
+ je memcpy_accel_sse_end
+ memcpy_accel_sse_loop2:
+ mov dl, byte ptr[esi]
+ mov byte ptr[edi], dl
+ inc esi
+ inc edi
+ dec ecx
+ jne memcpy_accel_sse_loop2
+ memcpy_accel_sse_end:
+ emms
+ sfence
+ }
+ }
+ else if((g_cpuid.m_flags & CCpuID::mmx) && len >= 64
+ && !((DWORD)src&7) && !((DWORD)dst&7))
+ {
+ __asm
+ {
+ mov esi, dword ptr [src]
+ mov edi, dword ptr [dst]
+ mov ecx, len
+ shr ecx, 6
+ memcpy_accel_mmx_loop:
+ movq mm0, qword ptr [esi]
+ movq mm1, qword ptr [esi+8*1]
+ movq mm2, qword ptr [esi+8*2]
+ movq mm3, qword ptr [esi+8*3]
+ movq mm4, qword ptr [esi+8*4]
+ movq mm5, qword ptr [esi+8*5]
+ movq mm6, qword ptr [esi+8*6]
+ movq mm7, qword ptr [esi+8*7]
+ movq qword ptr [edi], mm0
+ movq qword ptr [edi+8*1], mm1
+ movq qword ptr [edi+8*2], mm2
+ movq qword ptr [edi+8*3], mm3
+ movq qword ptr [edi+8*4], mm4
+ movq qword ptr [edi+8*5], mm5
+ movq qword ptr [edi+8*6], mm6
+ movq qword ptr [edi+8*7], mm7
+ add esi, 64
+ add edi, 64
+ loop memcpy_accel_mmx_loop
+ mov ecx, len
+ and ecx, 63
+ cmp ecx, 0
+ je memcpy_accel_mmx_end
+ memcpy_accel_mmx_loop2:
+ mov dl, byte ptr [esi]
+ mov byte ptr [edi], dl
+ inc esi
+ inc edi
+ dec ecx
+ jne memcpy_accel_mmx_loop2
+ memcpy_accel_mmx_end:
+ emms
+ }
+ }
+ else
+ {
+ memcpy(dst, src, len);
+ }
}
static void yuvtoyuy2row_c(BYTE* dst, BYTE* srcy, BYTE* srcu, BYTE* srcv, DWORD width)
{
- WORD* dstw = (WORD*)dst;
- for(; width > 1; width -= 2)
- {
- *dstw++ = (*srcu++ << 8) | *srcy++;
- *dstw++ = (*srcv++ << 8) | *srcy++;
- }
+ WORD* dstw = (WORD*)dst;
+ for(; width > 1; width -= 2)
+ {
+ *dstw++ = (*srcu++<<8)|*srcy++;
+ *dstw++ = (*srcv++<<8)|*srcy++;
+ }
}
static void yuvtoyuy2row_avg_c(BYTE* dst, BYTE* srcy, BYTE* srcu, BYTE* srcv, DWORD width, DWORD pitchuv)
{
- WORD* dstw = (WORD*)dst;
- for(; width > 1; width -= 2, srcu++, srcv++)
- {
- *dstw++ = (((srcu[0] + srcu[pitchuv]) >> 1) << 8) | *srcy++;
- *dstw++ = (((srcv[0] + srcv[pitchuv]) >> 1) << 8) | *srcy++;
- }
+ WORD* dstw = (WORD*)dst;
+ for(; width > 1; width -= 2, srcu++, srcv++)
+ {
+ *dstw++ = (((srcu[0]+srcu[pitchuv])>>1)<<8)|*srcy++;
+ *dstw++ = (((srcv[0]+srcv[pitchuv])>>1)<<8)|*srcy++;
+ }
}
static void asm_blend_row_clipped_c(BYTE* dst, BYTE* src, DWORD w, DWORD srcpitch)
{
- BYTE* src2 = src + srcpitch;
- do
- {
- *dst++ = (*src++ + *src2++ + 1) >> 1;
- }
- while(w--);
+ BYTE* src2 = src + srcpitch;
+ do {*dst++ = (*src++ + *src2++ + 1) >> 1;}
+ while(w--);
}
static void asm_blend_row_c(BYTE* dst, BYTE* src, DWORD w, DWORD srcpitch)
{
- BYTE* src2 = src + srcpitch;
- BYTE* src3 = src2 + srcpitch;
- do
- {
- *dst++ = (*src++ + (*src2++ << 1) + *src3++ + 2) >> 2;
- }
- while(w--);
+ BYTE* src2 = src + srcpitch;
+ BYTE* src3 = src2 + srcpitch;
+ do {*dst++ = (*src++ + (*src2++ << 1) + *src3++ + 2) >> 2;}
+ while(w--);
}
bool BitBltFromI420ToI420(int w, int h, BYTE* dsty, BYTE* dstu, BYTE* dstv, int dstpitch, BYTE* srcy, BYTE* srcu, BYTE* srcv, int srcpitch)
{
- if((w & 1)) return(false);
+ if((w&1)) return(false);
- if(w > 0 && w == srcpitch && w == dstpitch)
- {
- memcpy_accel(dsty, srcy, h * srcpitch);
- memcpy_accel(dstu, srcu, h / 2 * srcpitch / 2);
- memcpy_accel(dstv, srcv, h / 2 * srcpitch / 2);
- }
- else
- {
- int pitch = min(abs(srcpitch), abs(dstpitch));
+ if(w > 0 && w == srcpitch && w == dstpitch)
+ {
+ memcpy_accel(dsty, srcy, h*srcpitch);
+ memcpy_accel(dstu, srcu, h/2*srcpitch/2);
+ memcpy_accel(dstv, srcv, h/2*srcpitch/2);
+ }
+ else
+ {
+ int pitch = min(abs(srcpitch), abs(dstpitch));
- for(ptrdiff_t y = 0; y < h; y++, srcy += srcpitch, dsty += dstpitch)
- memcpy_accel(dsty, srcy, pitch);
+ for(ptrdiff_t y = 0; y < h; y++, srcy += srcpitch, dsty += dstpitch)
+ memcpy_accel(dsty, srcy, pitch);
- srcpitch >>= 1;
- dstpitch >>= 1;
+ srcpitch >>= 1;
+ dstpitch >>= 1;
- pitch = min(abs(srcpitch), abs(dstpitch));
+ pitch = min(abs(srcpitch), abs(dstpitch));
- for(ptrdiff_t y = 0; y < h; y += 2, srcu += srcpitch, dstu += dstpitch)
- memcpy_accel(dstu, srcu, pitch);
+ for(ptrdiff_t y = 0; y < h; y+=2, srcu += srcpitch, dstu += dstpitch)
+ memcpy_accel(dstu, srcu, pitch);
- for(ptrdiff_t y = 0; y < h; y += 2, srcv += srcpitch, dstv += dstpitch)
- memcpy_accel(dstv, srcv, pitch);
- }
+ for(ptrdiff_t y = 0; y < h; y+=2, srcv += srcpitch, dstv += dstpitch)
+ memcpy_accel(dstv, srcv, pitch);
+ }
- return true;
+ return true;
}
bool BitBltFromYUY2ToYUY2(int w, int h, BYTE* dst, int dstpitch, BYTE* src, int srcpitch)
{
- if(w > 0 && w == srcpitch && w == dstpitch)
- {
- memcpy_accel(dst, src, h * srcpitch);
- }
- else
- {
- int pitch = min(abs(srcpitch), abs(dstpitch));
-
- for(ptrdiff_t y = 0; y < h; y++, src += srcpitch, dst += dstpitch)
- memcpy_accel(dst, src, pitch);
- }
-
- return(true);
+ if(w > 0 && w == srcpitch && w == dstpitch)
+ {
+ memcpy_accel(dst, src, h*srcpitch);
+ }
+ else
+ {
+ int pitch = min(abs(srcpitch), abs(dstpitch));
+
+ for(ptrdiff_t y = 0; y < h; y++, src += srcpitch, dst += dstpitch)
+ memcpy_accel(dst, src, pitch);
+ }
+
+ return(true);
}
extern "C" void asm_YUVtoRGB32_row(void* ARGB1, void* ARGB2, BYTE* Y1, BYTE* Y2, BYTE* U, BYTE* V, long width);
@@ -650,1260 +633,1225 @@ extern "C" void asm_YUVtoRGB16_row_ISSE(void* ARGB1, void* ARGB2, BYTE* Y1, BYTE bool BitBltFromI420ToRGB(int w, int h, BYTE* dst, int dstpitch, int dbpp, BYTE* srcy, BYTE* srcu, BYTE* srcv, int srcpitch)
{
- if(w <= 0 || h <= 0 || (w & 1) || (h & 1))
- return(false);
-
- void (*asm_YUVtoRGB_row)(void * ARGB1, void * ARGB2, BYTE * Y1, BYTE * Y2, BYTE * U, BYTE * V, long width) = NULL;;
-
- if((g_cpuid.m_flags & CCpuID::ssefpu) && !(w & 7))
- {
- switch(dbpp)
- {
- case 16:
- asm_YUVtoRGB_row = asm_YUVtoRGB16_row/*_ISSE*/;
- break; // TODO: fix _ISSE (555->565)
- case 24:
- asm_YUVtoRGB_row = asm_YUVtoRGB24_row_ISSE;
- break;
- case 32:
- asm_YUVtoRGB_row = asm_YUVtoRGB32_row_ISSE;
- break;
- }
- }
- else if((g_cpuid.m_flags & CCpuID::mmx) && !(w & 7))
- {
- switch(dbpp)
- {
- case 16:
- asm_YUVtoRGB_row = asm_YUVtoRGB16_row/*_MMX*/;
- break; // TODO: fix _MMX (555->565)
- case 24:
- asm_YUVtoRGB_row = asm_YUVtoRGB24_row_MMX;
- break;
- case 32:
- asm_YUVtoRGB_row = asm_YUVtoRGB32_row_MMX;
- break;
- }
- }
- else
- {
- switch(dbpp)
- {
- case 16:
- asm_YUVtoRGB_row = asm_YUVtoRGB16_row;
- break;
- case 24:
- asm_YUVtoRGB_row = asm_YUVtoRGB24_row;
- break;
- case 32:
- asm_YUVtoRGB_row = asm_YUVtoRGB32_row;
- break;
- }
- }
-
- if(!asm_YUVtoRGB_row)
- return(false);
-
- do
- {
- asm_YUVtoRGB_row(dst + dstpitch, dst, srcy + srcpitch, srcy, srcu, srcv, w / 2);
-
- dst += 2 * dstpitch;
- srcy += srcpitch * 2;
- srcu += srcpitch / 2;
- srcv += srcpitch / 2;
- }
- while(h -= 2);
-
- if(g_cpuid.m_flags & CCpuID::mmx)
- __asm emms
-
- if(g_cpuid.m_flags & CCpuID::ssefpu)
- __asm sfence
-
- return true;
+ if(w<=0 || h<=0 || (w&1) || (h&1))
+ return(false);
+
+ void (*asm_YUVtoRGB_row)(void* ARGB1, void* ARGB2, BYTE* Y1, BYTE* Y2, BYTE* U, BYTE* V, long width) = NULL;;
+
+ if((g_cpuid.m_flags & CCpuID::ssefpu) && !(w&7))
+ {
+ switch(dbpp)
+ {
+ case 16: asm_YUVtoRGB_row = asm_YUVtoRGB16_row/*_ISSE*/; break; // TODO: fix _ISSE (555->565)
+ case 24: asm_YUVtoRGB_row = asm_YUVtoRGB24_row_ISSE; break;
+ case 32: asm_YUVtoRGB_row = asm_YUVtoRGB32_row_ISSE; break;
+ }
+ }
+ else if((g_cpuid.m_flags & CCpuID::mmx) && !(w&7))
+ {
+ switch(dbpp)
+ {
+ case 16: asm_YUVtoRGB_row = asm_YUVtoRGB16_row/*_MMX*/; break; // TODO: fix _MMX (555->565)
+ case 24: asm_YUVtoRGB_row = asm_YUVtoRGB24_row_MMX; break;
+ case 32: asm_YUVtoRGB_row = asm_YUVtoRGB32_row_MMX; break;
+ }
+ }
+ else
+ {
+ switch(dbpp)
+ {
+ case 16: asm_YUVtoRGB_row = asm_YUVtoRGB16_row; break;
+ case 24: asm_YUVtoRGB_row = asm_YUVtoRGB24_row; break;
+ case 32: asm_YUVtoRGB_row = asm_YUVtoRGB32_row; break;
+ }
+ }
+
+ if(!asm_YUVtoRGB_row)
+ return(false);
+
+ do
+ {
+ asm_YUVtoRGB_row(dst + dstpitch, dst, srcy + srcpitch, srcy, srcu, srcv, w/2);
+
+ dst += 2*dstpitch;
+ srcy += srcpitch*2;
+ srcu += srcpitch/2;
+ srcv += srcpitch/2;
+ }
+ while(h -= 2);
+
+ if(g_cpuid.m_flags & CCpuID::mmx)
+ __asm emms
+
+ if(g_cpuid.m_flags & CCpuID::ssefpu)
+ __asm sfence
+
+ return true;
}
static void __declspec(naked) yuvtoyuy2row_MMX(BYTE* dst, BYTE* srcy, BYTE* srcu, BYTE* srcv, DWORD width)
{
- __asm
- {
- push ebp
- push edi
- push esi
- push ebx
+ __asm {
+ push ebp
+ push edi
+ push esi
+ push ebx
- mov edi, [esp+20] // dst
- mov ebp, [esp+24] // srcy
- mov ebx, [esp+28] // srcu
- mov esi, [esp+32] // srcv
- mov ecx, [esp+36] // width
+ mov edi, [esp+20] // dst
+ mov ebp, [esp+24] // srcy
+ mov ebx, [esp+28] // srcu
+ mov esi, [esp+32] // srcv
+ mov ecx, [esp+36] // width
- shr ecx, 3
+ shr ecx, 3
- yuvtoyuy2row_loop:
+yuvtoyuy2row_loop:
- movd mm0, [ebx]
- punpcklbw mm0, [esi]
+ movd mm0, [ebx]
+ punpcklbw mm0, [esi]
- movq mm1, [ebp]
- movq mm2, mm1
- punpcklbw mm1, mm0
- punpckhbw mm2, mm0
+ movq mm1, [ebp]
+ movq mm2, mm1
+ punpcklbw mm1, mm0
+ punpckhbw mm2, mm0
- movq [edi], mm1
- movq [edi+8], mm2
+ movq [edi], mm1
+ movq [edi+8], mm2
- add ebp, 8
- add ebx, 4
- add esi, 4
+ add ebp, 8
+ add ebx, 4
+ add esi, 4
add edi, 16
- dec ecx
- jnz yuvtoyuy2row_loop
+ dec ecx
+ jnz yuvtoyuy2row_loop
- pop ebx
- pop esi
- pop edi
- pop ebp
- ret
- };
+ pop ebx
+ pop esi
+ pop edi
+ pop ebp
+ ret
+ };
}
static void __declspec(naked) yuvtoyuy2row_avg_MMX(BYTE* dst, BYTE* srcy, BYTE* srcu, BYTE* srcv, DWORD width, DWORD pitchuv)
{
- static const __int64 mask = 0x7f7f7f7f7f7f7f7fi64;
+ static const __int64 mask = 0x7f7f7f7f7f7f7f7fi64;
- __asm
- {
- push ebp
- push edi
- push esi
- push ebx
+ __asm {
+ push ebp
+ push edi
+ push esi
+ push ebx
- movq mm7, mask
+ movq mm7, mask
- mov edi, [esp+20] // dst
- mov ebp, [esp+24] // srcy
- mov ebx, [esp+28] // srcu
- mov esi, [esp+32] // srcv
- mov ecx, [esp+36] // width
- mov eax, [esp+40] // pitchuv
+ mov edi, [esp+20] // dst
+ mov ebp, [esp+24] // srcy
+ mov ebx, [esp+28] // srcu
+ mov esi, [esp+32] // srcv
+ mov ecx, [esp+36] // width
+ mov eax, [esp+40] // pitchuv
- shr ecx, 3
+ shr ecx, 3
- yuvtoyuy2row_avg_loop:
+yuvtoyuy2row_avg_loop:
- movd mm0, [ebx]
- punpcklbw mm0, [esi]
- movq mm1, mm0
+ movd mm0, [ebx]
+ punpcklbw mm0, [esi]
+ movq mm1, mm0
- movd mm2, [ebx + eax]
- punpcklbw mm2, [esi + eax]
- movq mm3, mm2
+ movd mm2, [ebx + eax]
+ punpcklbw mm2, [esi + eax]
+ movq mm3, mm2
- // (x+y)>>1 == (x&y)+((x^y)>>1)
+ // (x+y)>>1 == (x&y)+((x^y)>>1)
- pand mm0, mm2
- pxor mm1, mm3
- psrlq mm1, 1
- pand mm1, mm7
- paddb mm0, mm1
+ pand mm0, mm2
+ pxor mm1, mm3
+ psrlq mm1, 1
+ pand mm1, mm7
+ paddb mm0, mm1
- movq mm1, [ebp]
- movq mm2, mm1
- punpcklbw mm1, mm0
- punpckhbw mm2, mm0
+ movq mm1, [ebp]
+ movq mm2, mm1
+ punpcklbw mm1, mm0
+ punpckhbw mm2, mm0
- movq [edi], mm1
- movq [edi+8], mm2
+ movq [edi], mm1
+ movq [edi+8], mm2
- add ebp, 8
- add ebx, 4
- add esi, 4
+ add ebp, 8
+ add ebx, 4
+ add esi, 4
add edi, 16
- dec ecx
- jnz yuvtoyuy2row_avg_loop
+ dec ecx
+ jnz yuvtoyuy2row_avg_loop
- pop ebx
- pop esi
- pop edi
- pop ebp
- ret
- };
+ pop ebx
+ pop esi
+ pop edi
+ pop ebp
+ ret
+ };
}
-static void __declspec(naked) yv12_yuy2_row_sse2()
-{
- __asm
- {
- // ebx - Y
- // edx - U
- // esi - V
- // edi - dest
- // ecx - halfwidth
- xor eax, eax
-
- one:
- movdqa xmm0, [ebx + eax*2] // YYYYYYYY
- movdqa xmm1, [ebx + eax*2 + 16] // YYYYYYYY
-
- movdqa xmm2, [edx + eax] // UUUUUUUU
- movdqa xmm3, [esi + eax] // VVVVVVVV
-
- movdqa xmm4, xmm2
- movdqa xmm5, xmm0
- movdqa xmm6, xmm1
- punpcklbw xmm2, xmm3 // VUVUVUVU
- punpckhbw xmm4, xmm3 // VUVUVUVU
-
- punpcklbw xmm0, xmm2 // VYUYVYUY
- punpcklbw xmm1, xmm4
- punpckhbw xmm5, xmm2
- punpckhbw xmm6, xmm4
-
- movntdq [edi + eax*4], xmm0
- movntdq [edi + eax*4 + 16], xmm5
- movntdq [edi + eax*4 + 32], xmm1
- movntdq [edi + eax*4 + 48], xmm6
-
- add eax, 16
- cmp eax, ecx
-
- jb one
-
- ret
- };
+static void __declspec(naked) yv12_yuy2_row_sse2() {
+ __asm {
+ // ebx - Y
+ // edx - U
+ // esi - V
+ // edi - dest
+ // ecx - halfwidth
+ xor eax, eax
+
+one:
+ movdqa xmm0, [ebx + eax*2] // YYYYYYYY
+ movdqa xmm1, [ebx + eax*2 + 16] // YYYYYYYY
+
+ movdqa xmm2, [edx + eax] // UUUUUUUU
+ movdqa xmm3, [esi + eax] // VVVVVVVV
+
+ movdqa xmm4, xmm2
+ movdqa xmm5, xmm0
+ movdqa xmm6, xmm1
+ punpcklbw xmm2, xmm3 // VUVUVUVU
+ punpckhbw xmm4, xmm3 // VUVUVUVU
+
+ punpcklbw xmm0, xmm2 // VYUYVYUY
+ punpcklbw xmm1, xmm4
+ punpckhbw xmm5, xmm2
+ punpckhbw xmm6, xmm4
+
+ movntdq [edi + eax*4], xmm0
+ movntdq [edi + eax*4 + 16], xmm5
+ movntdq [edi + eax*4 + 32], xmm1
+ movntdq [edi + eax*4 + 48], xmm6
+
+ add eax, 16
+ cmp eax, ecx
+
+ jb one
+
+ ret
+ };
}
-static void __declspec(naked) yv12_yuy2_row_sse2_linear()
-{
- __asm
- {
- // ebx - Y
- // edx - U
- // esi - V
- // edi - dest
- // ecx - width
- // ebp - uv_stride
- xor eax, eax
-
- one:
- movdqa xmm0, [ebx + eax*2] // YYYYYYYY
- movdqa xmm1, [ebx + eax*2 + 16] // YYYYYYYY
-
- movdqa xmm2, [edx]
- movdqa xmm3, [esi]
- pavgb xmm2, [edx + ebp] // UUUUUUUU
- pavgb xmm3, [esi + ebp] // VVVVVVVV
-
- movdqa xmm4, xmm2
- movdqa xmm5, xmm0
- movdqa xmm6, xmm1
- punpcklbw xmm2, xmm3 // VUVUVUVU
- punpckhbw xmm4, xmm3 // VUVUVUVU
-
- punpcklbw xmm0, xmm2 // VYUYVYUY
- punpcklbw xmm1, xmm4
- punpckhbw xmm5, xmm2
- punpckhbw xmm6, xmm4
-
- movntdq [edi + eax*4], xmm0
- movntdq [edi + eax*4 + 16], xmm5
- movntdq [edi + eax*4 + 32], xmm1
- movntdq [edi + eax*4 + 48], xmm6
-
- add eax, 16
- add edx, 16
- add esi, 16
- cmp eax, ecx
-
- jb one
-
- ret
- };
+static void __declspec(naked) yv12_yuy2_row_sse2_linear() {
+ __asm {
+ // ebx - Y
+ // edx - U
+ // esi - V
+ // edi - dest
+ // ecx - width
+ // ebp - uv_stride
+ xor eax, eax
+
+one:
+ movdqa xmm0, [ebx + eax*2] // YYYYYYYY
+ movdqa xmm1, [ebx + eax*2 + 16] // YYYYYYYY
+
+ movdqa xmm2, [edx]
+ movdqa xmm3, [esi]
+ pavgb xmm2, [edx + ebp] // UUUUUUUU
+ pavgb xmm3, [esi + ebp] // VVVVVVVV
+
+ movdqa xmm4, xmm2
+ movdqa xmm5, xmm0
+ movdqa xmm6, xmm1
+ punpcklbw xmm2, xmm3 // VUVUVUVU
+ punpckhbw xmm4, xmm3 // VUVUVUVU
+
+ punpcklbw xmm0, xmm2 // VYUYVYUY
+ punpcklbw xmm1, xmm4
+ punpckhbw xmm5, xmm2
+ punpckhbw xmm6, xmm4
+
+ movntdq [edi + eax*4], xmm0
+ movntdq [edi + eax*4 + 16], xmm5
+ movntdq [edi + eax*4 + 32], xmm1
+ movntdq [edi + eax*4 + 48], xmm6
+
+ add eax, 16
+ add edx, 16
+ add esi, 16
+ cmp eax, ecx
+
+ jb one
+
+ ret
+ };
}
-static void __declspec(naked) yv12_yuy2_row_sse2_linear_interlaced()
-{
- __asm
- {
- // ebx - Y
- // edx - U
- // esi - V
- // edi - dest
- // ecx - width
- // ebp - uv_stride
- xor eax, eax
-
- one:
- movdqa xmm0, [ebx + eax*2] // YYYYYYYY
- movdqa xmm1, [ebx + eax*2 + 16] // YYYYYYYY
-
- movdqa xmm2, [edx]
- movdqa xmm3, [esi]
- pavgb xmm2, [edx + ebp*2] // UUUUUUUU
- pavgb xmm3, [esi + ebp*2] // VVVVVVVV
-
- movdqa xmm4, xmm2
- movdqa xmm5, xmm0
- movdqa xmm6, xmm1
- punpcklbw xmm2, xmm3 // VUVUVUVU
- punpckhbw xmm4, xmm3 // VUVUVUVU
-
- punpcklbw xmm0, xmm2 // VYUYVYUY
- punpcklbw xmm1, xmm4
- punpckhbw xmm5, xmm2
- punpckhbw xmm6, xmm4
-
- movntdq [edi + eax*4], xmm0
- movntdq [edi + eax*4 + 16], xmm5
- movntdq [edi + eax*4 + 32], xmm1
- movntdq [edi + eax*4 + 48], xmm6
-
- add eax, 16
- add edx, 16
- add esi, 16
- cmp eax, ecx
-
- jb one
-
- ret
- };
+static void __declspec(naked) yv12_yuy2_row_sse2_linear_interlaced() {
+ __asm {
+ // ebx - Y
+ // edx - U
+ // esi - V
+ // edi - dest
+ // ecx - width
+ // ebp - uv_stride
+ xor eax, eax
+
+one:
+ movdqa xmm0, [ebx + eax*2] // YYYYYYYY
+ movdqa xmm1, [ebx + eax*2 + 16] // YYYYYYYY
+
+ movdqa xmm2, [edx]
+ movdqa xmm3, [esi]
+ pavgb xmm2, [edx + ebp*2] // UUUUUUUU
+ pavgb xmm3, [esi + ebp*2] // VVVVVVVV
+
+ movdqa xmm4, xmm2
+ movdqa xmm5, xmm0
+ movdqa xmm6, xmm1
+ punpcklbw xmm2, xmm3 // VUVUVUVU
+ punpckhbw xmm4, xmm3 // VUVUVUVU
+
+ punpcklbw xmm0, xmm2 // VYUYVYUY
+ punpcklbw xmm1, xmm4
+ punpckhbw xmm5, xmm2
+ punpckhbw xmm6, xmm4
+
+ movntdq [edi + eax*4], xmm0
+ movntdq [edi + eax*4 + 16], xmm5
+ movntdq [edi + eax*4 + 32], xmm1
+ movntdq [edi + eax*4 + 48], xmm6
+
+ add eax, 16
+ add edx, 16
+ add esi, 16
+ cmp eax, ecx
+
+ jb one
+
+ ret
+ };
}
void __declspec(naked) yv12_yuy2_sse2(const BYTE *Y, const BYTE *U, const BYTE *V,
- int halfstride, unsigned halfwidth, unsigned height,
- BYTE *YUY2, int d_stride)
+ int halfstride, unsigned halfwidth, unsigned height,
+ BYTE *YUY2, int d_stride)
{
- __asm
- {
- push ebx
- push esi
- push edi
- push ebp
+ __asm {
+ push ebx
+ push esi
+ push edi
+ push ebp
- mov ebx, [esp + 20] // Y
- mov edx, [esp + 24] // U
- mov esi, [esp + 28] // V
- mov edi, [esp + 44] // D
- mov ebp, [esp + 32] // uv_stride
- mov ecx, [esp + 36] // uv_width
+ mov ebx, [esp + 20] // Y
+ mov edx, [esp + 24] // U
+ mov esi, [esp + 28] // V
+ mov edi, [esp + 44] // D
+ mov ebp, [esp + 32] // uv_stride
+ mov ecx, [esp + 36] // uv_width
- mov eax, ecx
- add eax, 15
- and eax, 0xfffffff0
- sub [esp + 32], eax
+ mov eax, ecx
+ add eax, 15
+ and eax, 0xfffffff0
+ sub [esp + 32], eax
- cmp dword ptr [esp + 40], 2
- jbe last2
+ cmp dword ptr [esp + 40], 2
+ jbe last2
- row:
- sub dword ptr [esp + 40], 2
- call yv12_yuy2_row_sse2
+row:
+ sub dword ptr [esp + 40], 2
+ call yv12_yuy2_row_sse2
- lea ebx, [ebx + ebp*2]
- add edi, [esp + 48]
+ lea ebx, [ebx + ebp*2]
+ add edi, [esp + 48]
- call yv12_yuy2_row_sse2_linear
+ call yv12_yuy2_row_sse2_linear
- add edx, [esp + 32]
- add esi, [esp + 32]
+ add edx, [esp + 32]
+ add esi, [esp + 32]
- lea ebx, [ebx + ebp*2]
- add edi, [esp + 48]
+ lea ebx, [ebx + ebp*2]
+ add edi, [esp + 48]
- cmp dword ptr [esp + 40], 2
- ja row
+ cmp dword ptr [esp + 40], 2
+ ja row
- last2:
- call yv12_yuy2_row_sse2
+last2:
+ call yv12_yuy2_row_sse2
- dec dword ptr [esp + 40]
- jz done
+ dec dword ptr [esp + 40]
+ jz done
- lea ebx, [ebx + ebp*2]
- add edi, [esp + 48]
- call yv12_yuy2_row_sse2
- done:
+ lea ebx, [ebx + ebp*2]
+ add edi, [esp + 48]
+ call yv12_yuy2_row_sse2
+done:
- pop ebp
- pop edi
- pop esi
- pop ebx
+ pop ebp
+ pop edi
+ pop esi
+ pop ebx
- ret
- };
+ ret
+ };
}
void __declspec(naked) yv12_yuy2_sse2_interlaced(const BYTE *Y, const BYTE *U, const BYTE *V,
- int halfstride, unsigned halfwidth, unsigned height,
- BYTE *YUY2, int d_stride)
+ int halfstride, unsigned halfwidth, unsigned height,
+ BYTE *YUY2, int d_stride)
{
- __asm
- {
- push ebx
- push esi
- push edi
- push ebp
+ __asm {
+ push ebx
+ push esi
+ push edi
+ push ebp
- mov ebx, [esp + 20] // Y
- mov edx, [esp + 24] // U
- mov esi, [esp + 28] // V
- mov edi, [esp + 44] // D
- mov ebp, [esp + 32] // uv_stride
- mov ecx, [esp + 36] // uv_width
+ mov ebx, [esp + 20] // Y
+ mov edx, [esp + 24] // U
+ mov esi, [esp + 28] // V
+ mov edi, [esp + 44] // D
+ mov ebp, [esp + 32] // uv_stride
+ mov ecx, [esp + 36] // uv_width
- mov eax, ecx
- add eax, 15
- and eax, 0xfffffff0
- sub [esp + 32], eax
+ mov eax, ecx
+ add eax, 15
+ and eax, 0xfffffff0
+ sub [esp + 32], eax
- cmp dword ptr [esp + 40], 4
- jbe last4
+ cmp dword ptr [esp + 40], 4
+ jbe last4
- row:
- sub dword ptr [esp + 40], 4
- call yv12_yuy2_row_sse2 // first row, first field
+row:
+ sub dword ptr [esp + 40], 4
+ call yv12_yuy2_row_sse2 // first row, first field
- lea ebx, [ebx + ebp*2]
- add edi, [esp + 48]
+ lea ebx, [ebx + ebp*2]
+ add edi, [esp + 48]
- add edx, ebp
- add esi, ebp
+ add edx, ebp
+ add esi, ebp
- call yv12_yuy2_row_sse2 // first row, second field
+ call yv12_yuy2_row_sse2 // first row, second field
- lea ebx, [ebx + ebp*2]
- add edi, [esp + 48]
+ lea ebx, [ebx + ebp*2]
+ add edi, [esp + 48]
- sub edx, ebp
- sub esi, ebp
+ sub edx, ebp
+ sub esi, ebp
- call yv12_yuy2_row_sse2_linear_interlaced // second row, first field
+ call yv12_yuy2_row_sse2_linear_interlaced // second row, first field
- add edx, [esp + 32]
- add esi, [esp + 32]
+ add edx, [esp + 32]
+ add esi, [esp + 32]
- lea ebx, [ebx + ebp*2]
- add edi, [esp + 48]
+ lea ebx, [ebx + ebp*2]
+ add edi, [esp + 48]
- call yv12_yuy2_row_sse2_linear_interlaced // second row, second field
+ call yv12_yuy2_row_sse2_linear_interlaced // second row, second field
- add edx, [esp + 32]
- add esi, [esp + 32]
+ add edx, [esp + 32]
+ add esi, [esp + 32]
- lea ebx, [ebx + ebp*2]
- add edi, [esp + 48]
+ lea ebx, [ebx + ebp*2]
+ add edi, [esp + 48]
- cmp dword ptr [esp + 40], 4
- ja row
+ cmp dword ptr [esp + 40], 4
+ ja row
- last4:
- call yv12_yuy2_row_sse2
+last4:
+ call yv12_yuy2_row_sse2
- lea ebx, [ebx + ebp*2]
- add edi, [esp + 48]
+ lea ebx, [ebx + ebp*2]
+ add edi, [esp + 48]
- add edx, ebp
- add esi, ebp
+ add edx, ebp
+ add esi, ebp
- call yv12_yuy2_row_sse2
+ call yv12_yuy2_row_sse2
- lea ebx, [ebx + ebp*2]
- add edi, [esp + 48]
+ lea ebx, [ebx + ebp*2]
+ add edi, [esp + 48]
- sub edx, ebp
- sub esi, ebp
+ sub edx, ebp
+ sub esi, ebp
- call yv12_yuy2_row_sse2
+ call yv12_yuy2_row_sse2
- lea ebx, [ebx + ebp*2]
- add edi, [esp + 48]
+ lea ebx, [ebx + ebp*2]
+ add edi, [esp + 48]
- add edx, ebp
- add esi, ebp
+ add edx, ebp
+ add esi, ebp
- call yv12_yuy2_row_sse2
+ call yv12_yuy2_row_sse2
- pop ebp
- pop edi
- pop esi
- pop ebx
+ pop ebp
+ pop edi
+ pop esi
+ pop ebx
- ret
- };
+ ret
+ };
}
bool BitBltFromI420ToYUY2(int w, int h, BYTE* dst, int dstpitch, BYTE* srcy, BYTE* srcu, BYTE* srcv, int srcpitch, bool fInterlaced)
{
- if(w <= 0 || h <= 0 || (w & 1) || (h & 1))
- return(false);
-
- if(srcpitch == 0) srcpitch = w;
-
- if((g_cpuid.m_flags & CCpuID::sse2)
- && !((DWORD_PTR)srcy & 15) && !((DWORD_PTR)srcu & 15) && !((DWORD_PTR)srcv & 15) && !(srcpitch & 31)
- && !((DWORD_PTR)dst & 15) && !(dstpitch & 15))
- {
- if(!fInterlaced) yv12_yuy2_sse2(srcy, srcu, srcv, srcpitch / 2, w / 2, h, dst, dstpitch);
- else yv12_yuy2_sse2_interlaced(srcy, srcu, srcv, srcpitch / 2, w / 2, h, dst, dstpitch);
- return true;
- }
- else
- {
- ASSERT(!fInterlaced);
- }
-
- void (*yuvtoyuy2row)(BYTE * dst, BYTE * srcy, BYTE * srcu, BYTE * srcv, DWORD width) = NULL;
- void (*yuvtoyuy2row_avg)(BYTE * dst, BYTE * srcy, BYTE * srcu, BYTE * srcv, DWORD width, DWORD pitchuv) = NULL;
-
- if((g_cpuid.m_flags & CCpuID::mmx) && !(w & 7))
- {
- yuvtoyuy2row = yuvtoyuy2row_MMX;
- yuvtoyuy2row_avg = yuvtoyuy2row_avg_MMX;
- }
- else
- {
- yuvtoyuy2row = yuvtoyuy2row_c;
- yuvtoyuy2row_avg = yuvtoyuy2row_avg_c;
- }
-
- if(!yuvtoyuy2row)
- return(false);
-
- do
- {
- yuvtoyuy2row(dst, srcy, srcu, srcv, w);
- yuvtoyuy2row_avg(dst + dstpitch, srcy + srcpitch, srcu, srcv, w, srcpitch / 2);
-
- dst += 2 * dstpitch;
- srcy += srcpitch * 2;
- srcu += srcpitch / 2;
- srcv += srcpitch / 2;
- }
- while((h -= 2) > 2);
-
- yuvtoyuy2row(dst, srcy, srcu, srcv, w);
- yuvtoyuy2row(dst + dstpitch, srcy + srcpitch, srcu, srcv, w);
-
- if(g_cpuid.m_flags & CCpuID::mmx)
- __asm emms
-
- return(true);
+ if(w<=0 || h<=0 || (w&1) || (h&1))
+ return(false);
+
+ if(srcpitch == 0) srcpitch = w;
+
+ if((g_cpuid.m_flags & CCpuID::sse2)
+ && !((DWORD_PTR)srcy&15) && !((DWORD_PTR)srcu&15) && !((DWORD_PTR)srcv&15) && !(srcpitch&31)
+ && !((DWORD_PTR)dst&15) && !(dstpitch&15))
+ {
+ if(!fInterlaced) yv12_yuy2_sse2(srcy, srcu, srcv, srcpitch/2, w/2, h, dst, dstpitch);
+ else yv12_yuy2_sse2_interlaced(srcy, srcu, srcv, srcpitch/2, w/2, h, dst, dstpitch);
+ return true;
+ }
+ else
+ {
+ ASSERT(!fInterlaced);
+ }
+
+ void (*yuvtoyuy2row)(BYTE* dst, BYTE* srcy, BYTE* srcu, BYTE* srcv, DWORD width) = NULL;
+ void (*yuvtoyuy2row_avg)(BYTE* dst, BYTE* srcy, BYTE* srcu, BYTE* srcv, DWORD width, DWORD pitchuv) = NULL;
+
+ if((g_cpuid.m_flags & CCpuID::mmx) && !(w&7))
+ {
+ yuvtoyuy2row = yuvtoyuy2row_MMX;
+ yuvtoyuy2row_avg = yuvtoyuy2row_avg_MMX;
+ }
+ else
+ {
+ yuvtoyuy2row = yuvtoyuy2row_c;
+ yuvtoyuy2row_avg = yuvtoyuy2row_avg_c;
+ }
+
+ if(!yuvtoyuy2row)
+ return(false);
+
+ do
+ {
+ yuvtoyuy2row(dst, srcy, srcu, srcv, w);
+ yuvtoyuy2row_avg(dst + dstpitch, srcy + srcpitch, srcu, srcv, w, srcpitch/2);
+
+ dst += 2*dstpitch;
+ srcy += srcpitch*2;
+ srcu += srcpitch/2;
+ srcv += srcpitch/2;
+ }
+ while((h -= 2) > 2);
+
+ yuvtoyuy2row(dst, srcy, srcu, srcv, w);
+ yuvtoyuy2row(dst + dstpitch, srcy + srcpitch, srcu, srcv, w);
+
+ if(g_cpuid.m_flags & CCpuID::mmx)
+ __asm emms
+
+ return(true);
}
bool BitBltFromRGBToRGB(int w, int h, BYTE* dst, int dstpitch, int dbpp, BYTE* src, int srcpitch, int sbpp)
{
- if(dbpp == sbpp)
- {
- int rowbytes = w * dbpp >> 3;
-
- if(rowbytes > 0 && rowbytes == srcpitch && rowbytes == dstpitch)
- {
- memcpy_accel(dst, src, h * rowbytes);
- }
- else
- {
- for(ptrdiff_t y = 0; y < h; y++, src += srcpitch, dst += dstpitch)
- memcpy_accel(dst, src, rowbytes);
- }
-
- return(true);
- }
-
- if(sbpp != 16 && sbpp != 24 && sbpp != 32
- || dbpp != 16 && dbpp != 24 && dbpp != 32)
- return(false);
-
- if(dbpp == 16)
- {
- for(ptrdiff_t y = 0; y < h; y++, src += srcpitch, dst += dstpitch)
- {
- if(sbpp == 24)
- {
- BYTE* s = (BYTE*)src;
- WORD* d = (WORD*)dst;
- for(ptrdiff_t x = 0; x < w; x++, s += 3, d++)
- * d = (WORD)(((*((DWORD*)s) >> 8) & 0xf800) | ((*((DWORD*)s) >> 5) & 0x07e0) | ((*((DWORD*)s) >> 3) & 0x1f));
- }
- else if(sbpp == 32)
- {
- DWORD* s = (DWORD*)src;
- WORD* d = (WORD*)dst;
- for(ptrdiff_t x = 0; x < w; x++, s++, d++)
- *d = (WORD)(((*s >> 8) & 0xf800) | ((*s >> 5) & 0x07e0) | ((*s >> 3) & 0x1f));
- }
- }
- }
- else if(dbpp == 24)
- {
- for(ptrdiff_t y = 0; y < h; y++, src += srcpitch, dst += dstpitch)
- {
- if(sbpp == 16)
- {
- WORD* s = (WORD*)src;
- BYTE* d = (BYTE*)dst;
- for(ptrdiff_t x = 0; x < w; x++, s++, d += 3)
- {
- // not tested, r-g-b might be in reverse
- d[0] = (*s & 0x001f) << 3;
- d[1] = (*s & 0x07e0) << 5;
- d[2] = (*s & 0xf800) << 8;
- }
- }
- else if(sbpp == 32)
- {
- BYTE* s = (BYTE*)src;
- BYTE* d = (BYTE*)dst;
- for(ptrdiff_t x = 0; x < w; x++, s += 4, d += 3)
- {
- d[0] = s[0];
- d[1] = s[1];
- d[2] = s[2];
- }
- }
- }
- }
- else if(dbpp == 32)
- {
- for(ptrdiff_t y = 0; y < h; y++, src += srcpitch, dst += dstpitch)
- {
- if(sbpp == 16)
- {
- WORD* s = (WORD*)src;
- DWORD* d = (DWORD*)dst;
- for(ptrdiff_t x = 0; x < w; x++, s++, d++)
- *d = ((*s & 0xf800) << 8) | ((*s & 0x07e0) << 5) | ((*s & 0x001f) << 3);
- }
- else if(sbpp == 24)
- {
- BYTE* s = (BYTE*)src;
- DWORD* d = (DWORD*)dst;
- for(ptrdiff_t x = 0; x < w; x++, s += 3, d++)
- * d = *((DWORD*)s) & 0xffffff;
- }
- }
- }
-
- return(true);
+ if(dbpp == sbpp)
+ {
+ int rowbytes = w*dbpp>>3;
+
+ if(rowbytes > 0 && rowbytes == srcpitch && rowbytes == dstpitch)
+ {
+ memcpy_accel(dst, src, h*rowbytes);
+ }
+ else
+ {
+ for(ptrdiff_t y = 0; y < h; y++, src += srcpitch, dst += dstpitch)
+ memcpy_accel(dst, src, rowbytes);
+ }
+
+ return(true);
+ }
+
+ if(sbpp != 16 && sbpp != 24 && sbpp != 32
+ || dbpp != 16 && dbpp != 24 && dbpp != 32)
+ return(false);
+
+ if(dbpp == 16)
+ {
+ for(ptrdiff_t y = 0; y < h; y++, src += srcpitch, dst += dstpitch)
+ {
+ if(sbpp == 24)
+ {
+ BYTE* s = (BYTE*)src;
+ WORD* d = (WORD*)dst;
+ for(ptrdiff_t x = 0; x < w; x++, s+=3, d++)
+ *d = (WORD)(((*((DWORD*)s)>>8)&0xf800)|((*((DWORD*)s)>>5)&0x07e0)|((*((DWORD*)s)>>3)&0x1f));
+ }
+ else if(sbpp == 32)
+ {
+ DWORD* s = (DWORD*)src;
+ WORD* d = (WORD*)dst;
+ for(ptrdiff_t x = 0; x < w; x++, s++, d++)
+ *d = (WORD)(((*s>>8)&0xf800)|((*s>>5)&0x07e0)|((*s>>3)&0x1f));
+ }
+ }
+ }
+ else if(dbpp == 24)
+ {
+ for(ptrdiff_t y = 0; y < h; y++, src += srcpitch, dst += dstpitch)
+ {
+ if(sbpp == 16)
+ {
+ WORD* s = (WORD*)src;
+ BYTE* d = (BYTE*)dst;
+ for(ptrdiff_t x = 0; x < w; x++, s++, d+=3)
+ { // not tested, r-g-b might be in reverse
+ d[0] = (*s&0x001f)<<3;
+ d[1] = (*s&0x07e0)<<5;
+ d[2] = (*s&0xf800)<<8;
+ }
+ }
+ else if(sbpp == 32)
+ {
+ BYTE* s = (BYTE*)src;
+ BYTE* d = (BYTE*)dst;
+ for(ptrdiff_t x = 0; x < w; x++, s+=4, d+=3)
+ {d[0] = s[0]; d[1] = s[1]; d[2] = s[2];}
+ }
+ }
+ }
+ else if(dbpp == 32)
+ {
+ for(ptrdiff_t y = 0; y < h; y++, src += srcpitch, dst += dstpitch)
+ {
+ if(sbpp == 16)
+ {
+ WORD* s = (WORD*)src;
+ DWORD* d = (DWORD*)dst;
+ for(ptrdiff_t x = 0; x < w; x++, s++, d++)
+ *d = ((*s&0xf800)<<8)|((*s&0x07e0)<<5)|((*s&0x001f)<<3);
+ }
+ else if(sbpp == 24)
+ {
+ BYTE* s = (BYTE*)src;
+ DWORD* d = (DWORD*)dst;
+ for(ptrdiff_t x = 0; x < w; x++, s+=3, d++)
+ *d = *((DWORD*)s)&0xffffff;
+ }
+ }
+ }
+
+ return(true);
}
static void __declspec(naked) asm_blend_row_clipped_MMX(BYTE* dst, BYTE* src, DWORD w, DWORD srcpitch)
{
- static const __int64 _x0001000100010001 = 0x0001000100010001;
-
- __asm
- {
- push ebp
- push edi
- push esi
- push ebx
-
- mov edi, [esp+20]
- mov esi, [esp+24]
- sub edi, esi
- mov ebp, [esp+28]
- mov edx, [esp+32]
-
- shr ebp, 3
-
- movq mm6, _x0001000100010001
- pxor mm7, mm7
-
- xloop:
- movq mm0, [esi]
- movq mm3, mm0
- punpcklbw mm0, mm7
- punpckhbw mm3, mm7
-
- movq mm1, [esi+edx]
- movq mm4, mm1
- punpcklbw mm1, mm7
- punpckhbw mm4, mm7
-
- paddw mm1, mm0
- paddw mm1, mm6
- psrlw mm1, 1
-
- paddw mm4, mm3
- paddw mm4, mm6
- psrlw mm4, 1
-
- add esi, 8
- packuswb mm1, mm4
- movq [edi+esi-8], mm1
-
- dec ebp
- jne xloop
-
- pop ebx
- pop esi
- pop edi
- pop ebp
- ret
- };
+ static const __int64 _x0001000100010001 = 0x0001000100010001;
+
+ __asm {
+ push ebp
+ push edi
+ push esi
+ push ebx
+
+ mov edi,[esp+20]
+ mov esi,[esp+24]
+ sub edi,esi
+ mov ebp,[esp+28]
+ mov edx,[esp+32]
+
+ shr ebp, 3
+
+ movq mm6, _x0001000100010001
+ pxor mm7, mm7
+
+xloop:
+ movq mm0, [esi]
+ movq mm3, mm0
+ punpcklbw mm0, mm7
+ punpckhbw mm3, mm7
+
+ movq mm1, [esi+edx]
+ movq mm4, mm1
+ punpcklbw mm1, mm7
+ punpckhbw mm4, mm7
+
+ paddw mm1, mm0
+ paddw mm1, mm6
+ psrlw mm1, 1
+
+ paddw mm4, mm3
+ paddw mm4, mm6
+ psrlw mm4, 1
+
+ add esi, 8
+ packuswb mm1, mm4
+ movq [edi+esi-8], mm1
+
+ dec ebp
+ jne xloop
+
+ pop ebx
+ pop esi
+ pop edi
+ pop ebp
+ ret
+ };
}
static void __declspec(naked) asm_blend_row_MMX(BYTE* dst, BYTE* src, DWORD w, DWORD srcpitch)
{
- static const __int64 mask0 = 0xfcfcfcfcfcfcfcfci64;
- static const __int64 mask1 = 0x7f7f7f7f7f7f7f7fi64;
- static const __int64 mask2 = 0x3f3f3f3f3f3f3f3fi64;
- static const __int64 _x0002000200020002 = 0x0002000200020002;
-
- __asm
- {
- push ebp
- push edi
- push esi
- push ebx
-
- mov edi, [esp+20]
- mov esi, [esp+24]
- sub edi, esi
- mov ebp, [esp+28]
- mov edx, [esp+32]
-
- shr ebp, 3
-
- movq mm6, _x0002000200020002
- pxor mm7, mm7
-
- xloop:
- movq mm0, [esi]
- movq mm3, mm0
- punpcklbw mm0, mm7
- punpckhbw mm3, mm7
-
- movq mm1, [esi+edx]
- movq mm4, mm1
- punpcklbw mm1, mm7
- punpckhbw mm4, mm7
-
- movq mm2, [esi+edx*2]
- movq mm5, mm2
- punpcklbw mm2, mm7
- punpckhbw mm5, mm7
-
- psllw mm1, 1
- paddw mm1, mm0
- paddw mm1, mm2
- paddw mm1, mm6
- psrlw mm1, 2
-
- psllw mm4, 1
- paddw mm4, mm3
- paddw mm4, mm5
- paddw mm4, mm6
- psrlw mm4, 2
-
- add esi, 8
- packuswb mm1, mm4
- movq [edi+esi-8], mm1
-
- dec ebp
- jne xloop
-
- // sadly the original code makes a lot of visible banding artifacts on yuv
- // (it seems those shiftings without rounding introduce too much error)
- /*
- mov edi,[esp+20]
- mov esi,[esp+24]
- sub edi,esi
- mov ebp,[esp+28]
- mov edx,[esp+32]
-
- movq mm5,mask0
- movq mm6,mask1
- movq mm7,mask2
- shr ebp,1
- jz oddpart
-
- xloop:
- movq mm2,[esi]
- movq mm0,mm5
-
- movq mm1,[esi+edx]
- pand mm0,mm2
-
- psrlq mm1,1
- movq mm2,[esi+edx*2]
-
- psrlq mm2,2
- pand mm1,mm6
-
- psrlq mm0,2
- pand mm2,mm7
-
- paddb mm0,mm1
- add esi,8
-
- paddb mm0,mm2
- dec ebp
-
- movq [edi+esi-8],mm0
- jne xloop
-
- oddpart:
- test byte ptr [esp+28],1
- jz nooddpart
-
- mov ecx,[esi]
- mov eax,0fcfcfcfch
- mov ebx,[esi+edx]
- and eax,ecx
- shr ebx,1
- mov ecx,[esi+edx*2]
- shr ecx,2
- and ebx,07f7f7f7fh
- shr eax,2
- and ecx,03f3f3f3fh
- add eax,ebx
- add eax,ecx
- mov [edi+esi],eax
-
- nooddpart:
- */
- pop ebx
- pop esi
- pop edi
- pop ebp
- ret
- };
+ static const __int64 mask0 = 0xfcfcfcfcfcfcfcfci64;
+ static const __int64 mask1 = 0x7f7f7f7f7f7f7f7fi64;
+ static const __int64 mask2 = 0x3f3f3f3f3f3f3f3fi64;
+ static const __int64 _x0002000200020002 = 0x0002000200020002;
+
+ __asm {
+ push ebp
+ push edi
+ push esi
+ push ebx
+
+ mov edi, [esp+20]
+ mov esi, [esp+24]
+ sub edi, esi
+ mov ebp, [esp+28]
+ mov edx, [esp+32]
+
+ shr ebp, 3
+
+ movq mm6, _x0002000200020002
+ pxor mm7, mm7
+
+xloop:
+ movq mm0, [esi]
+ movq mm3, mm0
+ punpcklbw mm0, mm7
+ punpckhbw mm3, mm7
+
+ movq mm1, [esi+edx]
+ movq mm4, mm1
+ punpcklbw mm1, mm7
+ punpckhbw mm4, mm7
+
+ movq mm2, [esi+edx*2]
+ movq mm5, mm2
+ punpcklbw mm2, mm7
+ punpckhbw mm5, mm7
+
+ psllw mm1, 1
+ paddw mm1, mm0
+ paddw mm1, mm2
+ paddw mm1, mm6
+ psrlw mm1, 2
+
+ psllw mm4, 1
+ paddw mm4, mm3
+ paddw mm4, mm5
+ paddw mm4, mm6
+ psrlw mm4, 2
+
+ add esi, 8
+ packuswb mm1, mm4
+ movq [edi+esi-8], mm1
+
+ dec ebp
+ jne xloop
+
+ // sadly the original code makes a lot of visible banding artifacts on yuv
+ // (it seems those shiftings without rounding introduce too much error)
+/*
+ mov edi,[esp+20]
+ mov esi,[esp+24]
+ sub edi,esi
+ mov ebp,[esp+28]
+ mov edx,[esp+32]
+
+ movq mm5,mask0
+ movq mm6,mask1
+ movq mm7,mask2
+ shr ebp,1
+ jz oddpart
+
+xloop:
+ movq mm2,[esi]
+ movq mm0,mm5
+
+ movq mm1,[esi+edx]
+ pand mm0,mm2
+
+ psrlq mm1,1
+ movq mm2,[esi+edx*2]
+
+ psrlq mm2,2
+ pand mm1,mm6
+
+ psrlq mm0,2
+ pand mm2,mm7
+
+ paddb mm0,mm1
+ add esi,8
+
+ paddb mm0,mm2
+ dec ebp
+
+ movq [edi+esi-8],mm0
+ jne xloop
+
+oddpart:
+ test byte ptr [esp+28],1
+ jz nooddpart
+
+ mov ecx,[esi]
+ mov eax,0fcfcfcfch
+ mov ebx,[esi+edx]
+ and eax,ecx
+ shr ebx,1
+ mov ecx,[esi+edx*2]
+ shr ecx,2
+ and ebx,07f7f7f7fh
+ shr eax,2
+ and ecx,03f3f3f3fh
+ add eax,ebx
+ add eax,ecx
+ mov [edi+esi],eax
+
+nooddpart:
+*/
+ pop ebx
+ pop esi
+ pop edi
+ pop ebp
+ ret
+ };
}
-__declspec(align(16)) static BYTE const_1_16_bytes[] = {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1};
+__declspec(align(16)) static BYTE const_1_16_bytes[] = {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1};
static void asm_blend_row_SSE2(BYTE* dst, BYTE* src, DWORD w, DWORD srcpitch)
{
- __asm
- {
- mov edx, srcpitch
- mov esi, src
- mov edi, dst
- sub edi, esi
- mov ecx, w
- mov ebx, ecx
- shr ecx, 4
- and ebx, 15
-
- movdqa xmm7, [const_1_16_bytes]
-
- asm_blend_row_SSE2_loop:
- movdqa xmm0, [esi]
- movdqa xmm1, [esi+edx]
- movdqa xmm2, [esi+edx*2]
- pavgb xmm0, xmm1
- pavgb xmm2, xmm1
- psubusb xmm0, xmm7
- pavgb xmm0, xmm2
- movdqa [esi+edi], xmm0
- add esi, 16
- dec ecx
- jnz asm_blend_row_SSE2_loop
-
- test ebx, 15
- jz asm_blend_row_SSE2_end
-
- mov ecx, ebx
- xor ax, ax
- xor bx, bx
- xor dx, dx
- asm_blend_row_SSE2_loop2:
- mov al, [esi]
- mov bl, [esi+edx]
- mov dl, [esi+edx*2]
- add ax, bx
- inc ax
- shr ax, 1
- add dx, bx
- inc dx
- shr dx, 1
- add ax, dx
- shr ax, 1
- mov [esi+edi], al
- inc esi
- dec ecx
- jnz asm_blend_row_SSE2_loop2
-
- asm_blend_row_SSE2_end:
- }
+ __asm
+ {
+ mov edx, srcpitch
+ mov esi, src
+ mov edi, dst
+ sub edi, esi
+ mov ecx, w
+ mov ebx, ecx
+ shr ecx, 4
+ and ebx, 15
+
+ movdqa xmm7, [const_1_16_bytes]
+
+asm_blend_row_SSE2_loop:
+ movdqa xmm0, [esi]
+ movdqa xmm1, [esi+edx]
+ movdqa xmm2, [esi+edx*2]
+ pavgb xmm0, xmm1
+ pavgb xmm2, xmm1
+ psubusb xmm0, xmm7
+ pavgb xmm0, xmm2
+ movdqa [esi+edi], xmm0
+ add esi, 16
+ dec ecx
+ jnz asm_blend_row_SSE2_loop
+
+ test ebx,15
+ jz asm_blend_row_SSE2_end
+
+ mov ecx, ebx
+ xor ax, ax
+ xor bx, bx
+ xor dx, dx
+asm_blend_row_SSE2_loop2:
+ mov al, [esi]
+ mov bl, [esi+edx]
+ mov dl, [esi+edx*2]
+ add ax, bx
+ inc ax
+ shr ax, 1
+ add dx, bx
+ inc dx
+ shr dx, 1
+ add ax, dx
+ shr ax, 1
+ mov [esi+edi], al
+ inc esi
+ dec ecx
+ jnz asm_blend_row_SSE2_loop2
+
+asm_blend_row_SSE2_end:
+ }
}
static void asm_blend_row_clipped_SSE2(BYTE* dst, BYTE* src, DWORD w, DWORD srcpitch)
{
- __asm
- {
- mov edx, srcpitch
- mov esi, src
- mov edi, dst
- sub edi, esi
- mov ecx, w
- mov ebx, ecx
- shr ecx, 4
- and ebx, 15
-
- movdqa xmm7, [const_1_16_bytes]
-
- asm_blend_row_clipped_SSE2_loop:
- movdqa xmm0, [esi]
- movdqa xmm1, [esi+edx]
- pavgb xmm0, xmm1
- movdqa [esi+edi], xmm0
- add esi, 16
- dec ecx
- jnz asm_blend_row_clipped_SSE2_loop
-
- test ebx, 15
- jz asm_blend_row_clipped_SSE2_end
-
- mov ecx, ebx
- xor ax, ax
- xor bx, bx
- asm_blend_row_clipped_SSE2_loop2:
- mov al, [esi]
- mov bl, [esi+edx]
- add ax, bx
- inc ax
- shr ax, 1
- mov [esi+edi], al
- inc esi
- dec ecx
- jnz asm_blend_row_clipped_SSE2_loop2
-
- asm_blend_row_clipped_SSE2_end:
- }
+ __asm
+ {
+ mov edx, srcpitch
+ mov esi, src
+ mov edi, dst
+ sub edi, esi
+ mov ecx, w
+ mov ebx, ecx
+ shr ecx, 4
+ and ebx, 15
+
+ movdqa xmm7, [const_1_16_bytes]
+
+asm_blend_row_clipped_SSE2_loop:
+ movdqa xmm0, [esi]
+ movdqa xmm1, [esi+edx]
+ pavgb xmm0, xmm1
+ movdqa [esi+edi], xmm0
+ add esi, 16
+ dec ecx
+ jnz asm_blend_row_clipped_SSE2_loop
+
+ test ebx,15
+ jz asm_blend_row_clipped_SSE2_end
+
+ mov ecx, ebx
+ xor ax, ax
+ xor bx, bx
+asm_blend_row_clipped_SSE2_loop2:
+ mov al, [esi]
+ mov bl, [esi+edx]
+ add ax, bx
+ inc ax
+ shr ax, 1
+ mov [esi+edi], al
+ inc esi
+ dec ecx
+ jnz asm_blend_row_clipped_SSE2_loop2
+
+asm_blend_row_clipped_SSE2_end:
+ }
}
void DeinterlaceBlend(BYTE* dst, BYTE* src, DWORD rowbytes, DWORD h, DWORD dstpitch, DWORD srcpitch)
{
- void (*asm_blend_row_clipped)(BYTE * dst, BYTE * src, DWORD w, DWORD srcpitch) = NULL;
- void (*asm_blend_row)(BYTE * dst, BYTE * src, DWORD w, DWORD srcpitch) = NULL;
-
- if((g_cpuid.m_flags & CCpuID::sse2) && !((DWORD)src & 0xf) && !((DWORD)dst & 0xf) && !(srcpitch & 0xf))
- {
- asm_blend_row_clipped = asm_blend_row_clipped_SSE2;
- asm_blend_row = asm_blend_row_SSE2;
- }
- else if(g_cpuid.m_flags & CCpuID::mmx)
- {
- asm_blend_row_clipped = asm_blend_row_clipped_MMX;
- asm_blend_row = asm_blend_row_MMX;
- }
- else
- {
- asm_blend_row_clipped = asm_blend_row_clipped_c;
- asm_blend_row = asm_blend_row_c;
- }
-
- if(!asm_blend_row_clipped)
- return;
-
- asm_blend_row_clipped(dst, src, rowbytes, srcpitch);
-
- if((h -= 2) > 0) do
- {
- dst += dstpitch;
- asm_blend_row(dst, src, rowbytes, srcpitch);
- src += srcpitch;
- }
- while(--h);
-
- asm_blend_row_clipped(dst + dstpitch, src, rowbytes, srcpitch);
-
- if(g_cpuid.m_flags & CCpuID::mmx)
- __asm emms
- }
+ void (*asm_blend_row_clipped)(BYTE* dst, BYTE* src, DWORD w, DWORD srcpitch) = NULL;
+ void (*asm_blend_row)(BYTE* dst, BYTE* src, DWORD w, DWORD srcpitch) = NULL;
+
+ if((g_cpuid.m_flags & CCpuID::sse2) && !((DWORD)src&0xf) && !((DWORD)dst&0xf) && !(srcpitch&0xf))
+ {
+ asm_blend_row_clipped = asm_blend_row_clipped_SSE2;
+ asm_blend_row = asm_blend_row_SSE2;
+ }
+ else if(g_cpuid.m_flags & CCpuID::mmx)
+ {
+ asm_blend_row_clipped = asm_blend_row_clipped_MMX;
+ asm_blend_row = asm_blend_row_MMX;
+ }
+ else
+ {
+ asm_blend_row_clipped = asm_blend_row_clipped_c;
+ asm_blend_row = asm_blend_row_c;
+ }
+
+ if(!asm_blend_row_clipped)
+ return;
+
+ asm_blend_row_clipped(dst, src, rowbytes, srcpitch);
+
+ if((h -= 2) > 0) do
+ {
+ dst += dstpitch;
+ asm_blend_row(dst, src, rowbytes, srcpitch);
+ src += srcpitch;
+ }
+ while(--h);
+
+ asm_blend_row_clipped(dst + dstpitch, src, rowbytes, srcpitch);
+
+ if(g_cpuid.m_flags & CCpuID::mmx)
+ __asm emms
+}
void DeinterlaceBob(BYTE* dst, BYTE* src, DWORD rowbytes, DWORD h, DWORD dstpitch, DWORD srcpitch, bool topfield)
{
- if(topfield)
- {
- BitBltFromRGBToRGB(rowbytes, h / 2, dst, dstpitch * 2, 8, src, srcpitch * 2, 8);
- AvgLines8(dst, h, dstpitch);
- }
- else
- {
- BitBltFromRGBToRGB(rowbytes, h / 2, dst + dstpitch, dstpitch * 2, 8, src + srcpitch, srcpitch * 2, 8);
- AvgLines8(dst + dstpitch, h - 1, dstpitch);
- }
+ if(topfield)
+ {
+ BitBltFromRGBToRGB(rowbytes, h/2, dst, dstpitch*2, 8, src, srcpitch*2, 8);
+ AvgLines8(dst, h, dstpitch);
+ }
+ else
+ {
+ BitBltFromRGBToRGB(rowbytes, h/2, dst + dstpitch, dstpitch*2, 8, src + srcpitch, srcpitch*2, 8);
+ AvgLines8(dst + dstpitch, h-1, dstpitch);
+ }
}
void AvgLines8(BYTE* dst, DWORD h, DWORD pitch)
{
- if(h <= 1) return;
-
- BYTE* s = dst;
- BYTE* d = dst + (h - 2) * pitch;
-
- for(; s < d; s += pitch * 2)
- {
- BYTE* tmp = s;
-
- 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:
- movdqa xmm0, [esi]
- pavgb xmm0, [esi+ebx*2]
- movdqa [esi+ebx], xmm0
- add esi, 16
-
- dec ecx
- jnz AvgLines8_sse2_loop
-
- mov tmp, esi
- }
-
- 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
- {
- mov esi, tmp
- mov ebx, pitch
-
- mov ecx, ebx
- shr ecx, 3
-
- pxor mm7, mm7
- AvgLines8_mmx_loop:
- movq mm0, [esi]
- movq mm1, mm0
-
- punpcklbw mm0, mm7
- punpckhbw mm1, mm7
-
- movq mm2, [esi+ebx*2]
- movq mm3, mm2
-
- punpcklbw mm2, mm7
- punpckhbw mm3, mm7
-
- paddw mm0, mm2
- psrlw mm0, 1
-
- paddw mm1, mm3
- psrlw mm1, 1
-
- packuswb mm0, mm1
-
- movq [esi+ebx], mm0
-
- lea esi, [esi+8]
-
- dec ecx
- jnz AvgLines8_mmx_loop
-
- mov tmp, esi
- }
-
- for(ptrdiff_t i = pitch & 7; i--; tmp++)
- {
- tmp[pitch] = (tmp[0] + tmp[pitch<<1] + 1) >> 1;
- }
- }
- else
- {
- for(ptrdiff_t i = pitch; i--; tmp++)
- {
- tmp[pitch] = (tmp[0] + tmp[pitch<<1] + 1) >> 1;
- }
- }
- }
-
- if(!(h & 1) && h >= 2)
- {
- dst += (h - 2) * pitch;
- memcpy_accel(dst + pitch, dst, pitch);
- }
-
- __asm emms;
+ if(h <= 1) return;
+
+ BYTE* s = dst;
+ BYTE* d = dst + (h-2)*pitch;
+
+ for(; s < d; s += pitch*2)
+ {
+ BYTE* tmp = s;
+
+ 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:
+ movdqa xmm0, [esi]
+ pavgb xmm0, [esi+ebx*2]
+ movdqa [esi+ebx], xmm0
+ add esi, 16
+
+ dec ecx
+ jnz AvgLines8_sse2_loop
+
+ mov tmp, esi
+ }
+
+ 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
+ {
+ mov esi, tmp
+ mov ebx, pitch
+
+ mov ecx, ebx
+ shr ecx, 3
+
+ pxor mm7, mm7
+AvgLines8_mmx_loop:
+ movq mm0, [esi]
+ movq mm1, mm0
+
+ punpcklbw mm0, mm7
+ punpckhbw mm1, mm7
+
+ movq mm2, [esi+ebx*2]
+ movq mm3, mm2
+
+ punpcklbw mm2, mm7
+ punpckhbw mm3, mm7
+
+ paddw mm0, mm2
+ psrlw mm0, 1
+
+ paddw mm1, mm3
+ psrlw mm1, 1
+
+ packuswb mm0, mm1
+
+ movq [esi+ebx], mm0
+
+ lea esi, [esi+8]
+
+ dec ecx
+ jnz AvgLines8_mmx_loop
+
+ mov tmp, esi
+ }
+
+ for(ptrdiff_t i = pitch&7; i--; tmp++)
+ {
+ tmp[pitch] = (tmp[0] + tmp[pitch<<1] + 1) >> 1;
+ }
+ }
+ else
+ {
+ for(ptrdiff_t i = pitch; i--; tmp++)
+ {
+ tmp[pitch] = (tmp[0] + tmp[pitch<<1] + 1) >> 1;
+ }
+ }
+ }
+
+ if(!(h&1) && h >= 2)
+ {
+ dst += (h-2)*pitch;
+ memcpy_accel(dst + pitch, dst, pitch);
+ }
+
+ __asm emms;
}
void AvgLines555(BYTE* dst, DWORD h, DWORD pitch)
{
- if(h <= 1) return;
+ if(h <= 1) return;
- unsigned __int64 __0x7c007c007c007c00 = 0x7c007c007c007c00;
- unsigned __int64 __0x03e003e003e003e0 = 0x03e003e003e003e0;
- unsigned __int64 __0x001f001f001f001f = 0x001f001f001f001f;
+ unsigned __int64 __0x7c007c007c007c00 = 0x7c007c007c007c00;
+ unsigned __int64 __0x03e003e003e003e0 = 0x03e003e003e003e0;
+ unsigned __int64 __0x001f001f001f001f = 0x001f001f001f001f;
- BYTE* s = dst;
- BYTE* d = dst + (h - 2) * pitch;
+ BYTE* s = dst;
+ BYTE* d = dst + (h-2)*pitch;
- for(; s < d; s += pitch * 2)
- {
- BYTE* tmp = s;
+ for(; s < d; s += pitch*2)
+ {
+ BYTE* tmp = s;
- __asm
- {
- mov esi, tmp
- mov ebx, pitch
+ __asm
+ {
+ mov esi, tmp
+ mov ebx, pitch
- mov ecx, ebx
- shr ecx, 3
+ mov ecx, ebx
+ shr ecx, 3
- movq mm6, __0x03e003e003e003e0
- movq mm7, __0x001f001f001f001f
+ movq mm6, __0x03e003e003e003e0
+ movq mm7, __0x001f001f001f001f
- AvgLines555_loop:
- movq mm0, [esi]
- movq mm1, mm0
- movq mm2, mm0
+AvgLines555_loop:
+ movq mm0, [esi]
+ movq mm1, mm0
+ movq mm2, mm0
- psrlw mm0, 10 // red1 bits: mm0 = 001f001f001f001f
- pand mm1, mm6 // green1 bits: mm1 = 03e003e003e003e0
- pand mm2, mm7 // blue1 bits: mm2 = 001f001f001f001f
+ psrlw mm0, 10 // red1 bits: mm0 = 001f001f001f001f
+ pand mm1, mm6 // green1 bits: mm1 = 03e003e003e003e0
+ pand mm2, mm7 // blue1 bits: mm2 = 001f001f001f001f
- movq mm3, [esi+ebx*2]
- movq mm4, mm3
- movq mm5, mm3
+ movq mm3, [esi+ebx*2]
+ movq mm4, mm3
+ movq mm5, mm3
- psrlw mm3, 10 // red2 bits: mm3 = 001f001f001f001f
- pand mm4, mm6 // green2 bits: mm4 = 03e003e003e003e0
- pand mm5, mm7 // blue2 bits: mm5 = 001f001f001f001f
+ psrlw mm3, 10 // red2 bits: mm3 = 001f001f001f001f
+ pand mm4, mm6 // green2 bits: mm4 = 03e003e003e003e0
+ pand mm5, mm7 // blue2 bits: mm5 = 001f001f001f001f
- paddw mm0, mm3
- psrlw mm0, 1 // (red1+red2)/2
- psllw mm0, 10 // red bits at 7c007c007c007c00
+ paddw mm0, mm3
+ psrlw mm0, 1 // (red1+red2)/2
+ psllw mm0, 10 // red bits at 7c007c007c007c00
- paddw mm1, mm4
- psrlw mm1, 1 // (green1+green2)/2
- pand mm1, mm6 // green bits at 03e003e003e003e0
+ paddw mm1, mm4
+ psrlw mm1, 1 // (green1+green2)/2
+ pand mm1, mm6 // green bits at 03e003e003e003e0
- paddw mm2, mm5
- psrlw mm2, 1 // (blue1+blue2)/2
- // blue bits at 001f001f001f001f (no need to pand, lower bits were discareded)
+ paddw mm2, mm5
+ psrlw mm2, 1 // (blue1+blue2)/2
+ // blue bits at 001f001f001f001f (no need to pand, lower bits were discareded)
- por mm0, mm1
- por mm0, mm2
+ por mm0, mm1
+ por mm0, mm2
- movq [esi+ebx], mm0
+ movq [esi+ebx], mm0
- lea esi, [esi+8]
+ lea esi, [esi+8]
- dec ecx
- jnz AvgLines555_loop
+ dec ecx
+ jnz AvgLines555_loop
- mov tmp, esi
- }
+ mov tmp, esi
+ }
- 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) |
- ((((*tmp & 0x001f) + (tmp[pitch<<1] & 0x001f)) >> 1) & 0x001f);
- }
- }
+ 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)|
+ ((((*tmp&0x001f) + (tmp[pitch<<1]&0x001f)) >> 1)&0x001f);
+ }
+ }
- if(!(h & 1) && h >= 2)
- {
- dst += (h - 2) * pitch;
- memcpy_accel(dst + pitch, dst, pitch);
- }
+ if(!(h&1) && h >= 2)
+ {
+ dst += (h-2)*pitch;
+ memcpy_accel(dst + pitch, dst, pitch);
+ }
- __asm emms;
+ __asm emms;
}
void AvgLines565(BYTE* dst, DWORD h, DWORD pitch)
{
- if(h <= 1) return;
+ if(h <= 1) return;
- unsigned __int64 __0xf800f800f800f800 = 0xf800f800f800f800;
- unsigned __int64 __0x07e007e007e007e0 = 0x07e007e007e007e0;
- unsigned __int64 __0x001f001f001f001f = 0x001f001f001f001f;
+ unsigned __int64 __0xf800f800f800f800 = 0xf800f800f800f800;
+ unsigned __int64 __0x07e007e007e007e0 = 0x07e007e007e007e0;
+ unsigned __int64 __0x001f001f001f001f = 0x001f001f001f001f;
- BYTE* s = dst;
- BYTE* d = dst + (h - 2) * pitch;
+ BYTE* s = dst;
+ BYTE* d = dst + (h-2)*pitch;
- for(; s < d; s += pitch * 2)
- {
- WORD* tmp = (WORD*)s;
+ for(; s < d; s += pitch*2)
+ {
+ WORD* tmp = (WORD*)s;
- __asm
- {
- mov esi, tmp
- mov ebx, pitch
+ __asm
+ {
+ mov esi, tmp
+ mov ebx, pitch
- mov ecx, ebx
- shr ecx, 3
+ mov ecx, ebx
+ shr ecx, 3
- movq mm6, __0x07e007e007e007e0
- movq mm7, __0x001f001f001f001f
+ movq mm6, __0x07e007e007e007e0
+ movq mm7, __0x001f001f001f001f
- AvgLines565_loop:
- movq mm0, [esi]
- movq mm1, mm0
- movq mm2, mm0
+AvgLines565_loop:
+ movq mm0, [esi]
+ movq mm1, mm0
+ movq mm2, mm0
- psrlw mm0, 11 // red1 bits: mm0 = 001f001f001f001f
- pand mm1, mm6 // green1 bits: mm1 = 07e007e007e007e0
- pand mm2, mm7 // blue1 bits: mm2 = 001f001f001f001f
+ psrlw mm0, 11 // red1 bits: mm0 = 001f001f001f001f
+ pand mm1, mm6 // green1 bits: mm1 = 07e007e007e007e0
+ pand mm2, mm7 // blue1 bits: mm2 = 001f001f001f001f
- movq mm3, [esi+ebx*2]
- movq mm4, mm3
- movq mm5, mm3
+ movq mm3, [esi+ebx*2]
+ movq mm4, mm3
+ movq mm5, mm3
- psrlw mm3, 11 // red2 bits: mm3 = 001f001f001f001f
- pand mm4, mm6 // green2 bits: mm4 = 07e007e007e007e0
- pand mm5, mm7 // blue2 bits: mm5 = 001f001f001f001f
+ psrlw mm3, 11 // red2 bits: mm3 = 001f001f001f001f
+ pand mm4, mm6 // green2 bits: mm4 = 07e007e007e007e0
+ pand mm5, mm7 // blue2 bits: mm5 = 001f001f001f001f
- paddw mm0, mm3
- psrlw mm0, 1 // (red1+red2)/2
- psllw mm0, 11 // red bits at f800f800f800f800
+ paddw mm0, mm3
+ psrlw mm0, 1 // (red1+red2)/2
+ psllw mm0, 11 // red bits at f800f800f800f800
- paddw mm1, mm4
- psrlw mm1, 1 // (green1+green2)/2
- pand mm1, mm6 // green bits at 03e003e003e003e0
+ paddw mm1, mm4
+ psrlw mm1, 1 // (green1+green2)/2
+ pand mm1, mm6 // green bits at 03e003e003e003e0
- paddw mm2, mm5
- psrlw mm2, 1 // (blue1+blue2)/2
- // blue bits at 001f001f001f001f (no need to pand, lower bits were discareded)
+ paddw mm2, mm5
+ psrlw mm2, 1 // (blue1+blue2)/2
+ // blue bits at 001f001f001f001f (no need to pand, lower bits were discareded)
- por mm0, mm1
- por mm0, mm2
+ por mm0, mm1
+ por mm0, mm2
- movq [esi+ebx], mm0
+ movq [esi+ebx], mm0
- lea esi, [esi+8]
+ lea esi, [esi+8]
- dec ecx
- jnz AvgLines565_loop
+ dec ecx
+ jnz AvgLines565_loop
- mov tmp, esi
- }
+ mov tmp, esi
+ }
- 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) |
- ((((*tmp & 0x001f) + (tmp[pitch<<1] & 0x001f)) >> 1) & 0x001f);
- }
- }
+ 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)|
+ ((((*tmp&0x001f) + (tmp[pitch<<1]&0x001f)) >> 1)&0x001f);
+ }
+ }
- if(!(h & 1) && h >= 2)
- {
- dst += (h - 2) * pitch;
- memcpy_accel(dst + pitch, dst, pitch);
- }
+ if(!(h&1) && h >= 2)
+ {
+ dst += (h-2)*pitch;
+ memcpy_accel(dst + pitch, dst, pitch);
+ }
- __asm emms;
+ __asm emms;
}
extern "C" void mmx_YUY2toRGB24(const BYTE* src, BYTE* dst, const BYTE* src_end, int src_pitch, int row_size, bool rec709);
@@ -1911,26 +1859,26 @@ extern "C" void mmx_YUY2toRGB32(const BYTE* src, BYTE* dst, const BYTE* src_end, bool BitBltFromYUY2ToRGB(int w, int h, BYTE* dst, int dstpitch, int dbpp, BYTE* src, int srcpitch)
{
- void (* YUY2toRGB)(const BYTE * src, BYTE * dst, const BYTE * src_end, int src_pitch, int row_size, bool rec709) = NULL;
-
- if(g_cpuid.m_flags & CCpuID::mmx)
- {
- YUY2toRGB =
- dbpp == 32 ? mmx_YUY2toRGB32 :
- dbpp == 24 ? mmx_YUY2toRGB24 :
- // dbpp == 16 ? mmx_YUY2toRGB16 : // TODO
- NULL;
- }
- else
- {
- // TODO
- }
-
- if(!YUY2toRGB) return(false);
-
- YUY2toRGB(src, dst, src + h * srcpitch, srcpitch, w, false);
-
- return(true);
+ void (* YUY2toRGB)(const BYTE* src, BYTE* dst, const BYTE* src_end, int src_pitch, int row_size, bool rec709) = NULL;
+
+ if(g_cpuid.m_flags & CCpuID::mmx)
+ {
+ YUY2toRGB =
+ dbpp == 32 ? mmx_YUY2toRGB32 :
+ dbpp == 24 ? mmx_YUY2toRGB24 :
+ // dbpp == 16 ? mmx_YUY2toRGB16 : // TODO
+ NULL;
+ }
+ else
+ {
+ // TODO
+ }
+
+ if(!YUY2toRGB) return(false);
+
+ YUY2toRGB(src, dst, src + h*srcpitch, srcpitch, w, false);
+
+ return(true);
}
#endif //_WIN64
diff --git a/src/DSUtil/vd.h b/src/DSUtil/vd.h index 440ee76e8..9c4ddcc51 100644 --- a/src/DSUtil/vd.h +++ b/src/DSUtil/vd.h @@ -15,7 +15,7 @@ // along with this program; if not, write to the Free Software
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
//
-// Notes:
+// Notes:
// - BitBltFromI420ToRGB is from VirtualDub
// - BitBltFromYUY2ToRGB is from AviSynth 2.52
// - The core assembly function of CCpuID is from DVD2AVI
@@ -23,12 +23,7 @@ #pragma once
-class CCpuID
-{
-public:
- CCpuID();
- enum flag_t {mmx = 1, ssemmx = 2, ssefpu = 4, sse2 = 8, _3dnow = 16} m_flags;
-};
+class CCpuID {public: CCpuID(); enum flag_t {mmx=1, ssemmx=2, ssefpu=4, sse2=8, _3dnow=16} m_flags;};
extern CCpuID g_cpuid;
extern bool BitBltFromI420ToI420(int w, int h, BYTE* dsty, BYTE* dstu, BYTE* dstv, int dstpitch, BYTE* srcy, BYTE* srcu, BYTE* srcv, int srcpitch);
|