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
57 sDownsampleFunc.pfGeneralRatioLuma = GeneralBilinearFastDownsampler_c;57 sDownsampleFunc.pfGeneralRatioLuma = GeneralBilinearFastDownsampler_c;
58#if defined(X86_ASM)58#if defined(X86_ASM)
59 if (iCpuFlag & WELS_CPU_SSE) {59 if (iCpuFlag & WELS_CPU_SSE) {
60 /* sDownsampleFunc.pfHalfAverage[0] = DyadicBilinearDownsamplerWidthx32_sse;60 sDownsampleFunc.pfHalfAverage[0] = DyadicBilinearDownsamplerWidthx32_sse;
61 sDownsampleFunc.pfHalfAverage[1] = DyadicBilinearDownsamplerWidthx16_sse;61 sDownsampleFunc.pfHalfAverage[1] = DyadicBilinearDownsamplerWidthx16_sse;
62 sDownsampleFunc.pfHalfAverage[2] = DyadicBilinearDownsamplerWidthx8_sse;*/62 sDownsampleFunc.pfHalfAverage[2] = DyadicBilinearDownsamplerWidthx8_sse;
63 }63 }
64 if (iCpuFlag & WELS_CPU_SSE2) {64 if (iCpuFlag & WELS_CPU_SSE2) {
65 // sDownsampleFunc.pfGeneralRatioChroma = GeneralBilinearAccurateDownsamplerWrap_sse2;65 sDownsampleFunc.pfGeneralRatioChroma = GeneralBilinearAccurateDownsamplerWrap_sse2;
66 // sDownsampleFunc.pfGeneralRatioLuma = GeneralBilinearFastDownsamplerWrap_sse2;66 sDownsampleFunc.pfGeneralRatioLuma = GeneralBilinearFastDownsamplerWrap_sse2;
67 }67 }
68 if (iCpuFlag & WELS_CPU_SSSE3) {68 if (iCpuFlag & WELS_CPU_SSSE3) {
69 // sDownsampleFunc.pfHalfAverage[0] = DyadicBilinearDownsamplerWidthx32_ssse3;69 sDownsampleFunc.pfHalfAverage[0] = DyadicBilinearDownsamplerWidthx32_ssse3;
70 // sDownsampleFunc.pfHalfAverage[1] = DyadicBilinearDownsamplerWidthx16_ssse3;70 sDownsampleFunc.pfHalfAverage[1] = DyadicBilinearDownsamplerWidthx16_ssse3;
71 }71 }
72 if (iCpuFlag & WELS_CPU_SSE41) {72 if (iCpuFlag & WELS_CPU_SSE41) {
73 // sDownsampleFunc.pfHalfAverage[0] = DyadicBilinearDownsamplerWidthx32_sse4;73 sDownsampleFunc.pfHalfAverage[0] = DyadicBilinearDownsamplerWidthx32_sse4;
74 // sDownsampleFunc.pfHalfAverage[1] = DyadicBilinearDownsamplerWidthx16_sse4;74 sDownsampleFunc.pfHalfAverage[1] = DyadicBilinearDownsamplerWidthx16_sse4;
75 }75 }
76#endif//X86_ASM76#endif//X86_ASM
77 77
codec/processing/src/downsample/downsample.h+2−6
@@ -94,13 +94,9 @@ GeneralDownsampleFunc GeneralBilinearFastDownsamplerWrap_sse2; · 93 unmodified lines
94GeneralDownsampleFunc GeneralBilinearAccurateDownsamplerWrap_sse2;94GeneralDownsampleFunc GeneralBilinearAccurateDownsamplerWrap_sse2;
95 95
96void GeneralBilinearFastDownsampler_sse2 (uint8_t* pDst, const int32_t kiDstStride, const int32_t kiDstWidth,96void GeneralBilinearFastDownsampler_sse2 (uint8_t* pDst, const int32_t kiDstStride, const int32_t kiDstWidth,
97 const int32_t kiDstHeight,97 const int32_t kiDstHeight, uint8_t* pSrc, const int32_t kiSrcStride, const uint32_t kuiScaleX, const uint32_t kuiScaleY);
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);
100void GeneralBilinearAccurateDownsampler_sse2 (uint8_t* pDst, const int32_t kiDstStride, const int32_t kiDstWidth,98void GeneralBilinearAccurateDownsampler_sse2 (uint8_t* pDst, const int32_t kiDstStride, const int32_t kiDstWidth,
101 const int32_t kiDstHeight,99 const int32_t kiDstHeight, uint8_t* pSrc, const int32_t kiSrcStride, const uint32_t kuiScaleX, const uint32_t kuiScaleY);
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);
104WELSVP_EXTERN_C_END100WELSVP_EXTERN_C_END
105#endif101#endif
106 102
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
202 202
203 203
204#ifdef X86_ASM204#ifdef X86_ASM
205//void GeneralBilinearFastDownsamplerWrap_sse2 (uint8_t* pDst, const int32_t kiDstStride, const int32_t kiDstWidth,205void GeneralBilinearFastDownsamplerWrap_sse2 (uint8_t* pDst, const int32_t kiDstStride, const int32_t kiDstWidth,
206// const int32_t kiDstHeight,206 const int32_t kiDstHeight,
207// uint8_t* pSrc, const int32_t kiSrcStride, const int32_t kiSrcWidth, const int32_t kiSrcHeight) {207 uint8_t* pSrc, const int32_t kiSrcStride, const int32_t kiSrcWidth, const int32_t kiSrcHeight) {
208// const int32_t kiScaleBitWidth = 16, kiScaleBitHeight = 15;208 const int32_t kiScaleBitWidth = 16, kiScaleBitHeight = 15;
209// const uint32_t kuiScaleWidth = (1 << kiScaleBitWidth), kuiScaleHeight = (1 << kiScaleBitHeight);209 const uint32_t kuiScaleWidth = (1 << kiScaleBitWidth), kuiScaleHeight = (1 << kiScaleBitHeight);
210//210
211// uint32_t uiScalex = WELS_ROUND ((float)kiSrcWidth / (float)kiDstWidth * kuiScaleWidth);211 uint32_t uiScalex = WELS_ROUND ((float)kiSrcWidth / (float)kiDstWidth * kuiScaleWidth);
212// uint32_t uiScaley = WELS_ROUND ((float)kiSrcHeight / (float)kiDstHeight * kuiScaleHeight);212 uint32_t uiScaley = WELS_ROUND ((float)kiSrcHeight / (float)kiDstHeight * kuiScaleHeight);
213//213
214// GeneralBilinearFastDownsampler_sse2 (pDst, kiDstStride, kiDstWidth, kiDstHeight,214 GeneralBilinearFastDownsampler_sse2 (pDst, kiDstStride, kiDstWidth, kiDstHeight,
215// pSrc, kiSrcStride, kiSrcWidth, kiSrcHeight, uiScalex, uiScaley);215 pSrc, kiSrcStride, uiScalex, uiScaley);
216//}216}
217//217
218//void GeneralBilinearAccurateDownsamplerWrap_sse2 (uint8_t* pDst, const int32_t kiDstStride, const int32_t kiDstWidth,218void GeneralBilinearAccurateDownsamplerWrap_sse2 (uint8_t* pDst, const int32_t kiDstStride, const int32_t kiDstWidth,
219// const int32_t kiDstHeight,219 const int32_t kiDstHeight,
220// uint8_t* pSrc, const int32_t kiSrcStride, const int32_t kiSrcWidth, const int32_t kiSrcHeight) {220 uint8_t* pSrc, const int32_t kiSrcStride, const int32_t kiSrcWidth, const int32_t kiSrcHeight) {
221// const int32_t kiScaleBit = 15;221 const int32_t kiScaleBit = 15;
222// const uint32_t kuiScale = (1 << kiScaleBit);222 const uint32_t kuiScale = (1 << kiScaleBit);
223//223
224// uint32_t uiScalex = WELS_ROUND ((float)kiSrcWidth / (float)kiDstWidth * kuiScale);224 uint32_t uiScalex = WELS_ROUND ((float)kiSrcWidth / (float)kiDstWidth * kuiScale);
225// uint32_t uiScaley = WELS_ROUND ((float)kiSrcHeight / (float)kiDstHeight * kuiScale);225 uint32_t uiScaley = WELS_ROUND ((float)kiSrcHeight / (float)kiDstHeight * kuiScale);
226//226
227// GeneralBilinearAccurateDownsampler_sse2 (pDst, kiDstStride, kiDstWidth, kiDstHeight,227 GeneralBilinearAccurateDownsampler_sse2 (pDst, kiDstStride, kiDstWidth, kiDstHeight,
228// pSrc, kiSrcStride, kiSrcWidth, kiSrcHeight, uiScalex, uiScaley);228 pSrc, kiSrcStride, uiScalex, uiScaley);
229//}229}
230#endif //X86_ASM230#endif //X86_ASM
231 231
232#ifdef HAVE_NEON232#ifdef HAVE_NEON
codec/processing/src/x86/downsample_bilinear.asm+1026−333
@@ -39,7 +39,7 @@ · 38 unmodified lines
39;*39;*
40;*************************************************************************/40;*************************************************************************/
41%include "asm_inc.asm"41%include "asm_inc.asm"
42%ifdef X86_3242
43;***********************************************************************43;***********************************************************************
44; Macros and other preprocessor constants44; Macros and other preprocessor constants
45;***********************************************************************45;***********************************************************************
@@ -64,6 +64,8 @@ shufb_mask_low: · 18 unmodified lines
64 db 00h, 80h, 02h, 80h, 04h, 80h, 06h, 80h, 08h, 80h, 0ah, 80h, 0ch, 80h, 0eh, 80h64 db 00h, 80h, 02h, 80h, 04h, 80h, 06h, 80h, 08h, 80h, 0ah, 80h, 0ch, 80h, 0eh, 80h
65shufb_mask_high:65shufb_mask_high:
66 db 01h, 80h, 03h, 80h, 05h, 80h, 07h, 80h, 09h, 80h, 0bh, 80h, 0dh, 80h, 0fh, 80h66 db 01h, 80h, 03h, 80h, 05h, 80h, 07h, 80h, 09h, 80h, 0bh, 80h, 0dh, 80h, 0fh, 80h
67add_extra_half:
68 dd 16384,0,0,0
67 69
68 70
69;***********************************************************************71;***********************************************************************
@@ -78,28 +80,36 @@ SECTION .text · 8 unmodified lines
78; const int iSrcWidth, const int iSrcHeight );80; const int iSrcWidth, const int iSrcHeight );
79;***********************************************************************81;***********************************************************************
80WELS_EXTERN DyadicBilinearDownsamplerWidthx32_sse82WELS_EXTERN DyadicBilinearDownsamplerWidthx32_sse
81 push ebx83%ifdef X86_32
82 push edx84 push r6
83 push esi85 %assign push_num 1
84 push edi86%else
85 push ebp87 %assign push_num 0
86 88%endif
87 mov edi, [esp+24] ; pDst89 LOAD_6_PARA
88 mov edx, [esp+28] ; iDstStride90 SIGN_EXTENSION r1, r1d
89 mov esi, [esp+32] ; pSrc91 SIGN_EXTENSION r3, r3d
90 mov ecx, [esp+36] ; iSrcStride92 SIGN_EXTENSION r4, r4d
91 mov ebp, [esp+44] ; iSrcHeight93 SIGN_EXTENSION r5, r5d
92 94
93 sar ebp, $01 ; iSrcHeight >> 195%ifndef X86_32
94 96 push r12
95.yloops:97 mov r12, r4
96 mov eax, [esp+40] ; iSrcWidth98%endif
97 sar eax, $01 ; iSrcWidth >> 199 sar r5, $01 ; iSrcHeight >> 1
98 mov ebx, eax ; iDstWidth restored at ebx100
99 sar eax, $04 ; (iSrcWidth >> 1) / 16 ; loop count = num_of_mb101.yloops1:
100 neg ebx ; - (iSrcWidth >> 1)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)
101 ; each loop = source bandwidth: 32 bytes111 ; each loop = source bandwidth: 32 bytes
102.xloops:112.xloops1:
103 ; 1st part horizonal loop: x16 bytes113 ; 1st part horizonal loop: x16 bytes
104 ; mem hi<- ->lo114 ; mem hi<- ->lo
105 ;1st Line Src: mm0: d D c C b B a A mm1: h H g G f F e E115 ;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
108 ;: H G F E D C B A, P O N M L K J I118 ;: H G F E D C B A, P O N M L K J I
109 ;: h g f e d c b a, p o n m l k j i119 ;: h g f e d c b a, p o n m l k j i
110 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;120 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
111 movq mm0, [esi] ; 1st pSrc line121 movq mm0, [r2] ; 1st pSrc line
112 movq mm1, [esi+8] ; 1st pSrc line + 8122 movq mm1, [r2+8] ; 1st pSrc line + 8
113 movq mm2, [esi+ecx] ; 2nd pSrc line123 movq mm2, [r2+r3] ; 2nd pSrc line
114 movq mm3, [esi+ecx+8] ; 2nd pSrc line + 8124 movq mm3, [r2+r3+8] ; 2nd pSrc line + 8
115 125
116 ; to handle mm0, mm1, mm2, mm3126 ; to handle mm0, mm1, mm2, mm3
117 pshufw mm4, mm0, 0d8h ; d D b B c C a A ; 11011000 B127 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
156 ;: H G F E D C B A, P O N M L K J I166 ;: H G F E D C B A, P O N M L K J I
157 ;: h g f e d c b a, p o n m l k j i167 ;: h g f e d c b a, p o n m l k j i
158 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;168 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
159 movq mm1, [esi+16] ; 1st pSrc line + 16169 movq mm1, [r2+16] ; 1st pSrc line + 16
160 movq mm2, [esi+24] ; 1st pSrc line + 24170 movq mm2, [r2+24] ; 1st pSrc line + 24
161 movq mm3, [esi+ecx+16] ; 2nd pSrc line + 16171 movq mm3, [r2+r3+16] ; 2nd pSrc line + 16
162 movq mm4, [esi+ecx+24] ; 2nd pSrc line + 24172 movq mm4, [r2+r3+24] ; 2nd pSrc line + 24
163 173
164 ; to handle mm1, mm2, mm3, mm4174 ; to handle mm1, mm2, mm3, mm4
165 pshufw mm5, mm1, 0d8h ; d D b B c C a A ; 11011000 B175 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
196 pavgb mm3, mm7 ; (I+i+1)>>1, .., (P+p+1)>>1, temp_row2206 pavgb mm3, mm7 ; (I+i+1)>>1, .., (P+p+1)>>1, temp_row2
197 pavgb mm2, mm3 ; (temp_row1+temp_row2+1)>>1, done in another 2nd horizonal part207 pavgb mm2, mm3 ; (temp_row1+temp_row2+1)>>1, done in another 2nd horizonal part
198 208
199 movq [edi ], mm0209 movq [r0 ], mm0
200 movq [edi+8], mm2210 movq [r0+8], mm2
201 211
202 ; next SMB212 ; next SMB
203 lea esi, [esi+32]213 lea r2, [r2+32]
204 lea edi, [edi+16]214 lea r0, [r0+16]
205 215
206 dec eax216 dec r4
207 jg near .xloops217 jg near .xloops1
208 218
209 ; next line219 ; next line
210 lea esi, [esi+2*ecx] ; next end of lines220 lea r2, [r2+2*r3] ; next end of lines
211 lea esi, [esi+2*ebx] ; reset to base 0 [- 2 * iDstWidth]221 lea r2, [r2+2*r6] ; reset to base 0 [- 2 * iDstWidth]
212 lea edi, [edi+edx]222 lea r0, [r0+r1]
213 lea edi, [edi+ebx] ; reset to base 0 [- iDstWidth]223 lea r0, [r0+r6] ; reset to base 0 [- iDstWidth]
214 224
215 dec ebp225 dec r5
216 jg near .yloops226 jg near .yloops1
217 227
218 WELSEMMS228 WELSEMMS
219 pop ebp229%ifndef X86_32
220 pop edi230 pop r12
221 pop esi231%endif
222 pop edx232 LOAD_6_PARA_POP
223 pop ebx233%ifdef X86_32
234 pop r6
235%endif
224 ret236 ret
225 237
226;***********************************************************************238;***********************************************************************
@@ -229,28 +241,36 @@ WELS_EXTERN DyadicBilinearDownsamplerWidthx32_sse · 2 unmodified lines
229; const int iSrcWidth, const int iSrcHeight );241; const int iSrcWidth, const int iSrcHeight );
230;***********************************************************************242;***********************************************************************
231WELS_EXTERN DyadicBilinearDownsamplerWidthx16_sse243WELS_EXTERN DyadicBilinearDownsamplerWidthx16_sse
232 push ebx244%ifdef X86_32
233 push edx245 push r6
234 push esi246 %assign push_num 1
235 push edi247%else
236 push ebp248 %assign push_num 0
237 249%endif
238 mov edi, [esp+24] ; pDst250 LOAD_6_PARA
239 mov edx, [esp+28] ; iDstStride251 SIGN_EXTENSION r1, r1d
240 mov esi, [esp+32] ; pSrc252 SIGN_EXTENSION r3, r3d
241 mov ecx, [esp+36] ; iSrcStride253 SIGN_EXTENSION r4, r4d
242 mov ebp, [esp+44] ; iSrcHeight254 SIGN_EXTENSION r5, r5d
243 255
244 sar ebp, $01 ; iSrcHeight >> 1256%ifndef X86_32
245 257 push r12
246.yloops:258 mov r12, r4
247 mov eax, [esp+40] ; iSrcWidth259%endif
248 sar eax, $01 ; iSrcWidth >> 1260 sar r5, $01 ; iSrcHeight >> 1
249 mov ebx, eax ; iDstWidth restored at ebx261
250 sar eax, $03 ; (iSrcWidth >> 1) / 8 ; loop count = num_of_mb262.yloops2:
251 neg ebx ; - (iSrcWidth >> 1)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)
252 ; each loop = source bandwidth: 16 bytes272 ; each loop = source bandwidth: 16 bytes
253.xloops:273.xloops2:
254 ; 1st part horizonal loop: x16 bytes274 ; 1st part horizonal loop: x16 bytes
255 ; mem hi<- ->lo275 ; mem hi<- ->lo
256 ;1st Line Src: mm0: d D c C b B a A mm1: h H g G f F e E276 ;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
259 ;: H G F E D C B A, P O N M L K J I279 ;: H G F E D C B A, P O N M L K J I
260 ;: h g f e d c b a, p o n m l k j i280 ;: h g f e d c b a, p o n m l k j i
261 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;281 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
262 movq mm0, [esi] ; 1st pSrc line282 movq mm0, [r2] ; 1st pSrc line
263 movq mm1, [esi+8] ; 1st pSrc line + 8283 movq mm1, [r2+8] ; 1st pSrc line + 8
264 movq mm2, [esi+ecx] ; 2nd pSrc line284 movq mm2, [r2+r3] ; 2nd pSrc line
265 movq mm3, [esi+ecx+8] ; 2nd pSrc line + 8285 movq mm3, [r2+r3+8] ; 2nd pSrc line + 8
266 286
267 ; to handle mm0, mm1, mm2, mm3287 ; to handle mm0, mm1, mm2, mm3
268 pshufw mm4, mm0, 0d8h ; d D b B c C a A ; 11011000 B288 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
299 pavgb mm1, mm6 ; (I+i+1)>>1, .., (P+p+1)>>1, temp_row2319 pavgb mm1, mm6 ; (I+i+1)>>1, .., (P+p+1)>>1, temp_row2
300 pavgb mm0, mm1 ; (temp_row1+temp_row2+1)>>1, pending here and wait another horizonal part done then write memory once320 pavgb mm0, mm1 ; (temp_row1+temp_row2+1)>>1, pending here and wait another horizonal part done then write memory once
301 321
302 movq [edi ], mm0322 movq [r0 ], mm0
303 323
304 ; next SMB324 ; next SMB
305 lea esi, [esi+16]325 lea r2, [r2+16]
306 lea edi, [edi+8]326 lea r0, [r0+8]
307 327
308 dec eax328 dec r4
309 jg near .xloops329 jg near .xloops2
310 330
311 ; next line331 ; next line
312 lea esi, [esi+2*ecx] ; next end of lines332 lea r2, [r2+2*r3] ; next end of lines
313 lea esi, [esi+2*ebx] ; reset to base 0 [- 2 * iDstWidth]333 lea r2, [r2+2*r6] ; reset to base 0 [- 2 * iDstWidth]
314 lea edi, [edi+edx]334 lea r0, [r0+r1]
315 lea edi, [edi+ebx] ; reset to base 0 [- iDstWidth]335 lea r0, [r0+r6] ; reset to base 0 [- iDstWidth]
316 336
317 dec ebp337 dec r5
318 jg near .yloops338 jg near .yloops2
319 339
320 WELSEMMS340 WELSEMMS
321 pop ebp341%ifndef X86_32
322 pop edi342 pop r12
323 pop esi343%endif
324 pop edx344 LOAD_6_PARA_POP
325 pop ebx345%ifdef X86_32
346 pop r6
347%endif
326 ret348 ret
327 349
328;***********************************************************************350;***********************************************************************
@@ -331,28 +353,36 @@ WELS_EXTERN DyadicBilinearDownsamplerWidthx16_sse · 2 unmodified lines
331; const int iSrcWidth, const int iSrcHeight );353; const int iSrcWidth, const int iSrcHeight );
332;***********************************************************************354;***********************************************************************
333WELS_EXTERN DyadicBilinearDownsamplerWidthx8_sse355WELS_EXTERN DyadicBilinearDownsamplerWidthx8_sse
334 push ebx356%ifdef X86_32
335 push edx357 push r6
336 push esi358 %assign push_num 1
337 push edi359%else
338 push ebp360 %assign push_num 0
339 361%endif
340 mov edi, [esp+24] ; pDst362 LOAD_6_PARA
341 mov edx, [esp+28] ; iDstStride363 SIGN_EXTENSION r1, r1d
342 mov esi, [esp+32] ; pSrc364 SIGN_EXTENSION r3, r3d
343 mov ecx, [esp+36] ; iSrcStride365 SIGN_EXTENSION r4, r4d
344 mov ebp, [esp+44] ; iSrcHeight366 SIGN_EXTENSION r5, r5d
345 367
346 sar ebp, $01 ; iSrcHeight >> 1368%ifndef X86_32
347 369 push r12
348.yloops:370 mov r12, r4
349 mov eax, [esp+40] ; iSrcWidth371%endif
350 sar eax, $01 ; iSrcWidth >> 1372 sar r5, $01 ; iSrcHeight >> 1
351 mov ebx, eax ; iDstWidth restored at ebx373
352 sar eax, $02 ; (iSrcWidth >> 1) / 4 ; loop count = num_of_mb374.yloops3:
353 neg ebx ; - (iSrcWidth >> 1)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)
354 ; each loop = source bandwidth: 8 bytes384 ; each loop = source bandwidth: 8 bytes
355.xloops:385.xloops3:
356 ; 1st part horizonal loop: x8 bytes386 ; 1st part horizonal loop: x8 bytes
357 ; mem hi<- ->lo387 ; mem hi<- ->lo
358 ;1st Line Src: mm0: d D c C b B a A388 ;1st Line Src: mm0: d D c C b B a A
@@ -361,8 +391,8 @@ WELS_EXTERN DyadicBilinearDownsamplerWidthx8_sse · 2 unmodified lines
361 ;: H G F E D C B A391 ;: H G F E D C B A
362 ;: h g f e d c b a392 ;: h g f e d c b a
363 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;393 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
364 movq mm0, [esi] ; 1st pSrc line394 movq mm0, [r2] ; 1st pSrc line
365 movq mm1, [esi+ecx] ; 2nd pSrc line395 movq mm1, [r2+r3] ; 2nd pSrc line
366 396
367 ; to handle mm0, mm1, mm2, mm3397 ; to handle mm0, mm1, mm2, mm3
368 pshufw mm2, mm0, 0d8h ; d D b B c C a A ; 11011000 B398 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
385 pshufw mm1, mm0, 04eh ; 01001110 B415 pshufw mm1, mm0, 04eh ; 01001110 B
386 pavgb mm0, mm1 ; (temp_row1+temp_row2+1)>>1, pending here and wait another horizonal part done then write memory once416 pavgb mm0, mm1 ; (temp_row1+temp_row2+1)>>1, pending here and wait another horizonal part done then write memory once
387 417
388 movd [edi], mm0418 movd [r0], mm0
389 419
390 ; next unit420 ; next unit
391 lea esi, [esi+8]421 lea r2, [r2+8]
392 lea edi, [edi+4]422 lea r0, [r0+4]
393 423
394 dec eax424 dec r4
395 jg near .xloops425 jg near .xloops3
396 426
397 ; next line427 ; next line
398 lea esi, [esi+2*ecx] ; next end of lines428 lea r2, [r2+2*r3] ; next end of lines
399 lea esi, [esi+2*ebx] ; reset to base 0 [- 2 * iDstWidth]429 lea r2, [r2+2*r6] ; reset to base 0 [- 2 * iDstWidth]
400 lea edi, [edi+edx]430 lea r0, [r0+r1]
401 lea edi, [edi+ebx] ; reset to base 0 [- iDstWidth]431 lea r0, [r0+r6] ; reset to base 0 [- iDstWidth]
402 432
403 dec ebp433 dec r5
404 jg near .yloops434 jg near .yloops3
405 435
406 WELSEMMS436 WELSEMMS
407 pop ebp437%ifndef X86_32
408 pop edi438 pop r12
409 pop esi439%endif
410 pop edx440 LOAD_6_PARA_POP
411 pop ebx441%ifdef X86_32
442 pop r6
443%endif
412 ret444 ret
413 445
414 446
@@ -420,31 +452,56 @@ WELS_EXTERN DyadicBilinearDownsamplerWidthx8_sse · 5 unmodified lines
420; const int iSrcWidth, const int iSrcHeight );452; const int iSrcWidth, const int iSrcHeight );
421;***********************************************************************453;***********************************************************************
422WELS_EXTERN DyadicBilinearDownsamplerWidthx32_ssse3454WELS_EXTERN DyadicBilinearDownsamplerWidthx32_ssse3
423 push ebx455 ;push ebx
424 push edx456 ;push edx
425 push esi457 ;push esi
426 push edi458 ;push edi
427 push ebp459 ;push ebp
428 460
429 mov edi, [esp+24] ; pDst461 ;mov edi, [esp+24] ; pDst
430 mov edx, [esp+28] ; iDstStride462 ;mov edx, [esp+28] ; iDstStride
431 mov esi, [esp+32] ; pSrc463 ;mov esi, [esp+32] ; pSrc
432 mov ecx, [esp+36] ; iSrcStride464 ;mov ecx, [esp+36] ; iSrcStride
433 mov ebp, [esp+44] ; iSrcHeight465 ;mov ebp, [esp+44] ; iSrcHeight
434 466%ifdef X86_32
435 sar ebp, $01 ; iSrcHeight >> 1467 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
436 484
437 movdqa xmm7, [shufb_mask_low] ; mask low485 movdqa xmm7, [shufb_mask_low] ; mask low
438 movdqa xmm6, [shufb_mask_high] ; mask high486 movdqa xmm6, [shufb_mask_high] ; mask high
439 487
440.yloops:488.yloops4:
441 mov eax, [esp+40] ; iSrcWidth489 ;mov eax, [esp+40] ; iSrcWidth
442 sar eax, $01 ; iSrcWidth >> 1490 ;sar eax, $01 ; iSrcWidth >> 1
443 mov ebx, eax ; iDstWidth restored at ebx491 ;mov ebx, eax ; iDstWidth restored at ebx
444 sar eax, $04 ; (iSrcWidth >> 1) / 16 ; loop count = num_of_mb492 ;sar eax, $04 ; (iSrcWidth >> 1) / 16 ; loop count = num_of_mb
445 neg ebx ; - (iSrcWidth >> 1)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)
446 ; each loop = source bandwidth: 32 bytes503 ; each loop = source bandwidth: 32 bytes
447.xloops:504.xloops4:
448 ; 1st part horizonal loop: x16 bytes505 ; 1st part horizonal loop: x16 bytes
449 ; mem hi<- ->lo506 ; mem hi<- ->lo
450 ;1st Line Src: xmm0: h H g G f F e E d D c C b B a A507 ;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
458 ;: p .. a515 ;: p .. a
459 516
460 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;517 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
461 movdqa xmm0, [esi] ; 1st_src_line518 movdqa xmm0, [r2] ; 1st_src_line
462 movdqa xmm1, [esi+16] ; 1st_src_line + 16519 movdqa xmm1, [r2+16] ; 1st_src_line + 16
463 movdqa xmm2, [esi+ecx] ; 2nd_src_line520 movdqa xmm2, [r2+r3] ; 2nd_src_line
464 movdqa xmm3, [esi+ecx+16] ; 2nd_src_line + 16521 movdqa xmm3, [r2+r3+16] ; 2nd_src_line + 16
465 522
466 ; packing & avg523 ; packing & avg
467 movdqa xmm4, xmm0 ; h H g G f F e E d D c C b B a A524 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
498 pavgb xmm0, xmm2555 pavgb xmm0, xmm2
499 556
500 ; write pDst557 ; write pDst
501 movdqa [edi], xmm0558 movdqa [r0], xmm0
502 559
503 ; next SMB560 ; next SMB
504 lea esi, [esi+32]561 lea r2, [r2+32]
505 lea edi, [edi+16]562 lea r0, [r0+16]
506 563
507 dec eax564 dec r4
508 jg near .xloops565 jg near .xloops4
509 566
510 ; next line567 ; next line
511 lea esi, [esi+2*ecx] ; next end of lines568 lea r2, [r2+2*r3] ; next end of lines
512 lea esi, [esi+2*ebx] ; reset to base 0 [- 2 * iDstWidth]569 lea r2, [r2+2*r6] ; reset to base 0 [- 2 * iDstWidth]
513 lea edi, [edi+edx]570 lea r0, [r0+r1]
514 lea edi, [edi+ebx] ; reset to base 0 [- iDstWidth]571 lea r0, [r0+r6] ; reset to base 0 [- iDstWidth]
515 572
516 dec ebp573 dec r5
517 jg near .yloops574 jg near .yloops4
518 575
519 pop ebp576%ifndef X86_32
520 pop edi577 pop r12
521 pop esi578%endif
522 pop edx579
523 pop ebx580 POP_XMM
581 LOAD_6_PARA_POP
582%ifdef X86_32
583 pop r6
584%endif
524 ret585 ret
525 586
526;***********************************************************************587;***********************************************************************
@@ -529,30 +590,39 @@ WELS_EXTERN DyadicBilinearDownsamplerWidthx32_ssse3 · 2 unmodified lines
529; const int iSrcWidth, const int iSrcHeight );590; const int iSrcWidth, const int iSrcHeight );
530;***********************************************************************591;***********************************************************************
531WELS_EXTERN DyadicBilinearDownsamplerWidthx16_ssse3592WELS_EXTERN DyadicBilinearDownsamplerWidthx16_ssse3
532 push ebx593%ifdef X86_32
533 push edx594 push r6
534 push esi595 %assign push_num 1
535 push edi596%else
536 push ebp597 %assign push_num 0
537 598%endif
538 mov edi, [esp+24] ; pDst599 LOAD_6_PARA
539 mov edx, [esp+28] ; iDstStride600 PUSH_XMM 6
540 mov esi, [esp+32] ; pSrc601 SIGN_EXTENSION r1, r1d
541 mov ecx, [esp+36] ; iSrcStride602 SIGN_EXTENSION r3, r3d
542 mov ebp, [esp+44] ; iSrcHeight603 SIGN_EXTENSION r4, r4d
543 604 SIGN_EXTENSION r5, r5d
544 sar ebp, $01 ; iSrcHeight >> 1605
545 movdqa xmm7, [shufb_mask_low] ; mask low606%ifndef X86_32
546 movdqa xmm6, [shufb_mask_high] ; mask high607 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
547 613
548.yloops:614.yloops5:
549 mov eax, [esp+40] ; iSrcWidth615%ifdef X86_32
550 sar eax, $01 ; iSrcWidth >> 1616 mov r4, arg5
551 mov ebx, eax ; iDstWidth restored at ebx617%else
552 sar eax, $03 ; (iSrcWidth >> 1) / 8 ; loop count = num_of_mb618 mov r4, r12
553 neg ebx ; - (iSrcWidth >> 1)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)
554 ; each loop = source bandwidth: 16 bytes624 ; each loop = source bandwidth: 16 bytes
555.xloops:625.xloops5:
556 ; horizonal loop: x16 bytes by source626 ; horizonal loop: x16 bytes by source
557 ; mem hi<- ->lo627 ; mem hi<- ->lo
558 ;1st line pSrc: xmm0: h H g G f F e E d D c C b B a A628 ;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
562 ;: h g f e d c b a, p o n m l k j i632 ;: h g f e d c b a, p o n m l k j i
563 633
564 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;634 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
565 movdqa xmm0, [esi] ; 1st_src_line635 movdqa xmm0, [r2] ; 1st_src_line
566 movdqa xmm1, [esi+ecx] ; 2nd_src_line636 movdqa xmm1, [r2+r3] ; 2nd_src_line
567 637
568 ; packing & avg638 ; packing & avg
569 movdqa xmm2, xmm0 ; h H g G f F e E d D c C b B a A639 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 A640 pshufb xmm0, xmm5 ; 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 a641 pshufb xmm2, xmm4 ; 0 h 0 g 0 f 0 e 0 d 0 c 0 b 0 a
572 ; another implementation for xmm2 high bits642 ; another implementation for xmm2 high bits
573; psubb xmm2, xmm0 ; h 0 g 0 f 0 e 0 d 0 c 0 b 0 a 0643; psubb xmm2, xmm0 ; h 0 g 0 f 0 e 0 d 0 c 0 b 0 a 0
574; psrlw xmm2, 8 ; 0 h 0 g 0 f 0 e 0 d 0 c 0 b 0 a644; psrlw xmm2, 8 ; 0 h 0 g 0 f 0 e 0 d 0 c 0 b 0 a
575 pavgb xmm0, xmm2645 pavgb xmm0, xmm2
576 646
577 movdqa xmm3, xmm1647 movdqa xmm3, xmm1
578 pshufb xmm1, xmm7648 pshufb xmm1, xmm5
579 pshufb xmm3, xmm6649 pshufb xmm3, xmm4
580; psubb xmm3, xmm1650; psubb xmm3, xmm1
581; psrlw xmm3, 8651; psrlw xmm3, 8
582 pavgb xmm1, xmm3652 pavgb xmm1, xmm3
@@ -585,29 +655,32 @@ WELS_EXTERN DyadicBilinearDownsamplerWidthx16_ssse3 · 2 unmodified lines
585 packuswb xmm0, xmm1655 packuswb xmm0, xmm1
586 656
587 ; write pDst657 ; write pDst
588 movq [edi], xmm0658 movq [r0], xmm0
589 659
590 ; next SMB660 ; next SMB
591 lea esi, [esi+16]661 lea r2, [r2+16]
592 lea edi, [edi+8]662 lea r0, [r0+8]
593 663
594 dec eax664 dec r4
595 jg near .xloops665 jg near .xloops5
596 666
597 ; next line667 lea r2, [r2+2*r3] ; next end of lines
598 lea esi, [esi+2*ecx] ; next end of lines668 lea r2, [r2+2*r6] ; reset to base 0 [- 2 * iDstWidth]
599 lea esi, [esi+2*ebx] ; reset to base 0 [- 2 * iDstWidth]669 lea r0, [r0+r1]
600 lea edi, [edi+edx]670 lea r0, [r0+r6] ; reset to base 0 [- iDstWidth]
601 lea edi, [edi+ebx] ; reset to base 0 [- iDstWidth]671
602 672 dec r5
603 dec ebp673 jg near .yloops5
604 jg near .yloops674
605 675%ifndef X86_32
606 pop ebp676 pop r12
607 pop edi677%endif
608 pop esi678
609 pop edx679 POP_XMM
610 pop ebx680 LOAD_6_PARA_POP
681%ifdef X86_32
682 pop r6
683%endif
611 ret684 ret
612 685
613; got about 65% improvement over DyadicBilinearDownsamplerWidthx32_sse686; got about 65% improvement over DyadicBilinearDownsamplerWidthx32_sse
@@ -617,31 +690,40 @@ WELS_EXTERN DyadicBilinearDownsamplerWidthx16_ssse3 · 3 unmodified lines
617; const int iSrcWidth, const int iSrcHeight );690; const int iSrcWidth, const int iSrcHeight );
618;***********************************************************************691;***********************************************************************
619WELS_EXTERN DyadicBilinearDownsamplerWidthx32_sse4692WELS_EXTERN DyadicBilinearDownsamplerWidthx32_sse4
620 push ebx693%ifdef X86_32
621 push edx694 push r6
622 push esi695 %assign push_num 1
623 push edi696%else
624 push ebp697 %assign push_num 0
625 698%endif
626 mov edi, [esp+24] ; pDst699 LOAD_6_PARA
627 mov edx, [esp+28] ; iDstStride700 PUSH_XMM 8
628 mov esi, [esp+32] ; pSrc701 SIGN_EXTENSION r1, r1d
629 mov ecx, [esp+36] ; iSrcStride702 SIGN_EXTENSION r3, r3d
630 mov ebp, [esp+44] ; iSrcHeight703 SIGN_EXTENSION r4, r4d
631 704 SIGN_EXTENSION r5, r5d
632 sar ebp, $01 ; iSrcHeight >> 1705
706%ifndef X86_32
707 push r12
708 mov r12, r4
709%endif
710 sar r5, $01 ; iSrcHeight >> 1
633 711
634 movdqa xmm7, [shufb_mask_low] ; mask low712 movdqa xmm7, [shufb_mask_low] ; mask low
635 movdqa xmm6, [shufb_mask_high] ; mask high713 movdqa xmm6, [shufb_mask_high] ; mask high
636 714
637.yloops:715.yloops6:
638 mov eax, [esp+40] ; iSrcWidth716%ifdef X86_32
639 sar eax, $01 ; iSrcWidth >> 1717 mov r4, arg5
640 mov ebx, eax ; iDstWidth restored at ebx718%else
641 sar eax, $04 ; (iSrcWidth >> 1) / 16 ; loop count = num_of_mb719 mov r4, r12
642 neg ebx ; - (iSrcWidth >> 1)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)
643 ; each loop = source bandwidth: 32 bytes725 ; each loop = source bandwidth: 32 bytes
644.xloops:726.xloops6:
645 ; 1st part horizonal loop: x16 bytes727 ; 1st part horizonal loop: x16 bytes
646 ; mem hi<- ->lo728 ; mem hi<- ->lo
647 ;1st Line Src: xmm0: h H g G f F e E d D c C b B a A729 ;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
655 ;: p .. a737 ;: p .. a
656 738
657 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;739 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
658 movntdqa xmm0, [esi] ; 1st_src_line740 movntdqa xmm0, [r2] ; 1st_src_line
659 movntdqa xmm1, [esi+16] ; 1st_src_line + 16741 movntdqa xmm1, [r2+16] ; 1st_src_line + 16
660 movntdqa xmm2, [esi+ecx] ; 2nd_src_line742 movntdqa xmm2, [r2+r3] ; 2nd_src_line
661 movntdqa xmm3, [esi+ecx+16] ; 2nd_src_line + 16743 movntdqa xmm3, [r2+r3+16] ; 2nd_src_line + 16
662 744
663 ; packing & avg745 ; packing & avg
664 movdqa xmm4, xmm0 ; h H g G f F e E d D c C b B a A746 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
694 pavgb xmm0, xmm2776 pavgb xmm0, xmm2
695 777
696 ; write pDst778 ; write pDst
697 movdqa [edi], xmm0779 movdqa [r0], xmm0
698 780
699 ; next SMB781 ; next SMB
700 lea esi, [esi+32]782 lea r2, [r2+32]
701 lea edi, [edi+16]783 lea r0, [r0+16]
702 784
703 dec eax785 dec r4
704 jg near .xloops786 jg near .xloops6
705 787
706 ; next line788 lea r2, [r2+2*r3] ; next end of lines
707 lea esi, [esi+2*ecx] ; next end of lines789 lea r2, [r2+2*r6] ; reset to base 0 [- 2 * iDstWidth]
708 lea esi, [esi+2*ebx] ; reset to base 0 [- 2 * iDstWidth]790 lea r0, [r0+r1]
709 lea edi, [edi+edx]791 lea r0, [r0+r6] ; reset to base 0 [- iDstWidth]
710 lea edi, [edi+ebx] ; reset to base 0 [- iDstWidth]792
711 793 dec r5
712 dec ebp794 jg near .yloops6
713 jg near .yloops795
714 796%ifndef X86_32
715 pop ebp797 pop r12
716 pop edi798%endif
717 pop esi799
718 pop edx800 POP_XMM
719 pop ebx801 LOAD_6_PARA_POP
802%ifdef X86_32
803 pop r6
804%endif
720 ret805 ret
721 806
722;***********************************************************************807;***********************************************************************
@@ -725,30 +810,39 @@ WELS_EXTERN DyadicBilinearDownsamplerWidthx32_sse4 · 2 unmodified lines
725; const int iSrcWidth, const int iSrcHeight );810; const int iSrcWidth, const int iSrcHeight );
726;***********************************************************************811;***********************************************************************
727WELS_EXTERN DyadicBilinearDownsamplerWidthx16_sse4812WELS_EXTERN DyadicBilinearDownsamplerWidthx16_sse4
728 push ebx813%ifdef X86_32
729 push edx814 push r6
730 push esi815 %assign push_num 1
731 push edi816%else
732 push ebp817 %assign push_num 0
733 818%endif
734 mov edi, [esp+24] ; pDst819 LOAD_6_PARA
735 mov edx, [esp+28] ; iDstStride820 PUSH_XMM 6
736 mov esi, [esp+32] ; pSrc821 SIGN_EXTENSION r1, r1d
737 mov ecx, [esp+36] ; iSrcStride822 SIGN_EXTENSION r3, r3d
738 mov ebp, [esp+44] ; iSrcHeight823 SIGN_EXTENSION r4, r4d
739 824 SIGN_EXTENSION r5, r5d
740 sar ebp, $01 ; iSrcHeight >> 1825
741 movdqa xmm7, [shufb_mask_low] ; mask low826%ifndef X86_32
742 movdqa xmm6, [shufb_mask_high] ; mask high827 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
743 833
744.yloops:834.yloops7:
745 mov eax, [esp+40] ; iSrcWidth835%ifdef X86_32
746 sar eax, $01 ; iSrcWidth >> 1836 mov r4, arg5
747 mov ebx, eax ; iDstWidth restored at ebx837%else
748 sar eax, $03 ; (iSrcWidth >> 1) / 8 ; loop count = num_of_mb838 mov r4, r12
749 neg ebx ; - (iSrcWidth >> 1)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)
750 ; each loop = source bandwidth: 16 bytes844 ; each loop = source bandwidth: 16 bytes
751.xloops:845.xloops7:
752 ; horizonal loop: x16 bytes by source846 ; horizonal loop: x16 bytes by source
753 ; mem hi<- ->lo847 ; mem hi<- ->lo
754 ;1st line pSrc: xmm0: h H g G f F e E d D c C b B a A848 ;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
758 ;: h g f e d c b a, p o n m l k j i852 ;: h g f e d c b a, p o n m l k j i
759 853
760 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;854 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
761 movntdqa xmm0, [esi] ; 1st_src_line855 movntdqa xmm0, [r2] ; 1st_src_line
762 movntdqa xmm1, [esi+ecx] ; 2nd_src_line856 movntdqa xmm1, [r2+r3] ; 2nd_src_line
763 857
764 ; packing & avg858 ; packing & avg
765 movdqa xmm2, xmm0 ; h H g G f F e E d D c C b B a A859 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 A860 pshufb xmm0, xmm5 ; 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 a861 pshufb xmm2, xmm4 ; 0 h 0 g 0 f 0 e 0 d 0 c 0 b 0 a
768; psubb xmm2, xmm0 ; h 0 g 0 f 0 e 0 d 0 c 0 b 0 a 0862; psubb xmm2, xmm0 ; h 0 g 0 f 0 e 0 d 0 c 0 b 0 a 0
769; psrlw xmm2, 8 ; 0 h 0 g 0 f 0 e 0 d 0 c 0 b 0 a863; psrlw xmm2, 8 ; 0 h 0 g 0 f 0 e 0 d 0 c 0 b 0 a
770 pavgb xmm0, xmm2864 pavgb xmm0, xmm2
771 865
772 movdqa xmm3, xmm1866 movdqa xmm3, xmm1
773 pshufb xmm1, xmm7867 pshufb xmm1, xmm5
774 pshufb xmm3, xmm6868 pshufb xmm3, xmm4
775; psubb xmm3, xmm1869; psubb xmm3, xmm1
776; psrlw xmm3, 8870; psrlw xmm3, 8
777 pavgb xmm1, xmm3871 pavgb xmm1, xmm3
@@ -780,38 +874,40 @@ WELS_EXTERN DyadicBilinearDownsamplerWidthx16_sse4 · 2 unmodified lines
780 packuswb xmm0, xmm1874 packuswb xmm0, xmm1
781 875
782 ; write pDst876 ; write pDst
783 movq [edi], xmm0877 movq [r0], xmm0
784 878
785 ; next SMB879 ; next SMB
786 lea esi, [esi+16]880 lea r2, [r2+16]
787 lea edi, [edi+8]881 lea r0, [r0+8]
788 882
789 dec eax883 dec r4
790 jg near .xloops884 jg near .xloops7
791 885
792 ; next line886 ; next line
793 lea esi, [esi+2*ecx] ; next end of lines887 lea r2, [r2+2*r3] ; next end of lines
794 lea esi, [esi+2*ebx] ; reset to base 0 [- 2 * iDstWidth]888 lea r2, [r2+2*r6] ; reset to base 0 [- 2 * iDstWidth]
795 lea edi, [edi+edx]889 lea r0, [r0+r1]
796 lea edi, [edi+ebx] ; reset to base 0 [- iDstWidth]890 lea r0, [r0+r6] ; 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
807 891
892 dec r5
893 jg near .yloops7
808 894
895%ifndef X86_32
896 pop r12
897%endif
809 898
899 POP_XMM
900 LOAD_6_PARA_POP
901%ifdef X86_32
902 pop r6
903%endif
904 ret
810 905
811 906
907%ifdef X86_32
812;**************************************************************************************************************908;**************************************************************************************************************
813;int GeneralBilinearAccurateDownsampler_sse2( unsigned char* pDst, const int iDstStride, const int iDstWidth, const int iDstHeight,909;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,
815; unsigned int uiScaleX, unsigned int uiScaleY );911; unsigned int uiScaleX, unsigned int uiScaleY );
816;{912;{
817;**************************************************************************************************************913;**************************************************************************************************************
@@ -822,26 +918,22 @@ WELS_EXTERN GeneralBilinearAccurateDownsampler_sse2 · 4 unmodified lines
822 push edi918 push edi
823 push ebx919 push ebx
824%define pushsize 16920%define pushsize 16
825%define localsize 28921%define localsize 16
826%define pDstData esp + pushsize + localsize + 4922%define pDstData esp + pushsize + localsize + 4
827%define dwDstStride esp + pushsize + localsize + 8923%define dwDstStride esp + pushsize + localsize + 8
828%define dwDstWidth esp + pushsize + localsize + 12924%define dwDstWidth esp + pushsize + localsize + 12
829%define dwDstHeight esp + pushsize + localsize + 16925%define dwDstHeight esp + pushsize + localsize + 16
830%define pSrcData esp + pushsize + localsize + 20926%define pSrcData esp + pushsize + localsize + 20
831%define dwSrcStride esp + pushsize + localsize + 24927%define dwSrcStride esp + pushsize + localsize + 24
832%define dwSrcWidth esp + pushsize + localsize + 28928%define uiScaleX esp + pushsize + localsize + 28
833%define dwSrcHeight esp + pushsize + localsize + 32929%define uiScaleY esp + pushsize + localsize + 32
834%define scale esp + 0930%define tmpHeight esp + 0
835%define uiScaleX esp + pushsize + localsize + 36931%define yInverse esp + 4
836%define uiScaleY esp + pushsize + localsize + 40932%define xInverse esp + 8
837%define tmpHeight esp + 12933%define dstStep esp + 12
838%define yInverse esp + 16
839%define xInverse esp + 20
840%define dstStep esp + 24
841 sub esp, localsize934 sub esp, localsize
842 935
843 pxor xmm0, xmm0936 pxor xmm0, xmm0
844 mov edx, 32767
845 mov eax, [uiScaleX]937 mov eax, [uiScaleX]
846 and eax, 32767938 and eax, 32767
847 mov ebx, eax939 mov ebx, eax
@@ -999,7 +1091,6 @@ LAST_ROW_END: · 151 unmodified lines
999%undef dwDstWidth1091%undef dwDstWidth
1000%undef dwDstHeight1092%undef dwDstHeight
1001%undef dwDstStride1093%undef dwDstStride
1002%undef scale
1003%undef uiScaleX1094%undef uiScaleX
1004%undef uiScaleY1095%undef uiScaleY
1005%undef tmpHeight1096%undef tmpHeight
@@ -1013,7 +1104,7 @@ LAST_ROW_END: · 7 unmodified lines
1013 1104
1014;**************************************************************************************************************1105;**************************************************************************************************************
1015;int GeneralBilinearFastDownsampler_sse2( unsigned char* pDst, const int iDstStride, const int iDstWidth, const int iDstHeight,1106;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,
1017; unsigned int uiScaleX, unsigned int uiScaleY );1108; unsigned int uiScaleX, unsigned int uiScaleY );
1018;{1109;{
1019;**************************************************************************************************************1110;**************************************************************************************************************
@@ -1024,22 +1115,19 @@ WELS_EXTERN GeneralBilinearFastDownsampler_sse2 · 4 unmodified lines
1024 push edi1115 push edi
1025 push ebx1116 push ebx
1026%define pushsize 161117%define pushsize 16
1027%define localsize 281118%define localsize 16
1028%define pDstData esp + pushsize + localsize + 41119%define pDstData esp + pushsize + localsize + 4
1029%define dwDstStride esp + pushsize + localsize + 81120%define dwDstStride esp + pushsize + localsize + 8
1030%define dwDstWidth esp + pushsize + localsize + 121121%define dwDstWidth esp + pushsize + localsize + 12
1031%define dwDstHeight esp + pushsize + localsize + 161122%define dwDstHeight esp + pushsize + localsize + 16
1032%define pSrcData esp + pushsize + localsize + 201123%define pSrcData esp + pushsize + localsize + 20
1033%define dwSrcStride esp + pushsize + localsize + 241124%define dwSrcStride esp + pushsize + localsize + 24
1034%define dwSrcWidth esp + pushsize + localsize + 281125%define uiScaleX esp + pushsize + localsize + 28
1035%define dwSrcHeight esp + pushsize + localsize + 321126%define uiScaleY esp + pushsize + localsize + 32
1036%define scale esp + 01127%define tmpHeight esp + 0
1037%define uiScaleX esp + pushsize + localsize + 361128%define yInverse esp + 4
1038%define uiScaleY esp + pushsize + localsize + 401129%define xInverse esp + 8
1039%define tmpHeight esp + 121130%define dstStep esp + 12
1040%define yInverse esp + 16
1041%define xInverse esp + 20
1042%define dstStep esp + 24
1043 sub esp, localsize1131 sub esp, localsize
1044 1132
1045 pxor xmm0, xmm01133 pxor xmm0, xmm0
@@ -1191,10 +1279,7 @@ FAST_LAST_ROW_END: · 145 unmodified lines
1191%undef dwSrcHeight1279%undef dwSrcHeight
1192%undef dwSrcStride1280%undef dwSrcStride
1193%undef pDstData1281%undef pDstData
1194%undef dwDstWidth
1195%undef dwDstHeight
1196%undef dwDstStride1282%undef dwDstStride
1197%undef scale
1198%undef uiScaleX1283%undef uiScaleX
1199%undef uiScaleY1284%undef uiScaleY
1200%undef tmpHeight1285%undef tmpHeight
@@ -1202,4 +1287,612 @@ FAST_LAST_ROW_END: · 1 unmodified line
1202%undef xInverse1287%undef xInverse
1203%undef dstStep1288%undef dstStep
1204 ret1289 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
1300WELS_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
1348DOWNSAMPLE:
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
1354HEIGHT:
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
1368WIDTH:
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
1405WIDTH_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
1420LAST_ROW:
1421 shr r14, 15
1422 imul r14, r5
1423 add r4, r14
1424 mov r15, 16384
1425
1426LAST_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
1437LAST_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
1457WELS_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
1504FAST_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
1512FAST_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
1526FAST_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
1555FAST_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
1571FAST_LAST_ROW:
1572 shr r14, 15
1573 imul r14, r5
1574 add r4, r14
1575 mov r15, 32768
1576
1577FAST_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
1588FAST_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
1610WELS_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
1655DOWNSAMPLE:
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
1661HEIGHT:
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
1675WIDTH:
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
1712WIDTH_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
1727LAST_ROW:
1728 shr r14, 15
1729 imul r14, r5
1730 add r4, r14
1731 mov r15, 16384
1732
1733LAST_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
1744LAST_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
1761WELS_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
1805FAST_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
1813FAST_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
1827FAST_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
1856FAST_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
1872FAST_LAST_ROW:
1873 shr r14, 15
1874 imul r14, r5
1875 add r4, r14
1876 mov r15, 32768
1877
1878FAST_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
1889FAST_LAST_ROW_END:
1890
1891 pop rbp
1892 pop rbx
1893 pop r15
1894 pop r14
1895 pop r13
1896 pop r12
1897 ret
1205%endif1898%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