diff options
author | kasper93 <kasper93@gmail.com> | 2014-07-09 11:56:53 +0400 |
---|---|---|
committer | kasper93 <kasper93@gmail.com> | 2014-07-10 11:45:45 +0400 |
commit | 6c228d47e3d9adb9ef65f0045fa6a13aa43cdba7 (patch) | |
tree | caef75ba30159fb46ef6d31fd01b17c56eb276fa /src/Subtitles | |
parent | 231f8d9f38e23ef3a409a28d6368dab5c63a4e15 (diff) |
Rasterizer: Remove VirtualDub dependency to detect SSE2.
Diffstat (limited to 'src/Subtitles')
-rw-r--r-- | src/Subtitles/RTS.cpp | 5 | ||||
-rw-r--r-- | src/Subtitles/Rasterizer.cpp | 30 | ||||
-rw-r--r-- | src/Subtitles/Rasterizer.h | 2 |
3 files changed, 17 insertions, 20 deletions
diff --git a/src/Subtitles/RTS.cpp b/src/Subtitles/RTS.cpp index b40c5d4fe..4ccefc54f 100644 --- a/src/Subtitles/RTS.cpp +++ b/src/Subtitles/RTS.cpp @@ -21,8 +21,7 @@ #include "stdafx.h"
#include <math.h>
-#include <time.h>
-#include <emmintrin.h>
+#include <intrin.h>
#include <algorithm>
#include "RTS.h"
#include "../DSUtil/WinAPIUtils.h"
@@ -182,7 +181,7 @@ void CWord::Paint(const CPoint& p, const CPoint& org) void CWord::Transform(CPoint org)
{
- if (fSSE2) { // SSE code
+ if (m_bUseSSE2) { // SSE code
Transform_SSE2(org);
} else { // C-code
Transform_C(org);
diff --git a/src/Subtitles/Rasterizer.cpp b/src/Subtitles/Rasterizer.cpp index 495f491b6..253955910 100644 --- a/src/Subtitles/Rasterizer.cpp +++ b/src/Subtitles/Rasterizer.cpp @@ -24,12 +24,9 @@ #include <math.h>
#include <vector>
#include <algorithm>
-#include <xmmintrin.h>
-#include <emmintrin.h>
-#include <mmintrin.h>
+#include <intrin.h>
#include "Rasterizer.h"
#include "SeparableFilter.h"
-#include "../DSUtil/vd.h" // For CPUID usage in Rasterizer::Draw
#define MAX_DIMENSION 4000 // Maximum width or height supported
#define SUBPIXEL_MULTIPLIER 8
@@ -61,8 +58,9 @@ Rasterizer::Rasterizer() , mEdgeNext(0)
, mpScanBuffer(0)
{
- // CPUID from VDub
- fSSE2 = !!(g_cpuid.m_flags & CCpuID::sse2);
+ int cpuInfo[4] = { -1 };
+ __cpuid(cpuInfo, 1);
+ m_bUseSSE2 = !!(cpuInfo[3] & (1 << 26));
}
Rasterizer::~Rasterizer()
@@ -858,7 +856,7 @@ bool Rasterizer::Rasterize(int xsub, int ysub, int fBlur, double fGaussianBlur) byte* src = m_outlineData.mWideOutline.empty() ? m_overlayData.mpOverlayBufferBody : m_overlayData.mpOverlayBufferBorder;
- if (fSSE2) {
+ if (m_bUseSSE2) {
SeparableFilterX_SSE2(src, tmp, m_overlayData.mOverlayWidth, m_overlayData.mOverlayHeight, pitch,
filter.kernel, filter.width, filter.divisor);
SeparableFilterY_SSE2(tmp, src, m_overlayData.mOverlayWidth, m_overlayData.mOverlayHeight, pitch,
@@ -1556,7 +1554,7 @@ CRect Rasterizer::Draw(SubPicDesc& spd, CRect& clipRect, byte* pAlphaMask, int x if (switchpts[1] == DWORD_MAX) {
// fBody is true if we're rendering a fill or a shadow.
if (fBody) {
- if (fSSE2) {
+ if (m_bUseSSE2) {
Draw_noAlpha_spFF_Body_sse2(rnfo);
} else {
Draw_noAlpha_spFF_Body_0(rnfo);
@@ -1564,7 +1562,7 @@ CRect Rasterizer::Draw(SubPicDesc& spd, CRect& clipRect, byte* pAlphaMask, int x }
// Not painting body, ie. painting border without fill in it
else {
- if (fSSE2) {
+ if (m_bUseSSE2) {
Draw_noAlpha_spFF_noBody_sse2(rnfo);
} else {
Draw_noAlpha_spFF_noBody_0(rnfo);
@@ -1577,7 +1575,7 @@ CRect Rasterizer::Draw(SubPicDesc& spd, CRect& clipRect, byte* pAlphaMask, int x //const long *sw = switchpts;
if (fBody) {
- if (fSSE2) {
+ if (m_bUseSSE2) {
Draw_noAlpha_sp_Body_sse2(rnfo);
} else {
Draw_noAlpha_sp_Body_0(rnfo);
@@ -1585,7 +1583,7 @@ CRect Rasterizer::Draw(SubPicDesc& spd, CRect& clipRect, byte* pAlphaMask, int x }
// Not body
else {
- if (fSSE2) {
+ if (m_bUseSSE2) {
Draw_noAlpha_sp_noBody_sse2(rnfo);
} else {
Draw_noAlpha_sp_noBody_0(rnfo);
@@ -1597,13 +1595,13 @@ CRect Rasterizer::Draw(SubPicDesc& spd, CRect& clipRect, byte* pAlphaMask, int x else {
if (switchpts[1] == DWORD_MAX) {
if (fBody) {
- if (fSSE2) {
+ if (m_bUseSSE2) {
Draw_Alpha_spFF_Body_sse2(rnfo);
} else {
Draw_Alpha_spFF_Body_0(rnfo);
}
} else {
- if (fSSE2) {
+ if (m_bUseSSE2) {
Draw_Alpha_spFF_noBody_sse2(rnfo);
} else {
Draw_Alpha_spFF_noBody_0(rnfo);
@@ -1613,13 +1611,13 @@ CRect Rasterizer::Draw(SubPicDesc& spd, CRect& clipRect, byte* pAlphaMask, int x //const long *sw = switchpts;
if (fBody) {
- if (fSSE2) {
+ if (m_bUseSSE2) {
Draw_Alpha_sp_Body_sse2(rnfo);
} else {
Draw_Alpha_sp_Body_0(rnfo);
}
} else {
- if (fSSE2) {
+ if (m_bUseSSE2) {
Draw_Alpha_sp_noBody_sse2(rnfo);
} else {
Draw_Alpha_sp_noBody_0(rnfo);
@@ -1641,7 +1639,7 @@ void Rasterizer::FillSolidRect(SubPicDesc& spd, int x, int y, int nWidth, int nH for (int wy = y; wy < y + nHeight; wy++) {
DWORD* dst = (DWORD*)((BYTE*)spd.bits + spd.pitch * wy) + x;
for (int wt = 0; wt < nWidth; ++wt) {
- if (fSSE2) {
+ if (m_bUseSSE2) {
pixmix_sse2(&dst[wt], lColor, 0x40); // 0x40 because >> 6 in pixmix (to preserve tranparency)
} else {
pixmix(&dst[wt], lColor, 0x40);
diff --git a/src/Subtitles/Rasterizer.h b/src/Subtitles/Rasterizer.h index 092a7e4ea..d624058c4 100644 --- a/src/Subtitles/Rasterizer.h +++ b/src/Subtitles/Rasterizer.h @@ -160,7 +160,7 @@ protected: BYTE* mpPathTypes;
POINT* mpPathPoints;
int mPathPoints;
- bool fSSE2;
+ bool m_bUseSSE2;
private:
struct Edge {
|