History

Merge pull request #1140 from zhilwang/x86_64-downsample

Add X86 64bit asm code for downsample

dongzha committed 12 years ago

Commit da0f65e2 parents 6310017 eaf7d654 files · +1062 −373Browse files

Showing the changes to codec/processing/src (4 of 4 files). Show all

Unified · Split

4 files
  1. codec/processing/src/downsample/downsample.cpp +9 −9
  2. codec/processing/src/downsample/downsample.h +2 −6
  3. codec/processing/src/downsample/downsamplefuncs.cpp +25 −25
  4. codec/processing/src/x86/downsample_bilinear.asm +1026 −333
codec/processing/src/downsample/downsample.cpp+9−9
@@ -57,21 +57,21 @@ void CDownsampling::InitDownsampleFuncs (SDownsampleFuncs& sDownsampleFunc, int · 56 unmodified lines
5757 sDownsampleFunc.pfGeneralRatioLuma = GeneralBilinearFastDownsampler_c;
5858 #if defined(X86_ASM)
5959 if (iCpuFlag & WELS_CPU_SSE) {
60− /* sDownsampleFunc.pfHalfAverage[0] = DyadicBilinearDownsamplerWidthx32_sse;
61− sDownsampleFunc.pfHalfAverage[1] = DyadicBilinearDownsamplerWidthx16_sse;
62− sDownsampleFunc.pfHalfAverage[2] = DyadicBilinearDownsamplerWidthx8_sse;*/
60+ sDownsampleFunc.pfHalfAverage[0] = DyadicBilinearDownsamplerWidthx32_sse;
61+ sDownsampleFunc.pfHalfAverage[1] = DyadicBilinearDownsamplerWidthx16_sse;
62+ sDownsampleFunc.pfHalfAverage[2] = DyadicBilinearDownsamplerWidthx8_sse;
6363 }
6464 if (iCpuFlag & WELS_CPU_SSE2) {
65− // sDownsampleFunc.pfGeneralRatioChroma = GeneralBilinearAccurateDownsamplerWrap_sse2;
66− // sDownsampleFunc.pfGeneralRatioLuma = GeneralBilinearFastDownsamplerWrap_sse2;
65+ sDownsampleFunc.pfGeneralRatioChroma = GeneralBilinearAccurateDownsamplerWrap_sse2;
66+ sDownsampleFunc.pfGeneralRatioLuma = GeneralBilinearFastDownsamplerWrap_sse2;
6767 }
6868 if (iCpuFlag & WELS_CPU_SSSE3) {
69− // sDownsampleFunc.pfHalfAverage[0] = DyadicBilinearDownsamplerWidthx32_ssse3;
70− // sDownsampleFunc.pfHalfAverage[1] = DyadicBilinearDownsamplerWidthx16_ssse3;
69+ sDownsampleFunc.pfHalfAverage[0] = DyadicBilinearDownsamplerWidthx32_ssse3;
70+ sDownsampleFunc.pfHalfAverage[1] = DyadicBilinearDownsamplerWidthx16_ssse3;
7171 }
7272 if (iCpuFlag & WELS_CPU_SSE41) {
73− // sDownsampleFunc.pfHalfAverage[0] = DyadicBilinearDownsamplerWidthx32_sse4;
74− // sDownsampleFunc.pfHalfAverage[1] = DyadicBilinearDownsamplerWidthx16_sse4;
73+ sDownsampleFunc.pfHalfAverage[0] = DyadicBilinearDownsamplerWidthx32_sse4;
74+ sDownsampleFunc.pfHalfAverage[1] = DyadicBilinearDownsamplerWidthx16_sse4;
7575 }
7676 #endif//X86_ASM
7777
codec/processing/src/downsample/downsample.h+2−6
@@ -94,13 +94,9 @@ GeneralDownsampleFunc GeneralBilinearFastDownsamplerWrap_sse2; · 93 unmodified lines
9494 GeneralDownsampleFunc GeneralBilinearAccurateDownsamplerWrap_sse2;
9595
9696 void GeneralBilinearFastDownsampler_sse2 (uint8_t* pDst, const int32_t kiDstStride, const int32_t kiDstWidth,
97− const int32_t kiDstHeight,
98− uint8_t* pSrc, const int32_t kiSrcStride, const int32_t kiSrcWidth, const int32_t kiSrcHeight,
99− const uint32_t kuiScaleX, const uint32_t kuiScaleY);
97+ const int32_t kiDstHeight, uint8_t* pSrc, const int32_t kiSrcStride, const uint32_t kuiScaleX, const uint32_t kuiScaleY);
10098 void GeneralBilinearAccurateDownsampler_sse2 (uint8_t* pDst, const int32_t kiDstStride, const int32_t kiDstWidth,
101− const int32_t kiDstHeight,
102− uint8_t* pSrc, const int32_t kiSrcStride, const int32_t kiSrcWidth, const int32_t kiSrcHeight,
103− const uint32_t kuiScaleX, const uint32_t kuiScaleY);
99+ const int32_t kiDstHeight, uint8_t* pSrc, const int32_t kiSrcStride, const uint32_t kuiScaleX, const uint32_t kuiScaleY);
104100 WELSVP_EXTERN_C_END
105101 #endif
106102
codec/processing/src/downsample/downsamplefuncs.cpp+25−25
@@ -202,31 +202,31 @@ void GeneralBilinearAccurateDownsampler_c (uint8_t* pDst, const int32_t kiDstStr · 201 unmodified lines
202202
203203
204204 #ifdef X86_ASM
205−//void GeneralBilinearFastDownsamplerWrap_sse2 (uint8_t* pDst, const int32_t kiDstStride, const int32_t kiDstWidth,
206−// const int32_t kiDstHeight,
207−// uint8_t* pSrc, const int32_t kiSrcStride, const int32_t kiSrcWidth, const int32_t kiSrcHeight) {
208−// const int32_t kiScaleBitWidth = 16, kiScaleBitHeight = 15;
209−// const uint32_t kuiScaleWidth = (1 << kiScaleBitWidth), kuiScaleHeight = (1 << kiScaleBitHeight);
210−//
211−// uint32_t uiScalex = WELS_ROUND ((float)kiSrcWidth / (float)kiDstWidth * kuiScaleWidth);
212−// uint32_t uiScaley = WELS_ROUND ((float)kiSrcHeight / (float)kiDstHeight * kuiScaleHeight);
213−//
214−// GeneralBilinearFastDownsampler_sse2 (pDst, kiDstStride, kiDstWidth, kiDstHeight,
215−// pSrc, kiSrcStride, kiSrcWidth, kiSrcHeight, uiScalex, uiScaley);
216−//}
217−//
218−//void GeneralBilinearAccurateDownsamplerWrap_sse2 (uint8_t* pDst, const int32_t kiDstStride, const int32_t kiDstWidth,
219−// const int32_t kiDstHeight,
220−// uint8_t* pSrc, const int32_t kiSrcStride, const int32_t kiSrcWidth, const int32_t kiSrcHeight) {
221−// const int32_t kiScaleBit = 15;
222−// const uint32_t kuiScale = (1 << kiScaleBit);
223−//
224−// uint32_t uiScalex = WELS_ROUND ((float)kiSrcWidth / (float)kiDstWidth * kuiScale);
225−// uint32_t uiScaley = WELS_ROUND ((float)kiSrcHeight / (float)kiDstHeight * kuiScale);
226−//
227−// GeneralBilinearAccurateDownsampler_sse2 (pDst, kiDstStride, kiDstWidth, kiDstHeight,
228−// pSrc, kiSrcStride, kiSrcWidth, kiSrcHeight, uiScalex, uiScaley);
229−//}
205+void GeneralBilinearFastDownsamplerWrap_sse2 (uint8_t* pDst, const int32_t kiDstStride, const int32_t kiDstWidth,
206+ const int32_t kiDstHeight,
207+ uint8_t* pSrc, const int32_t kiSrcStride, const int32_t kiSrcWidth, const int32_t kiSrcHeight) {
208+ const int32_t kiScaleBitWidth = 16, kiScaleBitHeight = 15;
209+ const uint32_t kuiScaleWidth = (1 << kiScaleBitWidth), kuiScaleHeight = (1 << kiScaleBitHeight);
210+
211+ uint32_t uiScalex = WELS_ROUND ((float)kiSrcWidth / (float)kiDstWidth * kuiScaleWidth);
212+ uint32_t uiScaley = WELS_ROUND ((float)kiSrcHeight / (float)kiDstHeight * kuiScaleHeight);
213+
214+ GeneralBilinearFastDownsampler_sse2 (pDst, kiDstStride, kiDstWidth, kiDstHeight,
215+ pSrc, kiSrcStride, uiScalex, uiScaley);
216+}
217+
218+void GeneralBilinearAccurateDownsamplerWrap_sse2 (uint8_t* pDst, const int32_t kiDstStride, const int32_t kiDstWidth,
219+ const int32_t kiDstHeight,
220+ uint8_t* pSrc, const int32_t kiSrcStride, const int32_t kiSrcWidth, const int32_t kiSrcHeight) {
221+ const int32_t kiScaleBit = 15;
222+ const uint32_t kuiScale = (1 << kiScaleBit);
223+
224+ uint32_t uiScalex = WELS_ROUND ((float)kiSrcWidth / (float)kiDstWidth * kuiScale);
225+ uint32_t uiScaley = WELS_ROUND ((float)kiSrcHeight / (float)kiDstHeight * kuiScale);
226+
227+ GeneralBilinearAccurateDownsampler_sse2 (pDst, kiDstStride, kiDstWidth, kiDstHeight,
228+ pSrc, kiSrcStride, uiScalex, uiScaley);
229+}
230230 #endif //X86_ASM
231231
232232 #ifdef HAVE_NEON
codec/processing/src/x86/downsample_bilinear.asm+1026−333
@@ -39,7 +39,7 @@ · 38 unmodified lines
3939 ;*
4040 ;*************************************************************************/
4141 %include "asm_inc.asm"
42−%ifdef X86_32
42+
4343 ;***********************************************************************
4444 ; Macros and other preprocessor constants
4545 ;***********************************************************************
@@ -64,6 +64,8 @@ shufb_mask_low: · 18 unmodified lines
6464 db 00h, 80h, 02h, 80h, 04h, 80h, 06h, 80h, 08h, 80h, 0ah, 80h, 0ch, 80h, 0eh, 80h
6565 shufb_mask_high:
6666 db 01h, 80h, 03h, 80h, 05h, 80h, 07h, 80h, 09h, 80h, 0bh, 80h, 0dh, 80h, 0fh, 80h
67+add_extra_half:
68+ dd 16384,0,0,0
6769
6870
6971 ;***********************************************************************
@@ -78,28 +80,36 @@ SECTION .text · 8 unmodified lines
7880 ; const int iSrcWidth, const int iSrcHeight );
7981 ;***********************************************************************
8082 WELS_EXTERN DyadicBilinearDownsamplerWidthx32_sse
81− push ebx
82− push edx
83− push esi
84− push edi
85− push ebp
86−
87− mov edi, [esp+24] ; pDst
88− mov edx, [esp+28] ; iDstStride
89− mov esi, [esp+32] ; pSrc
90− mov ecx, [esp+36] ; iSrcStride
91− mov ebp, [esp+44] ; iSrcHeight
92−
93− sar ebp, $01 ; iSrcHeight >> 1
94−
95−.yloops:
96− mov eax, [esp+40] ; iSrcWidth
97− sar eax, $01 ; iSrcWidth >> 1
98− mov ebx, eax ; iDstWidth restored at ebx
99− sar eax, $04 ; (iSrcWidth >> 1) / 16 ; loop count = num_of_mb
100− neg ebx ; - (iSrcWidth >> 1)
83+%ifdef X86_32
84+ push r6
85+ %assign push_num 1
86+%else
87+ %assign push_num 0
88+%endif
89+ LOAD_6_PARA
90+ SIGN_EXTENSION r1, r1d
91+ SIGN_EXTENSION r3, r3d
92+ SIGN_EXTENSION r4, r4d
93+ SIGN_EXTENSION r5, r5d
94+
95+%ifndef X86_32
96+ push r12
97+ mov r12, r4
98+%endif
99+ sar r5, $01 ; iSrcHeight >> 1
100+
101+.yloops1:
102+%ifdef X86_32
103+ mov r4, arg5
104+%else
105+ mov r4, r12
106+%endif
107+ sar r4, $01 ; iSrcWidth >> 1
108+ mov r6, r4 ; iDstWidth restored at ebx
109+ sar r4, $04 ; (iSrcWidth >> 1) / 16 ; loop count = num_of_mb
110+ neg r6 ; - (iSrcWidth >> 1)
101111 ; each loop = source bandwidth: 32 bytes
102−.xloops:
112+.xloops1:
103113 ; 1st part horizonal loop: x16 bytes
104114 ; mem hi<- ->lo
105115 ;1st Line Src: mm0: d D c C b B a A mm1: h H g G f F e E
@@ -108,10 +118,10 @@ WELS_EXTERN DyadicBilinearDownsamplerWidthx32_sse · 2 unmodified lines
108118 ;: H G F E D C B A, P O N M L K J I
109119 ;: h g f e d c b a, p o n m l k j i
110120 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
111− movq mm0, [esi] ; 1st pSrc line
112− movq mm1, [esi+8] ; 1st pSrc line + 8
113− movq mm2, [esi+ecx] ; 2nd pSrc line
114− movq mm3, [esi+ecx+8] ; 2nd pSrc line + 8
121+ movq mm0, [r2] ; 1st pSrc line
122+ movq mm1, [r2+8] ; 1st pSrc line + 8
123+ movq mm2, [r2+r3] ; 2nd pSrc line
124+ movq mm3, [r2+r3+8] ; 2nd pSrc line + 8
115125
116126 ; to handle mm0, mm1, mm2, mm3
117127 pshufw mm4, mm0, 0d8h ; d D b B c C a A ; 11011000 B
@@ -156,10 +166,10 @@ WELS_EXTERN DyadicBilinearDownsamplerWidthx32_sse · 38 unmodified lines
156166 ;: H G F E D C B A, P O N M L K J I
157167 ;: h g f e d c b a, p o n m l k j i
158168 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
159− movq mm1, [esi+16] ; 1st pSrc line + 16
160− movq mm2, [esi+24] ; 1st pSrc line + 24
161− movq mm3, [esi+ecx+16] ; 2nd pSrc line + 16
162− movq mm4, [esi+ecx+24] ; 2nd pSrc line + 24
169+ movq mm1, [r2+16] ; 1st pSrc line + 16
170+ movq mm2, [r2+24] ; 1st pSrc line + 24
171+ movq mm3, [r2+r3+16] ; 2nd pSrc line + 16
172+ movq mm4, [r2+r3+24] ; 2nd pSrc line + 24
163173
164174 ; to handle mm1, mm2, mm3, mm4
165175 pshufw mm5, mm1, 0d8h ; d D b B c C a A ; 11011000 B
@@ -196,31 +206,33 @@ WELS_EXTERN DyadicBilinearDownsamplerWidthx32_sse · 30 unmodified lines
196206 pavgb mm3, mm7 ; (I+i+1)>>1, .., (P+p+1)>>1, temp_row2
197207 pavgb mm2, mm3 ; (temp_row1+temp_row2+1)>>1, done in another 2nd horizonal part
198208
199− movq [edi ], mm0
200− movq [edi+8], mm2
209+ movq [r0 ], mm0
210+ movq [r0+8], mm2
201211
202212 ; next SMB
203− lea esi, [esi+32]
204− lea edi, [edi+16]
213+ lea r2, [r2+32]
214+ lea r0, [r0+16]
205215
206− dec eax
207− jg near .xloops
216+ dec r4
217+ jg near .xloops1
208218
209219 ; next line
210− lea esi, [esi+2*ecx] ; next end of lines
211− lea esi, [esi+2*ebx] ; reset to base 0 [- 2 * iDstWidth]
212− lea edi, [edi+edx]
213− lea edi, [edi+ebx] ; reset to base 0 [- iDstWidth]
220+ lea r2, [r2+2*r3] ; next end of lines
221+ lea r2, [r2+2*r6] ; reset to base 0 [- 2 * iDstWidth]
222+ lea r0, [r0+r1]
223+ lea r0, [r0+r6] ; reset to base 0 [- iDstWidth]
214224
215− dec ebp
216− jg near .yloops
225+ dec r5
226+ jg near .yloops1
217227
218228 WELSEMMS
219− pop ebp
220− pop edi
221− pop esi
222− pop edx
223− pop ebx
229+%ifndef X86_32
230+ pop r12
231+%endif
232+ LOAD_6_PARA_POP
233+%ifdef X86_32
234+ pop r6
235+%endif
224236 ret
225237
226238 ;***********************************************************************
@@ -229,28 +241,36 @@ WELS_EXTERN DyadicBilinearDownsamplerWidthx32_sse · 2 unmodified lines
229241 ; const int iSrcWidth, const int iSrcHeight );
230242 ;***********************************************************************
231243 WELS_EXTERN DyadicBilinearDownsamplerWidthx16_sse
232− push ebx
233− push edx
234− push esi
235− push edi
236− push ebp
237−
238− mov edi, [esp+24] ; pDst
239− mov edx, [esp+28] ; iDstStride
240− mov esi, [esp+32] ; pSrc
241− mov ecx, [esp+36] ; iSrcStride
242− mov ebp, [esp+44] ; iSrcHeight
243−
244− sar ebp, $01 ; iSrcHeight >> 1
245−
246−.yloops:
247− mov eax, [esp+40] ; iSrcWidth
248− sar eax, $01 ; iSrcWidth >> 1
249− mov ebx, eax ; iDstWidth restored at ebx
250− sar eax, $03 ; (iSrcWidth >> 1) / 8 ; loop count = num_of_mb
251− neg ebx ; - (iSrcWidth >> 1)
244+%ifdef X86_32
245+ push r6
246+ %assign push_num 1
247+%else
248+ %assign push_num 0
249+%endif
250+ LOAD_6_PARA
251+ SIGN_EXTENSION r1, r1d
252+ SIGN_EXTENSION r3, r3d
253+ SIGN_EXTENSION r4, r4d
254+ SIGN_EXTENSION r5, r5d
255+
256+%ifndef X86_32
257+ push r12
258+ mov r12, r4
259+%endif
260+ sar r5, $01 ; iSrcHeight >> 1
261+
262+.yloops2:
263+%ifdef X86_32
264+ mov r4, arg5
265+%else
266+ mov r4, r12
267+%endif
268+ sar r4, $01 ; iSrcWidth >> 1
269+ mov r6, r4 ; iDstWidth restored at ebx
270+ sar r4, $03 ; (iSrcWidth >> 1) / 8 ; loop count = num_of_mb
271+ neg r6 ; - (iSrcWidth >> 1)
252272 ; each loop = source bandwidth: 16 bytes
253−.xloops:
273+.xloops2:
254274 ; 1st part horizonal loop: x16 bytes
255275 ; mem hi<- ->lo
256276 ;1st Line Src: mm0: d D c C b B a A mm1: h H g G f F e E
@@ -259,10 +279,10 @@ WELS_EXTERN DyadicBilinearDownsamplerWidthx16_sse · 2 unmodified lines
259279 ;: H G F E D C B A, P O N M L K J I
260280 ;: h g f e d c b a, p o n m l k j i
261281 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
262− movq mm0, [esi] ; 1st pSrc line
263− movq mm1, [esi+8] ; 1st pSrc line + 8
264− movq mm2, [esi+ecx] ; 2nd pSrc line
265− movq mm3, [esi+ecx+8] ; 2nd pSrc line + 8
282+ movq mm0, [r2] ; 1st pSrc line
283+ movq mm1, [r2+8] ; 1st pSrc line + 8
284+ movq mm2, [r2+r3] ; 2nd pSrc line
285+ movq mm3, [r2+r3+8] ; 2nd pSrc line + 8
266286
267287 ; to handle mm0, mm1, mm2, mm3
268288 pshufw mm4, mm0, 0d8h ; d D b B c C a A ; 11011000 B
@@ -299,30 +319,32 @@ WELS_EXTERN DyadicBilinearDownsamplerWidthx16_sse · 30 unmodified lines
299319 pavgb mm1, mm6 ; (I+i+1)>>1, .., (P+p+1)>>1, temp_row2
300320 pavgb mm0, mm1 ; (temp_row1+temp_row2+1)>>1, pending here and wait another horizonal part done then write memory once
301321
302− movq [edi ], mm0
322+ movq [r0 ], mm0
303323
304324 ; next SMB
305− lea esi, [esi+16]
306− lea edi, [edi+8]
325+ lea r2, [r2+16]
326+ lea r0, [r0+8]
307327
308− dec eax
309− jg near .xloops
328+ dec r4
329+ jg near .xloops2
310330
311331 ; next line
312− lea esi, [esi+2*ecx] ; next end of lines
313− lea esi, [esi+2*ebx] ; reset to base 0 [- 2 * iDstWidth]
314− lea edi, [edi+edx]
315− lea edi, [edi+ebx] ; reset to base 0 [- iDstWidth]
332+ lea r2, [r2+2*r3] ; next end of lines
333+ lea r2, [r2+2*r6] ; reset to base 0 [- 2 * iDstWidth]
334+ lea r0, [r0+r1]
335+ lea r0, [r0+r6] ; reset to base 0 [- iDstWidth]
316336
317− dec ebp
318− jg near .yloops
337+ dec r5
338+ jg near .yloops2
319339
320340 WELSEMMS
321− pop ebp
322− pop edi
323− pop esi
324− pop edx
325− pop ebx
341+%ifndef X86_32
342+ pop r12
343+%endif
344+ LOAD_6_PARA_POP
345+%ifdef X86_32
346+ pop r6
347+%endif
326348 ret
327349
328350 ;***********************************************************************
@@ -331,28 +353,36 @@ WELS_EXTERN DyadicBilinearDownsamplerWidthx16_sse · 2 unmodified lines
331353 ; const int iSrcWidth, const int iSrcHeight );
332354 ;***********************************************************************
333355 WELS_EXTERN DyadicBilinearDownsamplerWidthx8_sse
334− push ebx
335− push edx
336− push esi
337− push edi
338− push ebp
339−
340− mov edi, [esp+24] ; pDst
341− mov edx, [esp+28] ; iDstStride
342− mov esi, [esp+32] ; pSrc
343− mov ecx, [esp+36] ; iSrcStride
344− mov ebp, [esp+44] ; iSrcHeight
345−
346− sar ebp, $01 ; iSrcHeight >> 1
347−
348−.yloops:
349− mov eax, [esp+40] ; iSrcWidth
350− sar eax, $01 ; iSrcWidth >> 1
351− mov ebx, eax ; iDstWidth restored at ebx
352− sar eax, $02 ; (iSrcWidth >> 1) / 4 ; loop count = num_of_mb
353− neg ebx ; - (iSrcWidth >> 1)
356+%ifdef X86_32
357+ push r6
358+ %assign push_num 1
359+%else
360+ %assign push_num 0
361+%endif
362+ LOAD_6_PARA
363+ SIGN_EXTENSION r1, r1d
364+ SIGN_EXTENSION r3, r3d
365+ SIGN_EXTENSION r4, r4d
366+ SIGN_EXTENSION r5, r5d
367+
368+%ifndef X86_32
369+ push r12
370+ mov r12, r4
371+%endif
372+ sar r5, $01 ; iSrcHeight >> 1
373+
374+.yloops3:
375+%ifdef X86_32
376+ mov r4, arg5
377+%else
378+ mov r4, r12
379+%endif
380+ sar r4, $01 ; iSrcWidth >> 1
381+ mov r6, r4 ; iDstWidth restored at ebx
382+ sar r4, $02 ; (iSrcWidth >> 1) / 4 ; loop count = num_of_mb
383+ neg r6 ; - (iSrcWidth >> 1)
354384 ; each loop = source bandwidth: 8 bytes
355−.xloops:
385+.xloops3:
356386 ; 1st part horizonal loop: x8 bytes
357387 ; mem hi<- ->lo
358388 ;1st Line Src: mm0: d D c C b B a A
@@ -361,8 +391,8 @@ WELS_EXTERN DyadicBilinearDownsamplerWidthx8_sse · 2 unmodified lines
361391 ;: H G F E D C B A
362392 ;: h g f e d c b a
363393 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
364− movq mm0, [esi] ; 1st pSrc line
365− movq mm1, [esi+ecx] ; 2nd pSrc line
394+ movq mm0, [r2] ; 1st pSrc line
395+ movq mm1, [r2+r3] ; 2nd pSrc line
366396
367397 ; to handle mm0, mm1, mm2, mm3
368398 pshufw mm2, mm0, 0d8h ; d D b B c C a A ; 11011000 B
@@ -385,30 +415,32 @@ WELS_EXTERN DyadicBilinearDownsamplerWidthx8_sse · 16 unmodified lines
385415 pshufw mm1, mm0, 04eh ; 01001110 B
386416 pavgb mm0, mm1 ; (temp_row1+temp_row2+1)>>1, pending here and wait another horizonal part done then write memory once
387417
388− movd [edi], mm0
418+ movd [r0], mm0
389419
390420 ; next unit
391− lea esi, [esi+8]
392− lea edi, [edi+4]
421+ lea r2, [r2+8]
422+ lea r0, [r0+4]
393423
394− dec eax
395− jg near .xloops
424+ dec r4
425+ jg near .xloops3
396426
397427 ; next line
398− lea esi, [esi+2*ecx] ; next end of lines
399− lea esi, [esi+2*ebx] ; reset to base 0 [- 2 * iDstWidth]
400− lea edi, [edi+edx]
401− lea edi, [edi+ebx] ; reset to base 0 [- iDstWidth]
428+ lea r2, [r2+2*r3] ; next end of lines
429+ lea r2, [r2+2*r6] ; reset to base 0 [- 2 * iDstWidth]
430+ lea r0, [r0+r1]
431+ lea r0, [r0+r6] ; reset to base 0 [- iDstWidth]
402432
403− dec ebp
404− jg near .yloops
433+ dec r5
434+ jg near .yloops3
405435
406436 WELSEMMS
407− pop ebp
408− pop edi
409− pop esi
410− pop edx
411− pop ebx
437+%ifndef X86_32
438+ pop r12
439+%endif
440+ LOAD_6_PARA_POP
441+%ifdef X86_32
442+ pop r6
443+%endif
412444 ret
413445
414446
@@ -420,31 +452,56 @@ WELS_EXTERN DyadicBilinearDownsamplerWidthx8_sse · 5 unmodified lines
420452 ; const int iSrcWidth, const int iSrcHeight );
421453 ;***********************************************************************
422454 WELS_EXTERN DyadicBilinearDownsamplerWidthx32_ssse3
423− push ebx
424− push edx
425− push esi
426− push edi
427− push ebp
428−
429− mov edi, [esp+24] ; pDst
430− mov edx, [esp+28] ; iDstStride
431− mov esi, [esp+32] ; pSrc
432− mov ecx, [esp+36] ; iSrcStride
433− mov ebp, [esp+44] ; iSrcHeight
434−
435− sar ebp, $01 ; iSrcHeight >> 1
455+ ;push ebx
456+ ;push edx
457+ ;push esi
458+ ;push edi
459+ ;push ebp
460+
461+ ;mov edi, [esp+24] ; pDst
462+ ;mov edx, [esp+28] ; iDstStride
463+ ;mov esi, [esp+32] ; pSrc
464+ ;mov ecx, [esp+36] ; iSrcStride
465+ ;mov ebp, [esp+44] ; iSrcHeight
466+%ifdef X86_32
467+ push r6
468+ %assign push_num 1
469+%else
470+ %assign push_num 0
471+%endif
472+ LOAD_6_PARA
473+ PUSH_XMM 8
474+ SIGN_EXTENSION r1, r1d
475+ SIGN_EXTENSION r3, r3d
476+ SIGN_EXTENSION r4, r4d
477+ SIGN_EXTENSION r5, r5d
478+
479+%ifndef X86_32
480+ push r12
481+ mov r12, r4
482+%endif
483+ sar r5, $01 ; iSrcHeight >> 1
436484
437485 movdqa xmm7, [shufb_mask_low] ; mask low
438486 movdqa xmm6, [shufb_mask_high] ; mask high
439487
440−.yloops:
441− mov eax, [esp+40] ; iSrcWidth
442− sar eax, $01 ; iSrcWidth >> 1
443− mov ebx, eax ; iDstWidth restored at ebx
444− sar eax, $04 ; (iSrcWidth >> 1) / 16 ; loop count = num_of_mb
445− neg ebx ; - (iSrcWidth >> 1)
488+.yloops4:
489+ ;mov eax, [esp+40] ; iSrcWidth
490+ ;sar eax, $01 ; iSrcWidth >> 1
491+ ;mov ebx, eax ; iDstWidth restored at ebx
492+ ;sar eax, $04 ; (iSrcWidth >> 1) / 16 ; loop count = num_of_mb
493+ ;neg ebx ; - (iSrcWidth >> 1)
494+%ifdef X86_32
495+ mov r4, arg5
496+%else
497+ mov r4, r12
498+%endif
499+ sar r4, $01 ; iSrcWidth >> 1
500+ mov r6, r4 ; iDstWidth restored at ebx
501+ sar r4, $04 ; (iSrcWidth >> 1) / 16 ; loop count = num_of_mb
502+ neg r6 ; - (iSrcWidth >> 1)
446503 ; each loop = source bandwidth: 32 bytes
447−.xloops:
504+.xloops4:
448505 ; 1st part horizonal loop: x16 bytes
449506 ; mem hi<- ->lo
450507 ;1st Line Src: xmm0: h H g G f F e E d D c C b B a A
@@ -458,10 +515,10 @@ WELS_EXTERN DyadicBilinearDownsamplerWidthx32_ssse3 · 7 unmodified lines
458515 ;: p .. a
459516
460517 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
461− movdqa xmm0, [esi] ; 1st_src_line
462− movdqa xmm1, [esi+16] ; 1st_src_line + 16
463− movdqa xmm2, [esi+ecx] ; 2nd_src_line
464− movdqa xmm3, [esi+ecx+16] ; 2nd_src_line + 16
518+ movdqa xmm0, [r2] ; 1st_src_line
519+ movdqa xmm1, [r2+16] ; 1st_src_line + 16
520+ movdqa xmm2, [r2+r3] ; 2nd_src_line
521+ movdqa xmm3, [r2+r3+16] ; 2nd_src_line + 16
465522
466523 ; packing & avg
467524 movdqa xmm4, xmm0 ; h H g G f F e E d D c C b B a A
@@ -498,29 +555,33 @@ WELS_EXTERN DyadicBilinearDownsamplerWidthx32_ssse3 · 30 unmodified lines
498555 pavgb xmm0, xmm2
499556
500557 ; write pDst
501− movdqa [edi], xmm0
558+ movdqa [r0], xmm0
502559
503560 ; next SMB
504− lea esi, [esi+32]
505− lea edi, [edi+16]
561+ lea r2, [r2+32]
562+ lea r0, [r0+16]
506563
507− dec eax
508− jg near .xloops
564+ dec r4
565+ jg near .xloops4
509566
510567 ; next line
511− lea esi, [esi+2*ecx] ; next end of lines
512− lea esi, [esi+2*ebx] ; reset to base 0 [- 2 * iDstWidth]
513− lea edi, [edi+edx]
514− lea edi, [edi+ebx] ; reset to base 0 [- iDstWidth]
515−
516− dec ebp
517− jg near .yloops
518−
519− pop ebp
520− pop edi
521− pop esi
522− pop edx
523− pop ebx
568+ lea r2, [r2+2*r3] ; next end of lines
569+ lea r2, [r2+2*r6] ; reset to base 0 [- 2 * iDstWidth]
570+ lea r0, [r0+r1]
571+ lea r0, [r0+r6] ; reset to base 0 [- iDstWidth]
572+
573+ dec r5
574+ jg near .yloops4
575+
576+%ifndef X86_32
577+ pop r12
578+%endif
579+
580+ POP_XMM
581+ LOAD_6_PARA_POP
582+%ifdef X86_32
583+ pop r6
584+%endif
524585 ret
525586
526587 ;***********************************************************************
@@ -529,30 +590,39 @@ WELS_EXTERN DyadicBilinearDownsamplerWidthx32_ssse3 · 2 unmodified lines
529590 ; const int iSrcWidth, const int iSrcHeight );
530591 ;***********************************************************************
531592 WELS_EXTERN DyadicBilinearDownsamplerWidthx16_ssse3
532− push ebx
533− push edx
534− push esi
535− push edi
536− push ebp
537−
538− mov edi, [esp+24] ; pDst
539− mov edx, [esp+28] ; iDstStride
540− mov esi, [esp+32] ; pSrc
541− mov ecx, [esp+36] ; iSrcStride
542− mov ebp, [esp+44] ; iSrcHeight
543−
544− sar ebp, $01 ; iSrcHeight >> 1
545− movdqa xmm7, [shufb_mask_low] ; mask low
546− movdqa xmm6, [shufb_mask_high] ; mask high
593+%ifdef X86_32
594+ push r6
595+ %assign push_num 1
596+%else
597+ %assign push_num 0
598+%endif
599+ LOAD_6_PARA
600+ PUSH_XMM 6
601+ SIGN_EXTENSION r1, r1d
602+ SIGN_EXTENSION r3, r3d
603+ SIGN_EXTENSION r4, r4d
604+ SIGN_EXTENSION r5, r5d
605+
606+%ifndef X86_32
607+ push r12
608+ mov r12, r4
609+%endif
610+ sar r5, $01 ; iSrcHeight >> 1
611+ movdqa xmm5, [shufb_mask_low] ; mask low
612+ movdqa xmm4, [shufb_mask_high] ; mask high
547613
548−.yloops:
549− mov eax, [esp+40] ; iSrcWidth
550− sar eax, $01 ; iSrcWidth >> 1
551− mov ebx, eax ; iDstWidth restored at ebx
552− sar eax, $03 ; (iSrcWidth >> 1) / 8 ; loop count = num_of_mb
553− neg ebx ; - (iSrcWidth >> 1)
614+.yloops5:
615+%ifdef X86_32
616+ mov r4, arg5
617+%else
618+ mov r4, r12
619+%endif
620+ sar r4, $01 ; iSrcWidth >> 1
621+ mov r6, r4 ; iDstWidth restored at ebx
622+ sar r4, $03 ; (iSrcWidth >> 1) / 8 ; loop count = num_of_mb
623+ neg r6 ; - (iSrcWidth >> 1)
554624 ; each loop = source bandwidth: 16 bytes
555−.xloops:
625+.xloops5:
556626 ; horizonal loop: x16 bytes by source
557627 ; mem hi<- ->lo
558628 ;1st line pSrc: xmm0: h H g G f F e E d D c C b B a A
@@ -562,21 +632,21 @@ WELS_EXTERN DyadicBilinearDownsamplerWidthx16_ssse3 · 3 unmodified lines
562632 ;: h g f e d c b a, p o n m l k j i
563633
564634 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
565− movdqa xmm0, [esi] ; 1st_src_line
566− movdqa xmm1, [esi+ecx] ; 2nd_src_line
635+ movdqa xmm0, [r2] ; 1st_src_line
636+ movdqa xmm1, [r2+r3] ; 2nd_src_line
567637
568638 ; packing & avg
569639 movdqa xmm2, xmm0 ; h H g G f F e E d D c C b B a A
570− pshufb xmm0, xmm7 ; 0 H 0 G 0 F 0 E 0 D 0 C 0 B 0 A
571− pshufb xmm2, xmm6 ; 0 h 0 g 0 f 0 e 0 d 0 c 0 b 0 a
640+ pshufb xmm0, xmm5 ; 0 H 0 G 0 F 0 E 0 D 0 C 0 B 0 A
641+ pshufb xmm2, xmm4 ; 0 h 0 g 0 f 0 e 0 d 0 c 0 b 0 a
572642 ; another implementation for xmm2 high bits
573643 ; psubb xmm2, xmm0 ; h 0 g 0 f 0 e 0 d 0 c 0 b 0 a 0
574644 ; psrlw xmm2, 8 ; 0 h 0 g 0 f 0 e 0 d 0 c 0 b 0 a
575645 pavgb xmm0, xmm2
576646
577647 movdqa xmm3, xmm1
578− pshufb xmm1, xmm7
579− pshufb xmm3, xmm6
648+ pshufb xmm1, xmm5
649+ pshufb xmm3, xmm4
580650 ; psubb xmm3, xmm1
581651 ; psrlw xmm3, 8
582652 pavgb xmm1, xmm3
@@ -585,29 +655,32 @@ WELS_EXTERN DyadicBilinearDownsamplerWidthx16_ssse3 · 2 unmodified lines
585655 packuswb xmm0, xmm1
586656
587657 ; write pDst
588− movq [edi], xmm0
658+ movq [r0], xmm0
589659
590660 ; next SMB
591− lea esi, [esi+16]
592− lea edi, [edi+8]
661+ lea r2, [r2+16]
662+ lea r0, [r0+8]
593663
594− dec eax
595− jg near .xloops
664+ dec r4
665+ jg near .xloops5
596666
597− ; next line
598− lea esi, [esi+2*ecx] ; next end of lines
599− lea esi, [esi+2*ebx] ; reset to base 0 [- 2 * iDstWidth]
600− lea edi, [edi+edx]
601− lea edi, [edi+ebx] ; reset to base 0 [- iDstWidth]
602−
603− dec ebp
604− jg near .yloops
605−
606− pop ebp
607− pop edi
608− pop esi
609− pop edx
610− pop ebx
667+ lea r2, [r2+2*r3] ; next end of lines
668+ lea r2, [r2+2*r6] ; reset to base 0 [- 2 * iDstWidth]
669+ lea r0, [r0+r1]
670+ lea r0, [r0+r6] ; reset to base 0 [- iDstWidth]
671+
672+ dec r5
673+ jg near .yloops5
674+
675+%ifndef X86_32
676+ pop r12
677+%endif
678+
679+ POP_XMM
680+ LOAD_6_PARA_POP
681+%ifdef X86_32
682+ pop r6
683+%endif
611684 ret
612685
613686 ; got about 65% improvement over DyadicBilinearDownsamplerWidthx32_sse
@@ -617,31 +690,40 @@ WELS_EXTERN DyadicBilinearDownsamplerWidthx16_ssse3 · 3 unmodified lines
617690 ; const int iSrcWidth, const int iSrcHeight );
618691 ;***********************************************************************
619692 WELS_EXTERN DyadicBilinearDownsamplerWidthx32_sse4
620− push ebx
621− push edx
622− push esi
623− push edi
624− push ebp
625−
626− mov edi, [esp+24] ; pDst
627− mov edx, [esp+28] ; iDstStride
628− mov esi, [esp+32] ; pSrc
629− mov ecx, [esp+36] ; iSrcStride
630− mov ebp, [esp+44] ; iSrcHeight
631−
632− sar ebp, $01 ; iSrcHeight >> 1
693+%ifdef X86_32
694+ push r6
695+ %assign push_num 1
696+%else
697+ %assign push_num 0
698+%endif
699+ LOAD_6_PARA
700+ PUSH_XMM 8
701+ SIGN_EXTENSION r1, r1d
702+ SIGN_EXTENSION r3, r3d
703+ SIGN_EXTENSION r4, r4d
704+ SIGN_EXTENSION r5, r5d
705+
706+%ifndef X86_32
707+ push r12
708+ mov r12, r4
709+%endif
710+ sar r5, $01 ; iSrcHeight >> 1
633711
634712 movdqa xmm7, [shufb_mask_low] ; mask low
635713 movdqa xmm6, [shufb_mask_high] ; mask high
636714
637−.yloops:
638− mov eax, [esp+40] ; iSrcWidth
639− sar eax, $01 ; iSrcWidth >> 1
640− mov ebx, eax ; iDstWidth restored at ebx
641− sar eax, $04 ; (iSrcWidth >> 1) / 16 ; loop count = num_of_mb
642− neg ebx ; - (iSrcWidth >> 1)
715+.yloops6:
716+%ifdef X86_32
717+ mov r4, arg5
718+%else
719+ mov r4, r12
720+%endif
721+ sar r4, $01 ; iSrcWidth >> 1
722+ mov r6, r4 ; iDstWidth restored at ebx
723+ sar r4, $04 ; (iSrcWidth >> 1) / 16 ; loop count = num_of_mb
724+ neg r6 ; - (iSrcWidth >> 1)
643725 ; each loop = source bandwidth: 32 bytes
644−.xloops:
726+.xloops6:
645727 ; 1st part horizonal loop: x16 bytes
646728 ; mem hi<- ->lo
647729 ;1st Line Src: xmm0: h H g G f F e E d D c C b B a A
@@ -655,10 +737,10 @@ WELS_EXTERN DyadicBilinearDownsamplerWidthx32_sse4 · 7 unmodified lines
655737 ;: p .. a
656738
657739 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
658− movntdqa xmm0, [esi] ; 1st_src_line
659− movntdqa xmm1, [esi+16] ; 1st_src_line + 16
660− movntdqa xmm2, [esi+ecx] ; 2nd_src_line
661− movntdqa xmm3, [esi+ecx+16] ; 2nd_src_line + 16
740+ movntdqa xmm0, [r2] ; 1st_src_line
741+ movntdqa xmm1, [r2+16] ; 1st_src_line + 16
742+ movntdqa xmm2, [r2+r3] ; 2nd_src_line
743+ movntdqa xmm3, [r2+r3+16] ; 2nd_src_line + 16
662744
663745 ; packing & avg
664746 movdqa xmm4, xmm0 ; h H g G f F e E d D c C b B a A
@@ -694,29 +776,32 @@ WELS_EXTERN DyadicBilinearDownsamplerWidthx32_sse4 · 29 unmodified lines
694776 pavgb xmm0, xmm2
695777
696778 ; write pDst
697− movdqa [edi], xmm0
779+ movdqa [r0], xmm0
698780
699781 ; next SMB
700− lea esi, [esi+32]
701− lea edi, [edi+16]
782+ lea r2, [r2+32]
783+ lea r0, [r0+16]
702784
703− dec eax
704− jg near .xloops
785+ dec r4
786+ jg near .xloops6
705787
706− ; next line
707− lea esi, [esi+2*ecx] ; next end of lines
708− lea esi, [esi+2*ebx] ; reset to base 0 [- 2 * iDstWidth]
709− lea edi, [edi+edx]
710− lea edi, [edi+ebx] ; reset to base 0 [- iDstWidth]
711−
712− dec ebp
713− jg near .yloops
714−
715− pop ebp
716− pop edi
717− pop esi
718− pop edx
719− pop ebx
788+ lea r2, [r2+2*r3] ; next end of lines
789+ lea r2, [r2+2*r6] ; reset to base 0 [- 2 * iDstWidth]
790+ lea r0, [r0+r1]
791+ lea r0, [r0+r6] ; reset to base 0 [- iDstWidth]
792+
793+ dec r5
794+ jg near .yloops6
795+
796+%ifndef X86_32
797+ pop r12
798+%endif
799+
800+ POP_XMM
801+ LOAD_6_PARA_POP
802+%ifdef X86_32
803+ pop r6
804+%endif
720805 ret
721806
722807 ;***********************************************************************
@@ -725,30 +810,39 @@ WELS_EXTERN DyadicBilinearDownsamplerWidthx32_sse4 · 2 unmodified lines
725810 ; const int iSrcWidth, const int iSrcHeight );
726811 ;***********************************************************************
727812 WELS_EXTERN DyadicBilinearDownsamplerWidthx16_sse4
728− push ebx
729− push edx
730− push esi
731− push edi
732− push ebp
733−
734− mov edi, [esp+24] ; pDst
735− mov edx, [esp+28] ; iDstStride
736− mov esi, [esp+32] ; pSrc
737− mov ecx, [esp+36] ; iSrcStride
738− mov ebp, [esp+44] ; iSrcHeight
739−
740− sar ebp, $01 ; iSrcHeight >> 1
741− movdqa xmm7, [shufb_mask_low] ; mask low
742− movdqa xmm6, [shufb_mask_high] ; mask high
813+%ifdef X86_32
814+ push r6
815+ %assign push_num 1
816+%else
817+ %assign push_num 0
818+%endif
819+ LOAD_6_PARA
820+ PUSH_XMM 6
821+ SIGN_EXTENSION r1, r1d
822+ SIGN_EXTENSION r3, r3d
823+ SIGN_EXTENSION r4, r4d
824+ SIGN_EXTENSION r5, r5d
825+
826+%ifndef X86_32
827+ push r12
828+ mov r12, r4
829+%endif
830+ sar r5, $01 ; iSrcHeight >> 1
831+ movdqa xmm5, [shufb_mask_low] ; mask low
832+ movdqa xmm4, [shufb_mask_high] ; mask high
743833
744−.yloops:
745− mov eax, [esp+40] ; iSrcWidth
746− sar eax, $01 ; iSrcWidth >> 1
747− mov ebx, eax ; iDstWidth restored at ebx
748− sar eax, $03 ; (iSrcWidth >> 1) / 8 ; loop count = num_of_mb
749− neg ebx ; - (iSrcWidth >> 1)
834+.yloops7:
835+%ifdef X86_32
836+ mov r4, arg5
837+%else
838+ mov r4, r12
839+%endif
840+ sar r4, $01 ; iSrcWidth >> 1
841+ mov r6, r4 ; iDstWidth restored at ebx
842+ sar r4, $03 ; (iSrcWidth >> 1) / 8 ; loop count = num_of_mb
843+ neg r6 ; - (iSrcWidth >> 1)
750844 ; each loop = source bandwidth: 16 bytes
751−.xloops:
845+.xloops7:
752846 ; horizonal loop: x16 bytes by source
753847 ; mem hi<- ->lo
754848 ;1st line pSrc: xmm0: h H g G f F e E d D c C b B a A
@@ -758,20 +852,20 @@ WELS_EXTERN DyadicBilinearDownsamplerWidthx16_sse4 · 3 unmodified lines
758852 ;: h g f e d c b a, p o n m l k j i
759853
760854 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
761− movntdqa xmm0, [esi] ; 1st_src_line
762− movntdqa xmm1, [esi+ecx] ; 2nd_src_line
855+ movntdqa xmm0, [r2] ; 1st_src_line
856+ movntdqa xmm1, [r2+r3] ; 2nd_src_line
763857
764858 ; packing & avg
765859 movdqa xmm2, xmm0 ; h H g G f F e E d D c C b B a A
766− pshufb xmm0, xmm7 ; 0 H 0 G 0 F 0 E 0 D 0 C 0 B 0 A
767− pshufb xmm2, xmm6 ; 0 h 0 g 0 f 0 e 0 d 0 c 0 b 0 a
860+ pshufb xmm0, xmm5 ; 0 H 0 G 0 F 0 E 0 D 0 C 0 B 0 A
861+ pshufb xmm2, xmm4 ; 0 h 0 g 0 f 0 e 0 d 0 c 0 b 0 a
768862 ; psubb xmm2, xmm0 ; h 0 g 0 f 0 e 0 d 0 c 0 b 0 a 0
769863 ; psrlw xmm2, 8 ; 0 h 0 g 0 f 0 e 0 d 0 c 0 b 0 a
770864 pavgb xmm0, xmm2
771865
772866 movdqa xmm3, xmm1
773− pshufb xmm1, xmm7
774− pshufb xmm3, xmm6
867+ pshufb xmm1, xmm5
868+ pshufb xmm3, xmm4
775869 ; psubb xmm3, xmm1
776870 ; psrlw xmm3, 8
777871 pavgb xmm1, xmm3
@@ -780,38 +874,40 @@ WELS_EXTERN DyadicBilinearDownsamplerWidthx16_sse4 · 2 unmodified lines
780874 packuswb xmm0, xmm1
781875
782876 ; write pDst
783− movq [edi], xmm0
877+ movq [r0], xmm0
784878
785879 ; next SMB
786− lea esi, [esi+16]
787− lea edi, [edi+8]
880+ lea r2, [r2+16]
881+ lea r0, [r0+8]
788882
789− dec eax
790− jg near .xloops
883+ dec r4
884+ jg near .xloops7
791885
792886 ; next line
793− lea esi, [esi+2*ecx] ; next end of lines
794− lea esi, [esi+2*ebx] ; reset to base 0 [- 2 * iDstWidth]
795− lea edi, [edi+edx]
796− lea edi, [edi+ebx] ; reset to base 0 [- iDstWidth]
797−
798− dec ebp
799− jg near .yloops
800−
801− pop ebp
802− pop edi
803− pop esi
804− pop edx
805− pop ebx
806− ret
887+ lea r2, [r2+2*r3] ; next end of lines
888+ lea r2, [r2+2*r6] ; reset to base 0 [- 2 * iDstWidth]
889+ lea r0, [r0+r1]
890+ lea r0, [r0+r6] ; reset to base 0 [- iDstWidth]
807891
892+ dec r5
893+ jg near .yloops7
808894
895+%ifndef X86_32
896+ pop r12
897+%endif
809898
899+ POP_XMM
900+ LOAD_6_PARA_POP
901+%ifdef X86_32
902+ pop r6
903+%endif
904+ ret
810905
811906
907+%ifdef X86_32
812908 ;**************************************************************************************************************
813909 ;int GeneralBilinearAccurateDownsampler_sse2( unsigned char* pDst, const int iDstStride, const int iDstWidth, const int iDstHeight,
814−; unsigned char* pSrc, const int iSrcStride, const int iSrcWidth, const int iSrcHeight,
910+; unsigned char* pSrc, const int iSrcStride,
815911 ; unsigned int uiScaleX, unsigned int uiScaleY );
816912 ;{
817913 ;**************************************************************************************************************
@@ -822,26 +918,22 @@ WELS_EXTERN GeneralBilinearAccurateDownsampler_sse2 · 4 unmodified lines
822918 push edi
823919 push ebx
824920 %define pushsize 16
825−%define localsize 28
921+%define localsize 16
826922 %define pDstData esp + pushsize + localsize + 4
827923 %define dwDstStride esp + pushsize + localsize + 8
828924 %define dwDstWidth esp + pushsize + localsize + 12
829925 %define dwDstHeight esp + pushsize + localsize + 16
830926 %define pSrcData esp + pushsize + localsize + 20
831927 %define dwSrcStride esp + pushsize + localsize + 24
832−%define dwSrcWidth esp + pushsize + localsize + 28
833−%define dwSrcHeight esp + pushsize + localsize + 32
834−%define scale esp + 0
835−%define uiScaleX esp + pushsize + localsize + 36
836−%define uiScaleY esp + pushsize + localsize + 40
837−%define tmpHeight esp + 12
838−%define yInverse esp + 16
839−%define xInverse esp + 20
840−%define dstStep esp + 24
928+%define uiScaleX esp + pushsize + localsize + 28
929+%define uiScaleY esp + pushsize + localsize + 32
930+%define tmpHeight esp + 0
931+%define yInverse esp + 4
932+%define xInverse esp + 8
933+%define dstStep esp + 12
841934 sub esp, localsize
842935
843936 pxor xmm0, xmm0
844− mov edx, 32767
845937 mov eax, [uiScaleX]
846938 and eax, 32767
847939 mov ebx, eax
@@ -999,7 +1091,6 @@ LAST_ROW_END: · 151 unmodified lines
9991091 %undef dwDstWidth
10001092 %undef dwDstHeight
10011093 %undef dwDstStride
1002−%undef scale
10031094 %undef uiScaleX
10041095 %undef uiScaleY
10051096 %undef tmpHeight
@@ -1013,7 +1104,7 @@ LAST_ROW_END: · 7 unmodified lines
10131104
10141105 ;**************************************************************************************************************
10151106 ;int GeneralBilinearFastDownsampler_sse2( unsigned char* pDst, const int iDstStride, const int iDstWidth, const int iDstHeight,
1016−; unsigned char* pSrc, const int iSrcStride, const int iSrcWidth, const int iSrcHeight,
1107+; unsigned char* pSrc, const int iSrcStride,
10171108 ; unsigned int uiScaleX, unsigned int uiScaleY );
10181109 ;{
10191110 ;**************************************************************************************************************
@@ -1024,22 +1115,19 @@ WELS_EXTERN GeneralBilinearFastDownsampler_sse2 · 4 unmodified lines
10241115 push edi
10251116 push ebx
10261117 %define pushsize 16
1027−%define localsize 28
1118+%define localsize 16
10281119 %define pDstData esp + pushsize + localsize + 4
10291120 %define dwDstStride esp + pushsize + localsize + 8
10301121 %define dwDstWidth esp + pushsize + localsize + 12
10311122 %define dwDstHeight esp + pushsize + localsize + 16
10321123 %define pSrcData esp + pushsize + localsize + 20
10331124 %define dwSrcStride esp + pushsize + localsize + 24
1034−%define dwSrcWidth esp + pushsize + localsize + 28
1035−%define dwSrcHeight esp + pushsize + localsize + 32
1036−%define scale esp + 0
1037−%define uiScaleX esp + pushsize + localsize + 36
1038−%define uiScaleY esp + pushsize + localsize + 40
1039−%define tmpHeight esp + 12
1040−%define yInverse esp + 16
1041−%define xInverse esp + 20
1042−%define dstStep esp + 24
1125+%define uiScaleX esp + pushsize + localsize + 28
1126+%define uiScaleY esp + pushsize + localsize + 32
1127+%define tmpHeight esp + 0
1128+%define yInverse esp + 4
1129+%define xInverse esp + 8
1130+%define dstStep esp + 12
10431131 sub esp, localsize
10441132
10451133 pxor xmm0, xmm0
@@ -1191,10 +1279,7 @@ FAST_LAST_ROW_END: · 145 unmodified lines
11911279 %undef dwSrcHeight
11921280 %undef dwSrcStride
11931281 %undef pDstData
1194−%undef dwDstWidth
1195−%undef dwDstHeight
11961282 %undef dwDstStride
1197−%undef scale
11981283 %undef uiScaleX
11991284 %undef uiScaleY
12001285 %undef tmpHeight
@@ -1202,4 +1287,612 @@ FAST_LAST_ROW_END: · 1 unmodified line
12021287 %undef xInverse
12031288 %undef dstStep
12041289 ret
1290+
1291+%elifdef WIN64
1292+
1293+;**************************************************************************************************************
1294+;int GeneralBilinearAccurateDownsampler_sse2( unsigned char* pDst, const int iDstStride, const int iDstWidth, const int iDstHeight,
1295+; unsigned char* pSrc, const int iSrcStride,
1296+; unsigned int uiScaleX, unsigned int uiScaleY );
1297+;{
1298+;**************************************************************************************************************
1299+
1300+WELS_EXTERN GeneralBilinearAccurateDownsampler_sse2
1301+ push r12
1302+ push r13
1303+ push r14
1304+ push r15
1305+ push rsi
1306+ push rdi
1307+ push rbx
1308+ push rbp
1309+ %assign push_num 8
1310+ LOAD_7_PARA
1311+ PUSH_XMM 8
1312+ SIGN_EXTENSION r1, r1d
1313+ SIGN_EXTENSION r2, r2d
1314+ SIGN_EXTENSION r3, r3d
1315+ SIGN_EXTENSION r5, r5d
1316+ SIGN_EXTENSION r6, r6d
1317+
1318+ pxor xmm0, xmm0
1319+ mov r12d, r6d
1320+ and r12d, 32767
1321+ mov r13d, r12d
1322+ neg r13d
1323+ and r13d, 32767
1324+ movd xmm1, r12d ; uinc(uiScaleX mod 32767)
1325+ movd xmm2, r13d ; -uinc
1326+ psllq xmm1, 32
1327+ por xmm1, xmm2 ; 0 0 uinc -uinc (dword)
1328+ pshufd xmm7, xmm1, 01000100b ; xmm7: uinc -uinc uinc -uinc
1329+
1330+ mov r12, arg8
1331+ SIGN_EXTENSION r12, r12d
1332+ mov rbp, r12
1333+ and r12d, 32767
1334+ mov r13d, r12d
1335+ neg r13d
1336+ and r13d, 32767
1337+ movd xmm6, r12d ; vinc(uiScaleY mod 32767)
1338+ movd xmm2, r13d ; -vinc
1339+ psllq xmm6, 32
1340+ por xmm6, xmm2 ; 0 0 vinc -vinc (dword)
1341+ pshufd xmm6, xmm6, 01010000b ; xmm6: vinc vinc -vinc -vinc
1342+
1343+ mov r12d, 40003fffh
1344+ movd xmm5, r12d
1345+ punpcklwd xmm5, xmm0 ; 16384 16383
1346+ pshufd xmm5, xmm5, 01000100b ; xmm5: 16384 16383 16384 16383
1347+
1348+DOWNSAMPLE:
1349+ sub r1, r2 ; stride - width
1350+ dec r3
1351+ mov r14,16384
1352+ pshufd xmm4, xmm5, 01010000b ; initial v to 16384 16384 16383 16383
1353+
1354+HEIGHT:
1355+ ;mov r12, r4
1356+ mov r12, r14
1357+ shr r12, 15
1358+ imul r12, r5
1359+ add r12, r4 ; get current row address
1360+ mov r13, r12
1361+ add r13, r5
1362+
1363+ mov r15, 16384
1364+ mov rsi, r2
1365+ dec rsi
1366+ movdqa xmm3, xmm5 ; initial u to 16384 16383 16384 16383
1367+
1368+WIDTH:
1369+ mov rdi, r15
1370+ shr rdi, 15
1371+
1372+ movd xmm1, [r12+rdi] ; xxxxxxba
1373+ movd xmm2, [r13+rdi] ; xxxxxxdc
1374+ pxor xmm0, xmm0
1375+ punpcklwd xmm1, xmm2 ; xxxxdcba
1376+ punpcklbw xmm1, xmm0 ; 0d0c0b0a
1377+ punpcklwd xmm1, xmm0 ; 000d000c000b000a
1378+
1379+ movdqa xmm2, xmm4 ; xmm2: vv(1-v)(1-v) tmpv
1380+ pmaddwd xmm2, xmm3 ; mul u(1-u)u(1-u) on xmm2
1381+ movdqa xmm0, xmm2
1382+ pmuludq xmm2, xmm1
1383+ psrlq xmm0, 32
1384+ psrlq xmm1, 32
1385+ pmuludq xmm0, xmm1
1386+ paddq xmm2, xmm0
1387+ pshufd xmm1, xmm2, 00001110b
1388+ paddq xmm2, xmm1
1389+ psrlq xmm2, 29
1390+
1391+ movd ebx, xmm2
1392+ inc ebx
1393+ shr ebx, 1
1394+ mov [r0], bl
1395+ inc r0
1396+
1397+ add r15, r6
1398+ paddw xmm3, xmm7 ; inc u
1399+ psllw xmm3, 1
1400+ psrlw xmm3, 1
1401+
1402+ dec rsi
1403+ jg WIDTH
1404+
1405+WIDTH_END:
1406+ shr r15, 15
1407+ mov bl, [r12+r15]
1408+ mov [r0],bl
1409+ inc r0
1410+ add r14, rbp
1411+ add r0, r1
1412+
1413+ paddw xmm4, xmm6 ; inc v
1414+ psllw xmm4, 1
1415+ psrlw xmm4, 1
1416+
1417+ dec r3
1418+ jg HEIGHT
1419+
1420+LAST_ROW:
1421+ shr r14, 15
1422+ imul r14, r5
1423+ add r4, r14
1424+ mov r15, 16384
1425+
1426+LAST_ROW_WIDTH:
1427+ mov rdi, r15
1428+ shr rdi, 15
1429+ mov bl, [r4+rdi]
1430+ mov [r0],bl
1431+ inc r0
1432+
1433+ add r15, r6
1434+ dec r2
1435+ jg LAST_ROW_WIDTH
1436+
1437+LAST_ROW_END:
1438+
1439+ POP_XMM
1440+ pop rbp
1441+ pop rbx
1442+ pop rdi
1443+ pop rsi
1444+ pop r15
1445+ pop r14
1446+ pop r13
1447+ pop r12
1448+ ret
1449+
1450+;**************************************************************************************************************
1451+;int GeneralBilinearFastDownsampler_sse2( unsigned char* pDst, const int iDstStride, const int iDstWidth, const int iDstHeight,
1452+; unsigned char* pSrc, const int iSrcStride,
1453+; unsigned int uiScaleX, unsigned int uiScaleY );
1454+;{
1455+;**************************************************************************************************************
1456+
1457+WELS_EXTERN GeneralBilinearFastDownsampler_sse2
1458+ push r12
1459+ push r13
1460+ push r14
1461+ push r15
1462+ push rsi
1463+ push rdi
1464+ push rbx
1465+ push rbp
1466+ %assign push_num 8
1467+ LOAD_7_PARA
1468+ PUSH_XMM 8
1469+ SIGN_EXTENSION r1, r1d
1470+ SIGN_EXTENSION r2, r2d
1471+ SIGN_EXTENSION r3, r3d
1472+ SIGN_EXTENSION r5, r5d
1473+ SIGN_EXTENSION r6, r6d
1474+
1475+ pxor xmm0, xmm0
1476+ mov r12d, r6d
1477+ and r12d, 65535
1478+ mov r13d, r12d
1479+ neg r13d
1480+ and r13d, 65535
1481+ movd xmm1, r12d ; uinc(uiScaleX mod 65536)
1482+ movd xmm2, r13d ; -uinc
1483+ psllq xmm1, 32
1484+ por xmm1, xmm2 ; 0 uinc 0 -uinc
1485+ pshuflw xmm7, xmm1, 10001000b ; xmm7: uinc -uinc uinc -uinc
1486+
1487+ mov r12, arg8
1488+ SIGN_EXTENSION r12, r12d
1489+ mov rbp, r12
1490+ and r12d, 32767
1491+ mov r13d, r12d
1492+ neg r13d
1493+ and r13d, 32767
1494+ movd xmm6, r12d ; vinc(uiScaleY mod 32767)
1495+ movd xmm2, r13d ; -vinc
1496+ psllq xmm6, 32
1497+ por xmm6, xmm2 ; 0 vinc 0 -vinc
1498+ pshuflw xmm6, xmm6, 10100000b ; xmm6: vinc vinc -vinc -vinc
1499+
1500+ mov r12d, 80007fffh ; 32768 32767
1501+ movd xmm5, r12d
1502+ pshuflw xmm5, xmm5, 01000100b ; 32768 32767 32768 32767
1503+
1504+FAST_DOWNSAMPLE:
1505+ sub r1, r2 ; stride - width
1506+ dec r3
1507+ mov r14,16384
1508+
1509+ pshuflw xmm4, xmm5, 01010000b
1510+ psrlw xmm4, 1 ; initial v to 16384 16384 16383 16383
1511+
1512+FAST_HEIGHT:
1513+ mov r12, r14
1514+ shr r12, 15
1515+ imul r12, r5
1516+ add r12, r4 ; get current row address
1517+ mov r13, r12
1518+ add r13, r5
1519+
1520+ mov r15, 32768
1521+ mov rsi, r2
1522+ dec rsi
1523+
1524+ movdqa xmm3, xmm5 ; initial u to 32768 32767 32768 32767
1525+
1526+FAST_WIDTH:
1527+ mov rdi, r15
1528+ shr rdi, 16
1529+
1530+ movd xmm1, [r12+rdi] ; xxxxxxba
1531+ movd xmm2, [r13+rdi] ; xxxxxxdc
1532+ punpcklwd xmm1, xmm2 ; xxxxdcba
1533+ punpcklbw xmm1, xmm0 ; 0d0c0b0a
1534+
1535+ movdqa xmm2, xmm4 ; xmm2: vv(1-v)(1-v) tmpv
1536+ pmulhuw xmm2, xmm3 ; mul u(1-u)u(1-u) on xmm2
1537+ pmaddwd xmm2, xmm1
1538+ pshufd xmm1, xmm2, 00000001b
1539+ paddd xmm2, xmm1
1540+ movdqa xmm1, [add_extra_half]
1541+ paddd xmm2, xmm1
1542+ psrld xmm2, 15
1543+
1544+ packuswb xmm2, xmm0
1545+ movd ebx, xmm2
1546+ mov [r0], bl
1547+ inc r0
1548+
1549+ add r15, r6
1550+
1551+ paddw xmm3, xmm7 ; inc u
1552+ dec rsi
1553+ jg FAST_WIDTH
1554+
1555+FAST_WIDTH_END:
1556+ shr r15, 16
1557+ mov bl, [r12+r15]
1558+ mov [r0],bl
1559+ inc r0
1560+ add r14, rbp
1561+ add r0, r1
1562+
1563+ paddw xmm4, xmm6 ; inc v
1564+ psllw xmm4, 1
1565+ psrlw xmm4, 1
1566+
1567+ dec r3
1568+ jg FAST_HEIGHT
1569+
1570+
1571+FAST_LAST_ROW:
1572+ shr r14, 15
1573+ imul r14, r5
1574+ add r4, r14
1575+ mov r15, 32768
1576+
1577+FAST_LAST_ROW_WIDTH:
1578+ mov rdi, r15
1579+ shr rdi, 16
1580+ mov bl, [r4+rdi]
1581+ mov [r0],bl
1582+ inc r0
1583+
1584+ add r15, r6
1585+ dec r2
1586+ jg FAST_LAST_ROW_WIDTH
1587+
1588+FAST_LAST_ROW_END:
1589+
1590+ POP_XMM
1591+ pop rbp
1592+ pop rbx
1593+ pop rdi
1594+ pop rsi
1595+ pop r15
1596+ pop r14
1597+ pop r13
1598+ pop r12
1599+ ret
1600+
1601+%elifdef UNIX64
1602+
1603+;**************************************************************************************************************
1604+;int GeneralBilinearAccurateDownsampler_sse2( unsigned char* pDst, const int iDstStride, const int iDstWidth, const int iDstHeight,
1605+; unsigned char* pSrc, const int iSrcStride,
1606+; unsigned int uiScaleX, unsigned int uiScaleY );
1607+;{
1608+;**************************************************************************************************************
1609+
1610+WELS_EXTERN GeneralBilinearAccurateDownsampler_sse2
1611+ push r12
1612+ push r13
1613+ push r14
1614+ push r15
1615+ push rbx
1616+ push rbp
1617+ %assign push_num 6
1618+ LOAD_7_PARA
1619+ SIGN_EXTENSION r1, r1d
1620+ SIGN_EXTENSION r2, r2d
1621+ SIGN_EXTENSION r3, r3d
1622+ SIGN_EXTENSION r5, r5d
1623+ SIGN_EXTENSION r6, r6d
1624+
1625+ pxor xmm0, xmm0
1626+ mov r12d, r6d
1627+ and r12d, 32767
1628+ mov r13d, r12d
1629+ neg r13d
1630+ and r13d, 32767
1631+ movd xmm1, r12d ; uinc(uiScaleX mod 32767)
1632+ movd xmm2, r13d ; -uinc
1633+ psllq xmm1, 32
1634+ por xmm1, xmm2 ; 0 0 uinc -uinc (dword)
1635+ pshufd xmm7, xmm1, 01000100b ; xmm7: uinc -uinc uinc -uinc
1636+
1637+ mov r12, arg8
1638+ SIGN_EXTENSION r12, r12d
1639+ mov rbp, r12
1640+ and r12d, 32767
1641+ mov r13d, r12d
1642+ neg r13d
1643+ and r13d, 32767
1644+ movd xmm6, r12d ; vinc(uiScaleY mod 32767)
1645+ movd xmm2, r13d ; -vinc
1646+ psllq xmm6, 32
1647+ por xmm6, xmm2 ; 0 0 vinc -vinc (dword)
1648+ pshufd xmm6, xmm6, 01010000b ; xmm6: vinc vinc -vinc -vinc
1649+
1650+ mov r12d, 40003fffh
1651+ movd xmm5, r12d
1652+ punpcklwd xmm5, xmm0 ; 16384 16383
1653+ pshufd xmm5, xmm5, 01000100b ; xmm5: 16384 16383 16384 16383
1654+
1655+DOWNSAMPLE:
1656+ sub r1, r2 ; stride - width
1657+ dec r3
1658+ mov r14,16384
1659+ pshufd xmm4, xmm5, 01010000b ; initial v to 16384 16384 16383 16383
1660+
1661+HEIGHT:
1662+ ;mov r12, r4
1663+ mov r12, r14
1664+ shr r12, 15
1665+ imul r12, r5
1666+ add r12, r4 ; get current row address
1667+ mov r13, r12
1668+ add r13, r5
1669+
1670+ mov r15, 16384
1671+ mov rax, r2
1672+ dec rax
1673+ movdqa xmm3, xmm5 ; initial u to 16384 16383 16384 16383
1674+
1675+WIDTH:
1676+ mov r11, r15
1677+ shr r11, 15
1678+
1679+ movd xmm1, [r12+r11] ; xxxxxxba
1680+ movd xmm2, [r13+r11] ; xxxxxxdc
1681+ pxor xmm0, xmm0
1682+ punpcklwd xmm1, xmm2 ; xxxxdcba
1683+ punpcklbw xmm1, xmm0 ; 0d0c0b0a
1684+ punpcklwd xmm1, xmm0 ; 000d000c000b000a
1685+
1686+ movdqa xmm2, xmm4 ; xmm2: vv(1-v)(1-v) tmpv
1687+ pmaddwd xmm2, xmm3 ; mul u(1-u)u(1-u) on xmm2
1688+ movdqa xmm0, xmm2
1689+ pmuludq xmm2, xmm1
1690+ psrlq xmm0, 32
1691+ psrlq xmm1, 32
1692+ pmuludq xmm0, xmm1
1693+ paddq xmm2, xmm0
1694+ pshufd xmm1, xmm2, 00001110b
1695+ paddq xmm2, xmm1
1696+ psrlq xmm2, 29
1697+
1698+ movd ebx, xmm2
1699+ inc ebx
1700+ shr ebx, 1
1701+ mov [r0], bl
1702+ inc r0
1703+
1704+ add r15, r6
1705+ paddw xmm3, xmm7 ; inc u
1706+ psllw xmm3, 1
1707+ psrlw xmm3, 1
1708+
1709+ dec rax
1710+ jg WIDTH
1711+
1712+WIDTH_END:
1713+ shr r15, 15
1714+ mov bl, [r12+r15]
1715+ mov [r0],bl
1716+ inc r0
1717+ add r14, rbp
1718+ add r0, r1
1719+
1720+ paddw xmm4, xmm6 ; inc v
1721+ psllw xmm4, 1
1722+ psrlw xmm4, 1
1723+
1724+ dec r3
1725+ jg HEIGHT
1726+
1727+LAST_ROW:
1728+ shr r14, 15
1729+ imul r14, r5
1730+ add r4, r14
1731+ mov r15, 16384
1732+
1733+LAST_ROW_WIDTH:
1734+ mov r11, r15
1735+ shr r11, 15
1736+ mov bl, [r4+r11]
1737+ mov [r0],bl
1738+ inc r0
1739+
1740+ add r15, r6
1741+ dec r2
1742+ jg LAST_ROW_WIDTH
1743+
1744+LAST_ROW_END:
1745+
1746+ pop rbp
1747+ pop rbx
1748+ pop r15
1749+ pop r14
1750+ pop r13
1751+ pop r12
1752+ ret
1753+
1754+;**************************************************************************************************************
1755+;int GeneralBilinearFastDownsampler_sse2( unsigned char* pDst, const int iDstStride, const int iDstWidth, const int iDstHeight,
1756+; unsigned char* pSrc, const int iSrcStride,
1757+; unsigned int uiScaleX, unsigned int uiScaleY );
1758+;{
1759+;**************************************************************************************************************
1760+
1761+WELS_EXTERN GeneralBilinearFastDownsampler_sse2
1762+ push r12
1763+ push r13
1764+ push r14
1765+ push r15
1766+ push rbx
1767+ push rbp
1768+ %assign push_num 6
1769+ LOAD_7_PARA
1770+ SIGN_EXTENSION r1, r1d
1771+ SIGN_EXTENSION r2, r2d
1772+ SIGN_EXTENSION r3, r3d
1773+ SIGN_EXTENSION r5, r5d
1774+ SIGN_EXTENSION r6, r6d
1775+
1776+ pxor xmm0, xmm0
1777+ mov r12d, r6d
1778+ and r12d, 65535
1779+ mov r13d, r12d
1780+ neg r13d
1781+ and r13d, 65535
1782+ movd xmm1, r12d ; uinc(uiScaleX mod 65536)
1783+ movd xmm2, r13d ; -uinc
1784+ psllq xmm1, 32
1785+ por xmm1, xmm2 ; 0 uinc 0 -uinc
1786+ pshuflw xmm7, xmm1, 10001000b ; xmm7: uinc -uinc uinc -uinc
1787+
1788+ mov r12, arg8
1789+ SIGN_EXTENSION r12, r12d
1790+ mov rbp, r12
1791+ and r12d, 32767
1792+ mov r13d, r12d
1793+ neg r13d
1794+ and r13d, 32767
1795+ movd xmm6, r12d ; vinc(uiScaleY mod 32767)
1796+ movd xmm2, r13d ; -vinc
1797+ psllq xmm6, 32
1798+ por xmm6, xmm2 ; 0 vinc 0 -vinc
1799+ pshuflw xmm6, xmm6, 10100000b ; xmm6: vinc vinc -vinc -vinc
1800+
1801+ mov r12d, 80007fffh ; 32768 32767
1802+ movd xmm5, r12d
1803+ pshuflw xmm5, xmm5, 01000100b ; 32768 32767 32768 32767
1804+
1805+FAST_DOWNSAMPLE:
1806+ sub r1, r2 ; stride - width
1807+ dec r3
1808+ mov r14,16384
1809+
1810+ pshuflw xmm4, xmm5, 01010000b
1811+ psrlw xmm4, 1 ; initial v to 16384 16384 16383 16383
1812+
1813+FAST_HEIGHT:
1814+ mov r12, r14
1815+ shr r12, 15
1816+ imul r12, r5
1817+ add r12, r4 ; get current row address
1818+ mov r13, r12
1819+ add r13, r5
1820+
1821+ mov r15, 32768
1822+ mov rax, r2
1823+ dec rax
1824+
1825+ movdqa xmm3, xmm5 ; initial u to 32768 32767 32768 32767
1826+
1827+FAST_WIDTH:
1828+ mov r11, r15
1829+ shr r11, 16
1830+
1831+ movd xmm1, [r12+r11] ; xxxxxxba
1832+ movd xmm2, [r13+r11] ; xxxxxxdc
1833+ punpcklwd xmm1, xmm2 ; xxxxdcba
1834+ punpcklbw xmm1, xmm0 ; 0d0c0b0a
1835+
1836+ movdqa xmm2, xmm4 ; xmm2: vv(1-v)(1-v) tmpv
1837+ pmulhuw xmm2, xmm3 ; mul u(1-u)u(1-u) on xmm2
1838+ pmaddwd xmm2, xmm1
1839+ pshufd xmm1, xmm2, 00000001b
1840+ paddd xmm2, xmm1
1841+ movdqa xmm1, [add_extra_half]
1842+ paddd xmm2, xmm1
1843+ psrld xmm2, 15
1844+
1845+ packuswb xmm2, xmm0
1846+ movd ebx, xmm2
1847+ mov [r0], bl
1848+ inc r0
1849+
1850+ add r15, r6
1851+
1852+ paddw xmm3, xmm7 ; inc u
1853+ dec rax
1854+ jg FAST_WIDTH
1855+
1856+FAST_WIDTH_END:
1857+ shr r15, 16
1858+ mov bl, [r12+r15]
1859+ mov [r0],bl
1860+ inc r0
1861+ add r14, rbp
1862+ add r0, r1
1863+
1864+ paddw xmm4, xmm6 ; inc v
1865+ psllw xmm4, 1
1866+ psrlw xmm4, 1
1867+
1868+ dec r3
1869+ jg FAST_HEIGHT
1870+
1871+
1872+FAST_LAST_ROW:
1873+ shr r14, 15
1874+ imul r14, r5
1875+ add r4, r14
1876+ mov r15, 32768
1877+
1878+FAST_LAST_ROW_WIDTH:
1879+ mov r11, r15
1880+ shr r11, 16
1881+ mov bl, [r4+r11]
1882+ mov [r0],bl
1883+ inc r0
1884+
1885+ add r15, r6
1886+ dec r2
1887+ jg FAST_LAST_ROW_WIDTH
1888+
1889+FAST_LAST_ROW_END:
1890+
1891+ pop rbp
1892+ pop rbx
1893+ pop r15
1894+ pop r14
1895+ pop r13
1896+ pop r12
1897+ ret
12051898 %endif

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t