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:
authorkasper93 <kasper93@gmail.com>2014-07-08 07:57:03 +0400
committerkasper93 <kasper93@gmail.com>2014-07-10 11:45:44 +0400
commit231f8d9f38e23ef3a409a28d6368dab5c63a4e15 (patch)
treed519a5f96207d9519e58ff1cc27e0af84c3c804c /src/Subtitles/RTS.cpp
parentdd44bd9d6260d9202d22fffa92f0d266f9d2d34f (diff)
RTS: Use SSE2 conversion for rounding.
Diffstat (limited to 'src/Subtitles/RTS.cpp')
-rw-r--r--src/Subtitles/RTS.cpp23
1 files changed, 9 insertions, 14 deletions
diff --git a/src/Subtitles/RTS.cpp b/src/Subtitles/RTS.cpp
index 2d3e91dc1..b40c5d4fe 100644
--- a/src/Subtitles/RTS.cpp
+++ b/src/Subtitles/RTS.cpp
@@ -259,10 +259,8 @@ void CWord::Transform_C(const CPoint& org)
y = yy * yzoomf / (zz + yzoomf);
// round to integer
- double xro = (x < 0.0) ? -0.5 : 0.5;
- double yro = (y < 0.0) ? -0.5 : 0.5;
- mpPathPoints[i].x = static_cast<LONG>(x + xro) + org.x;
- mpPathPoints[i].y = static_cast<LONG>(y + yro) + org.y;
+ mpPathPoints[i].x = std::lround(x) + org.x;
+ mpPathPoints[i].y = std::lround(y) + org.y;
}
}
@@ -397,25 +395,22 @@ void CWord::Transform_SSE2(const CPoint& org)
__yy = _mm_mul_ps(__yy, __yzoomf); // yy * yzoomf
__pointy = _mm_div_ps(__yy, __tmpzz); // y = (yy * yzoomf) / (zz + yzoomf);
- // mpPathPoints[i].x = (LONG)(x + org.x + 0.5);
- // mpPathPoints[i].y = (LONG)(y + org.y + 0.5);
__pointx = _mm_add_ps(__pointx, __xorg); // x = x + org.x
__pointy = _mm_add_ps(__pointy, __yorg); // y = y + org.y
- __m128 __05 = _mm_set_ps1(0.5);
-
- __pointx = _mm_add_ps(__pointx, __05); // x = x + 0.5
- __pointy = _mm_add_ps(__pointy, __05); // y = y + 0.5
+ // round to integer
+ __m128i __pointxRounded = _mm_cvtps_epi32(__pointx);
+ __m128i __pointyRounded = _mm_cvtps_epi32(__pointy);
if (i == mPathPointsD4) { // last cycle
for (int k = 0; k < mPathPointsM4; k++) {
- mpPathPoints[i * 4 + k].x = static_cast<LONG>(__pointx.m128_f32[3 - k]);
- mpPathPoints[i * 4 + k].y = static_cast<LONG>(__pointy.m128_f32[3 - k]);
+ mpPathPoints[i * 4 + k].x = __pointxRounded.m128i_i32[3 - k];
+ mpPathPoints[i * 4 + k].y = __pointyRounded.m128i_i32[3 - k];
}
} else {
for (int k = 0; k < 4; k++) {
- mpPathPoints[i * 4 + k].x = static_cast<LONG>(__pointx.m128_f32[3 - k]);
- mpPathPoints[i * 4 + k].y = static_cast<LONG>(__pointy.m128_f32[3 - k]);
+ mpPathPoints[i * 4 + k].x = __pointxRounded.m128i_i32[3 - k];
+ mpPathPoints[i * 4 + k].y = __pointyRounded.m128i_i32[3 - k];
}
}
}