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

github.com/mpc-hc/mpc-hc.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjonasno <jonasno@users.sourceforge.net>2010-02-21 21:50:41 +0300
committerjonasno <jonasno@users.sourceforge.net>2010-02-21 21:50:41 +0300
commit3244957f4563575d22bf109de27a703558611b19 (patch)
tree749080f5503fe3fd31e28587000b60b90aacf995 /src/DSUtil
parentc7a41c0086a8bfcd07530779645d98c80039bd84 (diff)
Merged VSFilterMod rev20, only 64 bit code enabled for the time being
git-svn-id: https://mpc-hc.svn.sourceforge.net/svnroot/mpc-hc/trunk@1688 10f7b99b-c216-0410-bff0-8a66a9350fd8
Diffstat (limited to 'src/DSUtil')
-rw-r--r--src/DSUtil/DSMPropertyBag.cpp2
-rw-r--r--src/DSUtil/DSUtil.cpp28
-rw-r--r--src/DSUtil/HdmvClipInfo.cpp12
-rw-r--r--src/DSUtil/HdmvClipInfo.h10
-rw-r--r--src/DSUtil/MediaTypeEx.cpp10
-rw-r--r--src/DSUtil/MediaTypes.cpp4
-rw-r--r--src/DSUtil/cpuid64.asm35
-rw-r--r--src/DSUtil/cpuid_32_64.cpp0
-rw-r--r--src/DSUtil/cpuid_32_64.h15
-rw-r--r--src/DSUtil/dsutil.vcproj50
-rw-r--r--src/DSUtil/text.cpp4
-rw-r--r--src/DSUtil/text.h6
-rw-r--r--src/DSUtil/vd.cpp163
-rw-r--r--src/DSUtil/vd.h3
14 files changed, 265 insertions, 77 deletions
diff --git a/src/DSUtil/DSMPropertyBag.cpp b/src/DSUtil/DSMPropertyBag.cpp
index 4544e16da..07862fc0f 100644
--- a/src/DSUtil/DSMPropertyBag.cpp
+++ b/src/DSUtil/DSMPropertyBag.cpp
@@ -237,7 +237,7 @@ STDMETHODIMP IDSMResourceBagImpl::ResRemoveAll(DWORD_PTR tag)
{
if(tag)
{
- for(int i = m_resources.GetCount() - 1; i >= 0; i--)
+ for(ptrdiff_t i = m_resources.GetCount() - 1; i >= 0; i--)
if(m_resources[i].tag == tag)
m_resources.RemoveAt(i);
}
diff --git a/src/DSUtil/DSUtil.cpp b/src/DSUtil/DSUtil.cpp
index 4ef3254b7..772fac0cb 100644
--- a/src/DSUtil/DSUtil.cpp
+++ b/src/DSUtil/DSUtil.cpp
@@ -49,7 +49,7 @@ void DumpStreamConfig(TCHAR* fn, IAMStreamConfig* pAMVSCCap)
if(size == sizeof(VIDEO_STREAM_CONFIG_CAPS))
{
- for(int i = 0; i < cnt; i++)
+ for(ptrdiff_t i = 0; i < cnt; i++)
{
AM_MEDIA_TYPE* pmt = NULL;
@@ -590,7 +590,7 @@ void ExtractMediaTypes(IPin* pPin, CAtlArray<GUID>& types)
{
bool fFound = false;
- for(int i = 0; !fFound && i < (int)types.GetCount(); i += 2)
+ for(ptrdiff_t i = 0; !fFound && i < (int)types.GetCount(); i += 2)
{
if(types[i] == pmt->majortype && types[i+1] == pmt->subtype)
fFound = true;
@@ -745,7 +745,7 @@ void CStringToBin(CString str, CAtlArray<BYTE>& data)
BYTE b = 0;
str.MakeUpper();
- for(int i = 0, j = str.GetLength(); i < j; i++)
+ for(size_t i = 0, j = str.GetLength(); i < j; i++)
{
TCHAR c = str[i];
if(c >= '0' && c <= '9')
@@ -840,7 +840,7 @@ cdrom_t GetCDROMType(TCHAR drive, CAtlList<CString>& files)
CDROM_TOC TOC;
if(DeviceIoControl(hDrive, IOCTL_CDROM_READ_TOC, NULL, 0, &TOC, sizeof(TOC), &BytesReturned, 0))
{
- for(int i = TOC.FirstTrack; i <= TOC.LastTrack; i++)
+ 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;
@@ -908,11 +908,11 @@ bool GetKeyFrames(CString fn, CUIntArray& kfs)
if(afi.dwCaps&AVIFILECAPS_ALLKEYFRAMES)
{
kfs.SetSize(si.dwLength);
- for(int kf = 0; kf < (int)si.dwLength; kf++) kfs[kf] = kf;
+ for(ptrdiff_t kf = 0; kf < (int)si.dwLength; kf++) kfs[kf] = kf;
}
else
{
- for(int kf = 0; ; kf++)
+ 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;
@@ -2037,7 +2037,7 @@ CString ISO6391ToLanguage(LPCSTR code)
strncpy_s(tmp, code, 2);
tmp[2] = 0;
_strlwr_s(tmp);
- for(int i = 0, j = countof(s_isolangs); i < j; i++)
+ 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));
@@ -2054,7 +2054,7 @@ CString ISO6392ToLanguage(LPCSTR code)
strncpy_s(tmp, code, 3);
tmp[3] = 0;
_strlwr_s(tmp);
- for(int i = 0, j = countof(s_isolangs); i < j; i++)
+ for(ptrdiff_t i = 0, j = countof(s_isolangs); i < j; i++)
{
if(!strcmp(s_isolangs[i].iso6392, tmp))
{
@@ -2073,7 +2073,7 @@ LCID ISO6391ToLcid(LPCSTR code)
strncpy_s(tmp, code, 3);
tmp[3] = 0;
_strlwr_s(tmp);
- for(int i = 0, j = countof(s_isolangs); i < j; i++)
+ for(ptrdiff_t i = 0, j = countof(s_isolangs); i < j; i++)
{
if(!strcmp(s_isolangs[i].iso6391, code))
{
@@ -2089,7 +2089,7 @@ LCID ISO6392ToLcid(LPCSTR code)
strncpy_s(tmp, code, 3);
tmp[3] = 0;
_strlwr_s(tmp);
- for(int i = 0, j = countof(s_isolangs); i < j; i++)
+ for(ptrdiff_t i = 0, j = countof(s_isolangs); i < j; i++)
{
if(!strcmp(s_isolangs[i].iso6392, tmp))
{
@@ -2105,7 +2105,7 @@ CString ISO6391To6392(LPCSTR code)
strncpy_s(tmp, code, 2);
tmp[2] = 0;
_strlwr_s(tmp);
- for(int i = 0, j = countof(s_isolangs); i < j; i++)
+ 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("");
@@ -2117,7 +2117,7 @@ CString ISO6392To6391(LPCSTR code)
strncpy_s(tmp, code, 3);
tmp[3] = 0;
_strlwr_s(tmp);
- for(int i = 0, j = countof(s_isolangs); i < j; i++)
+ 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("");
@@ -2127,7 +2127,7 @@ CString LanguageToISO6392(LPCTSTR lang)
{
CString str = lang;
str.MakeLower();
- for(int i = 0, j = countof(s_isolangs); i < j; i++)
+ for(ptrdiff_t i = 0, j = countof(s_isolangs); i < j; i++)
{
CAtlList<CString> sl;
Explode(CString(s_isolangs[i].name), sl, ';');
@@ -2284,7 +2284,7 @@ void RegisterSourceFilter(const CLSID& clsid, const GUID& subtype2, const CAtlLi
CString subtype = CStringFromGUID(subtype2);
POSITION pos = chkbytes.GetHeadPosition();
- for(int i = 0; pos; i++)
+ for(ptrdiff_t i = 0; pos; i++)
{
CString idx;
idx.Format(_T("%d"), i);
diff --git a/src/DSUtil/HdmvClipInfo.cpp b/src/DSUtil/HdmvClipInfo.cpp
index 2ac1183a0..35dfea8be 100644
--- a/src/DSUtil/HdmvClipInfo.cpp
+++ b/src/DSUtil/HdmvClipInfo.cpp
@@ -66,7 +66,7 @@ BYTE CHdmvClipInfo::ReadByte()
return bVal;
}
-void CHdmvClipInfo::ReadBuffer(BYTE* pBuff, int nLen)
+void CHdmvClipInfo::ReadBuffer(BYTE* pBuff, DWORD nLen)
{
DWORD dwRead;
ReadFile (m_hFile, pBuff, nLen, &dwRead, NULL);
@@ -85,14 +85,14 @@ HRESULT CHdmvClipInfo::ReadProgramInfo()
ReadByte(); //reserved_for_word_align
number_of_program_sequences = (BYTE)ReadByte();
int iStream = 0;
- for (int i=0; i<number_of_program_sequences; i++)
+ 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 (int stream_index=0; stream_index<number_of_streams_in_ps; stream_index++)
+ 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
@@ -199,8 +199,8 @@ HRESULT CHdmvClipInfo::ReadInfo(LPCTSTR strFile)
CHdmvClipInfo::Stream* CHdmvClipInfo::FindStream(SHORT wPID)
{
- int nStreams = int(m_Streams.GetCount());
- for (int i=0; i<nStreams; i++)
+ 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];
@@ -289,7 +289,7 @@ HRESULT CHdmvClipInfo::ReadPlaylist(CString strPlaylistFile, REFERENCE_TIME& rtD
dwPos += 10;
rtDuration = 0;
- for (int i=0; i<nPlaylistItems; i++)
+ for (size_t i=0; i<nPlaylistItems; i++)
{
PlaylistItem Item;
SetFilePointer(m_hFile, dwPos, NULL, FILE_BEGIN);
diff --git a/src/DSUtil/HdmvClipInfo.h b/src/DSUtil/HdmvClipInfo.h
index 0f129035b..fe1030af0 100644
--- a/src/DSUtil/HdmvClipInfo.h
+++ b/src/DSUtil/HdmvClipInfo.h
@@ -117,7 +117,7 @@ public:
REFERENCE_TIME m_rtIn;
REFERENCE_TIME m_rtOut;
- REFERENCE_TIME Duration() const
+ REFERENCE_TIME Duration()
{
return m_rtOut - m_rtIn;
}
@@ -133,9 +133,9 @@ public:
HRESULT ReadInfo(LPCTSTR strFile);
Stream* FindStream(SHORT wPID);
- bool IsHdmv() const { return m_bIsHdmv; };
- int GetStreamNumber() { return int(m_Streams.GetCount()); };
- Stream* GetStreamByIndex(int nIndex){ return (unsigned(nIndex) < m_Streams.GetCount()) ? &m_Streams[nIndex] : NULL; };
+ bool IsHdmv() { 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);
@@ -153,7 +153,7 @@ private :
DWORD ReadDword();
SHORT ReadShort();
BYTE ReadByte();
- void ReadBuffer(BYTE* pBuff, int nLen);
+ void ReadBuffer(BYTE* pBuff, DWORD nLen);
HRESULT ReadProgramInfo();
HRESULT CloseFile(HRESULT hr);
diff --git a/src/DSUtil/MediaTypeEx.cpp b/src/DSUtil/MediaTypeEx.cpp
index 9b3607379..027808a3a 100644
--- a/src/DSUtil/MediaTypeEx.cpp
+++ b/src/DSUtil/MediaTypeEx.cpp
@@ -215,7 +215,7 @@ CString CMediaTypeEx::GetVideoCodecName(const GUID& subtype, DWORD biCompression
{
BYTE* b = (BYTE*)&biCompression;
- for(int i = 0; i < 4; i++)
+ for(ptrdiff_t i = 0; i < 4; i++)
if(b[i] >= 'a' && b[i] <= 'z')
b[i] = toupper(b[i]);
@@ -618,25 +618,25 @@ void CMediaTypeEx::Dump(CAtlList<CString>& sl)
{
sl.AddTail(_T("pbFormat:"));
- for(int i = 0, j = (cbFormat + 15) & ~15; i < j; i += 16)
+ for(ptrdiff_t i = 0, j = (cbFormat + 15) & ~15; i < j; i += 16)
{
str.Format(_T("%04x:"), i);
- for(int k = i, l = min(i + 16, (int)cbFormat); k < l; k++)
+ 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(int k = min(i + 16, (int)cbFormat), l = i + 16; k < l; k++)
+ for(ptrdiff_t k = min(i + 16, (int)cbFormat), l = i + 16; k < l; k++)
{
str += _T(" ");
}
str += ' ';
- for(int k = i, l = min(i + 16, (int)cbFormat); k < l; k++)
+ for(ptrdiff_t k = i, l = min(i + 16, (int)cbFormat); k < l; k++)
{
unsigned char c = (unsigned char)pbFormat[k];
CStringA ch;
diff --git a/src/DSUtil/MediaTypes.cpp b/src/DSUtil/MediaTypes.cpp
index b7ccd18a1..47a45c607 100644
--- a/src/DSUtil/MediaTypes.cpp
+++ b/src/DSUtil/MediaTypes.cpp
@@ -348,7 +348,7 @@ void CorrectMediaType(AM_MEDIA_TYPE* pmt)
{
VIDEOINFOHEADER* vih = (VIDEOINFOHEADER*)mt.pbFormat;
- for(int i = 0; i < VIHSIZE; i++)
+ for(ptrdiff_t i = 0; i < VIHSIZE; i++)
{
if(mt.subtype == *vihs[i].subtype
&& vih->bmiHeader.biCompression == vihs[i].vih.bmiHeader.biCompression)
@@ -364,7 +364,7 @@ void CorrectMediaType(AM_MEDIA_TYPE* pmt)
{
VIDEOINFOHEADER2* vih2 = (VIDEOINFOHEADER2*)mt.pbFormat;
- for(int i = 0; i < VIHSIZE; i++)
+ for(ptrdiff_t i = 0; i < VIHSIZE; i++)
{
if(mt.subtype == *vih2s[i].subtype
&& vih2->bmiHeader.biCompression == vih2s[i].vih.bmiHeader.biCompression)
diff --git a/src/DSUtil/cpuid64.asm b/src/DSUtil/cpuid64.asm
new file mode 100644
index 000000000..4c3d4c35b
--- /dev/null
+++ b/src/DSUtil/cpuid64.asm
@@ -0,0 +1,35 @@
+; ml64 /c /Cx /nologo /Fo"$(OutDir)\$(InputName).obj" "$(InputPath)"
+; call cpuid with args in eax, ecx
+; store eax, ebx, ecx, edx to p
+
+ _TEXT64 segment page 'CODE'
+
+ align 8
+
+ PUBLIC cpuid64
+
+ cpuid64 PROC FRAME
+ ; void cpuid64(CPUID_ARGS* p);
+ ; rcx <= p
+ sub rsp, 32
+ .allocstack 32
+ push rbx
+ .pushreg rbx
+ .endprolog
+ mov r8, rcx
+ mov eax, DWORD PTR [r8+0]
+ mov ecx, DWORD PTR [r8+8]
+ cpuid
+ mov DWORD PTR [r8+0], eax
+ mov DWORD PTR [r8+4], ebx
+ mov DWORD PTR [r8+8], ecx
+ mov DWORD PTR [r8+12], edx
+ pop rbx
+ add rsp, 32
+ ret
+
+ ALIGN 8
+ cpuid64 ENDP
+_TEXT64 ENDS
+
+END \ No newline at end of file
diff --git a/src/DSUtil/cpuid_32_64.cpp b/src/DSUtil/cpuid_32_64.cpp
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/src/DSUtil/cpuid_32_64.cpp
diff --git a/src/DSUtil/cpuid_32_64.h b/src/DSUtil/cpuid_32_64.h
new file mode 100644
index 000000000..29990b681
--- /dev/null
+++ b/src/DSUtil/cpuid_32_64.h
@@ -0,0 +1,15 @@
+#pragma once
+
+typedef struct cpuid_args_s {
+DWORD eax;
+DWORD ebx;
+DWORD ecx;
+DWORD edx;
+} CPUID_ARGS;
+
+extern "C" {
+#ifdef _WIN64 // For 64-bit apps
+ void cpuid64(CPUID_ARGS* p);
+#define _CPUID cpuid64
+#endif
+} \ No newline at end of file
diff --git a/src/DSUtil/dsutil.vcproj b/src/DSUtil/dsutil.vcproj
index ba520b044..c8680014f 100644
--- a/src/DSUtil/dsutil.vcproj
+++ b/src/DSUtil/dsutil.vcproj
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="windows-1250"?>
<VisualStudioProject
ProjectType="Visual C++"
- Version="9.00"
+ Version="9,00"
Name="DSUtil"
ProjectGUID="{FC70988B-1AE5-4381-866D-4F405E28AC42}"
RootNamespace="dsutil"
@@ -404,6 +404,50 @@
</FileConfiguration>
</File>
<File
+ RelativePath=".\cpuid64.asm"
+ >
+ <FileConfiguration
+ Name="Debug Unicode|Win32"
+ ExcludedFromBuild="true"
+ >
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Debug Unicode|x64"
+ >
+ <Tool
+ Name="VCCustomBuildTool"
+ Description="cpuid64.asm"
+ CommandLine="ml64 /c /Cx /nologo /Fo&quot;$(OutDir)\$(InputName).obj&quot; &quot;$(InputPath)&quot;"
+ Outputs="$(OutDir)\$(InputName).obj"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release Unicode|Win32"
+ ExcludedFromBuild="true"
+ >
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release Unicode|x64"
+ >
+ <Tool
+ Name="VCCustomBuildTool"
+ Description="cpuid64.asm"
+ CommandLine="ml64 /c /Cx /nologo /Fo&quot;$(OutDir)\$(InputName).obj&quot; &quot;$(InputPath)&quot;"
+ Outputs="$(OutDir)\$(InputName).obj"
+ />
+ </FileConfiguration>
+ </File>
+ <File
+ RelativePath=".\cpuid_32_64.cpp"
+ >
+ </File>
+ <File
RelativePath=".\DSMPropertyBag.cpp"
>
</File>
@@ -509,6 +553,10 @@
Filter="h;hpp;hxx;hm;inl;inc"
>
<File
+ RelativePath=".\cpuid_32_64.h"
+ >
+ </File>
+ <File
RelativePath=".\DSMPropertyBag.h"
>
</File>
diff --git a/src/DSUtil/text.cpp b/src/DSUtil/text.cpp
index 382ee5301..99d61f702 100644
--- a/src/DSUtil/text.cpp
+++ b/src/DSUtil/text.cpp
@@ -11,7 +11,7 @@ CString Explode(CString str, CAtlList<CString>& sl, TCHAR sep, int limit)
if(!str.IsEmpty() && str[str.GetLength()-1] != sep)
str += sep;
- for(int i = 0, j = 0; (j = str.Find(sep, i)) >= 0; i = j+1)
+ for(ptrdiff_t i = 0, j = 0; (j = str.Find(sep, i)) >= 0; i = j+1)
{
CString tmp = str.Mid(i, j-i);
tmp.TrimLeft(sep); tmp.TrimRight(sep);
@@ -108,7 +108,7 @@ CStringA UrlEncode(CStringA str, bool fRaw)
{
CStringA urlstr;
- for(int i = 0; i < str.GetLength(); i++)
+ for(size_t i = 0; i < str.GetLength(); i++)
{
CHAR c = str[i];
if(fRaw && c == '+') urlstr += "%2B";
diff --git a/src/DSUtil/text.h b/src/DSUtil/text.h
index 14cd1149a..caef07a1a 100644
--- a/src/DSUtil/text.h
+++ b/src/DSUtil/text.h
@@ -7,11 +7,11 @@
// extern CString Implode(CAtlList<CString>& sl, TCHAR sep);
template<class T, typename SEP>
-T Explode(T str, CAtlList<T>& sl, SEP sep, int limit = 0)
+T Explode(T str, CAtlList<T>& sl, SEP sep, size_t limit = 0)
{
sl.RemoveAll();
- for(int i = 0, j = 0; ; i = j+1)
+ for(ptrdiff_t i = 0, j = 0; ; i = j+1)
{
j = str.Find(sep, i);
@@ -30,7 +30,7 @@ T Explode(T str, CAtlList<T>& sl, SEP sep, int limit = 0)
}
template<class T, typename SEP>
-T ExplodeMin(T str, CAtlList<T>& sl, SEP sep, int limit = 0)
+T ExplodeMin(T str, CAtlList<T>& sl, SEP sep, size_t limit = 0)
{
Explode(str, sl, sep, limit);
POSITION pos = sl.GetHeadPosition();
diff --git a/src/DSUtil/vd.cpp b/src/DSUtil/vd.cpp
index 410308a74..0b06b043b 100644
--- a/src/DSUtil/vd.cpp
+++ b/src/DSUtil/vd.cpp
@@ -24,6 +24,7 @@
#include "stdafx.h"
#include "vd.h"
+#include "cpuid_32_64.h"
#pragma warning(disable : 4799) // no emms... blahblahblah
@@ -34,7 +35,27 @@ CCpuID g_cpuid;
CCpuID::CCpuID()
{
// TODOX64 : ??
- m_flags = (flag_t)7;
+ 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)
@@ -86,7 +107,7 @@ bool BitBltFromI420ToI420(int w, int h, BYTE* dsty, BYTE* dstu, BYTE* dstv, int
{
int pitch = min(abs(srcpitch), abs(dstpitch));
- for(int y = 0; y < h; y++, srcy += srcpitch, dsty += dstpitch)
+ for(ptrdiff_t y = 0; y < h; y++, srcy += srcpitch, dsty += dstpitch)
memcpy(dsty, srcy, pitch);
srcpitch >>= 1;
@@ -94,10 +115,10 @@ bool BitBltFromI420ToI420(int w, int h, BYTE* dsty, BYTE* dstu, BYTE* dstv, int
pitch = min(abs(srcpitch), abs(dstpitch));
- for(int y = 0; y < h; y+=2, srcu += srcpitch, dstu += dstpitch)
+ for(ptrdiff_t y = 0; y < h; y+=2, srcu += srcpitch, dstu += dstpitch)
memcpy(dstu, srcu, pitch);
- for(int y = 0; y < h; y+=2, srcv += srcpitch, dstv += dstpitch)
+ for(ptrdiff_t y = 0; y < h; y+=2, srcv += srcpitch, dstv += dstpitch)
memcpy(dstv, srcv, pitch);
}
@@ -139,7 +160,7 @@ bool BitBltFromYUY2ToYUY2(int w, int h, BYTE* dst, int dstpitch, BYTE* src, int
{
int pitch = min(abs(srcpitch), abs(dstpitch));
- for(int y = 0; y < h; y++, src += srcpitch, dst += dstpitch)
+ for(ptrdiff_t y = 0; y < h; y++, src += srcpitch, dst += dstpitch)
memcpy(dst, src, pitch);
}
@@ -164,7 +185,7 @@ bool BitBltFromRGBToRGB(int w, int h, BYTE* dst, int dstpitch, int dbpp, BYTE* s
}
else
{
- for(int y = 0; y < h; y++, src += srcpitch, dst += dstpitch)
+ for(ptrdiff_t y = 0; y < h; y++, src += srcpitch, dst += dstpitch)
memcpy(dst, src, rowbytes);
}
@@ -177,33 +198,33 @@ bool BitBltFromRGBToRGB(int w, int h, BYTE* dst, int dstpitch, int dbpp, BYTE* s
if(dbpp == 16)
{
- for(int y = 0; y < h; y++, src += srcpitch, dst += dstpitch)
+ for(ptrdiff_t y = 0; y < h; y++, src += srcpitch, dst += dstpitch)
{
if(sbpp == 24)
{
BYTE* s = (BYTE*)src;
WORD* d = (WORD*)dst;
- for(int x = 0; x < w; x++, s+=3, d++)
+ 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(int x = 0; x < w; x++, s++, d++)
+ 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(int y = 0; y < h; y++, src += srcpitch, dst += dstpitch)
+ for(ptrdiff_t y = 0; y < h; y++, src += srcpitch, dst += dstpitch)
{
if(sbpp == 16)
{
WORD* s = (WORD*)src;
BYTE* d = (BYTE*)dst;
- for(int x = 0; x < w; x++, s++, d+=3)
+ 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;
@@ -214,27 +235,27 @@ bool BitBltFromRGBToRGB(int w, int h, BYTE* dst, int dstpitch, int dbpp, BYTE* s
{
BYTE* s = (BYTE*)src;
BYTE* d = (BYTE*)dst;
- for(int x = 0; x < w; x++, s+=4, d+=3)
+ 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(int y = 0; y < h; y++, src += srcpitch, dst += dstpitch)
+ for(ptrdiff_t y = 0; y < h; y++, src += srcpitch, dst += dstpitch)
{
if(sbpp == 16)
{
WORD* s = (WORD*)src;
DWORD* d = (DWORD*)dst;
- for(int x = 0; x < w; x++, s++, d++)
+ 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(int x = 0; x < w; x++, s+=3, d++)
+ for(ptrdiff_t x = 0; x < w; x++, s+=3, d++)
*d = *((DWORD*)s)&0xffffff;
}
}
@@ -292,7 +313,7 @@ void AvgLines8(BYTE* dst, DWORD h, DWORD pitch)
BYTE* tmp = s;
{
- for(int i = pitch; i--; tmp++)
+ for(ptrdiff_t i = pitch; i--; tmp++)
{
tmp[pitch] = (tmp[0] + tmp[pitch<<1] + 1) >> 1;
}
@@ -307,6 +328,76 @@ void AvgLines8(BYTE* dst, DWORD h, DWORD 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);
+ }
+}
+
+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);
+ }
+}
+
#else // _WIN64
CCpuID::CCpuID()
@@ -495,7 +586,7 @@ bool BitBltFromI420ToI420(int w, int h, BYTE* dsty, BYTE* dstu, BYTE* dstv, int
{
int pitch = min(abs(srcpitch), abs(dstpitch));
- for(int y = 0; y < h; y++, srcy += srcpitch, dsty += dstpitch)
+ for(ptrdiff_t y = 0; y < h; y++, srcy += srcpitch, dsty += dstpitch)
memcpy_accel(dsty, srcy, pitch);
srcpitch >>= 1;
@@ -503,10 +594,10 @@ bool BitBltFromI420ToI420(int w, int h, BYTE* dsty, BYTE* dstu, BYTE* dstv, int
pitch = min(abs(srcpitch), abs(dstpitch));
- for(int y = 0; y < h; y+=2, srcu += srcpitch, dstu += dstpitch)
+ for(ptrdiff_t y = 0; y < h; y+=2, srcu += srcpitch, dstu += dstpitch)
memcpy_accel(dstu, srcu, pitch);
- for(int y = 0; y < h; y+=2, srcv += srcpitch, dstv += dstpitch)
+ for(ptrdiff_t y = 0; y < h; y+=2, srcv += srcpitch, dstv += dstpitch)
memcpy_accel(dstv, srcv, pitch);
}
@@ -523,7 +614,7 @@ bool BitBltFromYUY2ToYUY2(int w, int h, BYTE* dst, int dstpitch, BYTE* src, int
{
int pitch = min(abs(srcpitch), abs(dstpitch));
- for(int y = 0; y < h; y++, src += srcpitch, dst += dstpitch)
+ for(ptrdiff_t y = 0; y < h; y++, src += srcpitch, dst += dstpitch)
memcpy_accel(dst, src, pitch);
}
@@ -545,7 +636,7 @@ bool BitBltFromI420ToRGB(int w, int h, BYTE* dst, int dstpitch, int dbpp, BYTE*
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;
+ 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))
{
@@ -1070,7 +1161,7 @@ bool BitBltFromRGBToRGB(int w, int h, BYTE* dst, int dstpitch, int dbpp, BYTE* s
}
else
{
- for(int y = 0; y < h; y++, src += srcpitch, dst += dstpitch)
+ for(ptrdiff_t y = 0; y < h; y++, src += srcpitch, dst += dstpitch)
memcpy_accel(dst, src, rowbytes);
}
@@ -1083,33 +1174,33 @@ bool BitBltFromRGBToRGB(int w, int h, BYTE* dst, int dstpitch, int dbpp, BYTE* s
if(dbpp == 16)
{
- for(int y = 0; y < h; y++, src += srcpitch, dst += dstpitch)
+ for(ptrdiff_t y = 0; y < h; y++, src += srcpitch, dst += dstpitch)
{
if(sbpp == 24)
{
BYTE* s = (BYTE*)src;
WORD* d = (WORD*)dst;
- for(int x = 0; x < w; x++, s+=3, d++)
+ 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(int x = 0; x < w; x++, s++, d++)
+ 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(int y = 0; y < h; y++, src += srcpitch, dst += dstpitch)
+ for(ptrdiff_t y = 0; y < h; y++, src += srcpitch, dst += dstpitch)
{
if(sbpp == 16)
{
WORD* s = (WORD*)src;
BYTE* d = (BYTE*)dst;
- for(int x = 0; x < w; x++, s++, d+=3)
+ 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;
@@ -1120,27 +1211,27 @@ bool BitBltFromRGBToRGB(int w, int h, BYTE* dst, int dstpitch, int dbpp, BYTE* s
{
BYTE* s = (BYTE*)src;
BYTE* d = (BYTE*)dst;
- for(int x = 0; x < w; x++, s+=4, d+=3)
+ 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(int y = 0; y < h; y++, src += srcpitch, dst += dstpitch)
+ for(ptrdiff_t y = 0; y < h; y++, src += srcpitch, dst += dstpitch)
{
if(sbpp == 16)
{
WORD* s = (WORD*)src;
DWORD* d = (DWORD*)dst;
- for(int x = 0; x < w; x++, s++, d++)
+ 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(int x = 0; x < w; x++, s+=3, d++)
+ for(ptrdiff_t x = 0; x < w; x++, s+=3, d++)
*d = *((DWORD*)s)&0xffffff;
}
}
@@ -1521,7 +1612,7 @@ AvgLines8_sse2_loop:
mov tmp, esi
}
- for(int i = pitch&7; i--; tmp++)
+ for(ptrdiff_t i = pitch&7; i--; tmp++)
{
tmp[pitch] = (tmp[0] + tmp[pitch<<1] + 1) >> 1;
}
@@ -1568,14 +1659,14 @@ AvgLines8_mmx_loop:
mov tmp, esi
}
- for(int i = pitch&7; i--; tmp++)
+ for(ptrdiff_t i = pitch&7; i--; tmp++)
{
tmp[pitch] = (tmp[0] + tmp[pitch<<1] + 1) >> 1;
}
}
else
{
- for(int i = pitch; i--; tmp++)
+ for(ptrdiff_t i = pitch; i--; tmp++)
{
tmp[pitch] = (tmp[0] + tmp[pitch<<1] + 1) >> 1;
}
@@ -1659,7 +1750,7 @@ AvgLines555_loop:
mov tmp, esi
}
- for(int i = (pitch&7)>>1; i--; tmp++)
+ for(ptrdiff_t i = (pitch&7)>>1; i--; tmp++)
{
tmp[pitch] =
((((*tmp&0x7c00) + (tmp[pitch<<1]&0x7c00)) >> 1)&0x7c00)|
@@ -1745,7 +1836,7 @@ AvgLines565_loop:
mov tmp, esi
}
- for(int i = (pitch&7)>>1; i--; tmp++)
+ for(ptrdiff_t i = (pitch&7)>>1; i--; tmp++)
{
tmp[pitch] =
((((*tmp&0xf800) + (tmp[pitch<<1]&0xf800)) >> 1)&0xf800)|
diff --git a/src/DSUtil/vd.h b/src/DSUtil/vd.h
index 434c214ec..9c4ddcc51 100644
--- a/src/DSUtil/vd.h
+++ b/src/DSUtil/vd.h
@@ -38,5 +38,4 @@ extern void DeinterlaceBob(BYTE* dst, BYTE* src, DWORD rowbytes, DWORD h, DWORD
extern void AvgLines8(BYTE* dst, DWORD h, DWORD pitch);
extern void AvgLines555(BYTE* dst, DWORD h, DWORD pitch);
-extern void AvgLines565(BYTE* dst, DWORD h, DWORD pitch);
-
+extern void AvgLines565(BYTE* dst, DWORD h, DWORD pitch); \ No newline at end of file