[x265] [PATCH] pixel: replace getResidual16 from vector class to intrinsic
yuvaraj at multicorewareinc.com
yuvaraj at multicorewareinc.com
Tue Oct 8 10:49:08 CEST 2013
# HG changeset patch
# User Yuvaraj Venkatesh <yuvaraj at multicorewareinc.com>
# Date 1381221983 -19800
# Tue Oct 08 14:16:23 2013 +0530
# Node ID 96e30370f4d96c7fed69f432027ed3be8e01dcf6
# Parent d71078917df01e92605158a13b45ab35ee7cfc1c
pixel: replace getResidual16 from vector class to intrinsic
diff -r d71078917df0 -r 96e30370f4d9 source/common/vec/pixel8.inc
--- a/source/common/vec/pixel8.inc Mon Oct 07 12:48:32 2013 +0530
+++ b/source/common/vec/pixel8.inc Tue Oct 08 14:16:23 2013 +0530
@@ -27,24 +27,56 @@
/* intrinsics for when pixel type is uint8_t */
-void getResidual16(pixel *fenc, pixel *pred, short *resi, int stride)
-{
- Vec16uc f, p;
- Vec8s r;
-
- for (int y = 0; y < 16; y++)
- {
- f.load_a(fenc);
- p.load_a(pred);
- r = extend_low(f) - extend_low(p);
- r.store(resi);
- r = extend_high(f) - extend_high(p);
- r.store(resi + 8);
-
- fenc += stride;
- pred += stride;
- resi += stride;
- }
+void getResidual16(pixel *fenc, pixel *pred, short *resi, int stride)
+{
+ __m128i T00, T01, T02, T03, T04;
+
+#define RESIDUAL_16x4(BASE) \
+ T00 = _mm_load_si128((__m128i*)(fenc + (BASE + 0) * stride)); \
+ T01 = _mm_load_si128((__m128i*)(pred + (BASE + 0) * stride)); \
+ T02 = _mm_unpacklo_epi8(T00, _mm_setzero_si128()); \
+ T03 = _mm_unpacklo_epi8(T01, _mm_setzero_si128()); \
+ T04 = _mm_sub_epi16(T02, T03); \
+ _mm_store_si128((__m128i*)(resi + (BASE + 0) * stride), T04); \
+ T02 = _mm_unpackhi_epi8(T00, _mm_setzero_si128()); \
+ T03 = _mm_unpackhi_epi8(T01, _mm_setzero_si128()); \
+ T04 = _mm_sub_epi16(T02, T03); \
+ _mm_store_si128((__m128i*)(resi + 8 + (BASE + 0) * stride), T04); \
+ T00 = _mm_load_si128((__m128i*)(fenc + (BASE + 1) * stride)); \
+ T01 = _mm_load_si128((__m128i*)(pred + (BASE + 1) * stride)); \
+ T02 = _mm_unpacklo_epi8(T00, _mm_setzero_si128()); \
+ T03 = _mm_unpacklo_epi8(T01, _mm_setzero_si128()); \
+ T04 = _mm_sub_epi16(T02, T03); \
+ _mm_store_si128((__m128i*)(resi + (BASE + 1) * stride), T04); \
+ T02 = _mm_unpackhi_epi8(T00, _mm_setzero_si128()); \
+ T03 = _mm_unpackhi_epi8(T01, _mm_setzero_si128()); \
+ T04 = _mm_sub_epi16(T02, T03); \
+ _mm_store_si128((__m128i*)(resi + 8 + (BASE + 1) * stride), T04); \
+ T00 = _mm_load_si128((__m128i*)(fenc + (BASE + 2) * stride)); \
+ T01 = _mm_load_si128((__m128i*)(pred + (BASE + 2) * stride)); \
+ T02 = _mm_unpacklo_epi8(T00, _mm_setzero_si128()); \
+ T03 = _mm_unpacklo_epi8(T01, _mm_setzero_si128()); \
+ T04 = _mm_sub_epi16(T02, T03); \
+ _mm_store_si128((__m128i*)(resi + (BASE + 2) * stride), T04); \
+ T02 = _mm_unpackhi_epi8(T00, _mm_setzero_si128()); \
+ T03 = _mm_unpackhi_epi8(T01, _mm_setzero_si128()); \
+ T04 = _mm_sub_epi16(T02, T03); \
+ _mm_store_si128((__m128i*)(resi + 8 + (BASE + 2) * stride), T04); \
+ T00 = _mm_load_si128((__m128i*)(fenc + (BASE + 3) * stride)); \
+ T01 = _mm_load_si128((__m128i*)(pred + (BASE + 3) * stride)); \
+ T02 = _mm_unpacklo_epi8(T00, _mm_setzero_si128()); \
+ T03 = _mm_unpacklo_epi8(T01, _mm_setzero_si128()); \
+ T04 = _mm_sub_epi16(T02, T03); \
+ _mm_store_si128((__m128i*)(resi + (BASE + 3) * stride), T04); \
+ T02 = _mm_unpackhi_epi8(T00, _mm_setzero_si128()); \
+ T03 = _mm_unpackhi_epi8(T01, _mm_setzero_si128()); \
+ T04 = _mm_sub_epi16(T02, T03); \
+ _mm_store_si128((__m128i*)(resi + 8 + (BASE + 3) * stride), T04)
+
+ RESIDUAL_16x4(0);
+ RESIDUAL_16x4(4);
+ RESIDUAL_16x4(8);
+ RESIDUAL_16x4(12);
}
void getResidual32(pixel *fenc, pixel *pred, short *resi, int stride)
More information about the x265-devel
mailing list