Web Speech API: cancel outstanding infobar requests when aborting.
[chromium-blink-merge.git] / media / base / simd / linear_scale_yuv_to_rgb_mmx_x64.asm
blobf7e1d908549020fce8d2fcb9236fba9f887642d7
1 ; Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 ; Use of this source code is governed by a BSD-style license that can be
3 ; found in the LICENSE file.
5 %include "media/base/simd/media_export.asm"
6 %include "third_party/x86inc/x86inc.asm"
9 ; This file uses MMX instructions.
11 SECTION_TEXT
12 CPU MMX
14 ;void LinearScaleYUVToRGB32Row_MMX_X64(const uint8* y_buf,
15 ; const uint8* u_buf,
16 ; const uint8* v_buf,
17 ; uint8* rgb_buf,
18 ; ptrdiff_t width,
19 ; ptrdiff_t source_dx);
20 %define SYMBOL LinearScaleYUVToRGB32Row_MMX_X64
21 EXPORT SYMBOL
22 align function_align
24 mangle(SYMBOL):
25 %assign stack_offset 0
26 extern mangle(kCoefficientsRgbY)
28 ; Parameters are in the following order:
29 ; 1. Y plane
30 ; 2. U plane
31 ; 3. V plane
32 ; 4. ARGB frame
33 ; 5. Width
34 ; 6. Source dx
36 PROLOGUE 6, 7, 3, Y, U, V, ARGB, WIDTH, SOURCE_DX, COMPL
38 %define TABLEq r10
39 %define Xq r11
40 %define INDEXq r12
41 %define COMPRd r13d
42 %define COMPRq r13
43 %define FRACTIONq r14
45 PUSH TABLEq
46 PUSH Xq
47 PUSH INDEXq
48 PUSH COMPRq
49 PUSH FRACTIONq
51 %macro EPILOGUE 0
52 POP FRACTIONq
53 POP COMPRq
54 POP INDEXq
55 POP Xq
56 POP TABLEq
57 %endmacro
59 LOAD_SYM TABLEq, mangle(kCoefficientsRgbY)
61 imul WIDTHq, SOURCE_DXq ; source_width = width * source_dx
62 xor Xq, Xq ; x = 0
63 cmp SOURCE_DXq, 0x20000
64 jl .lscaleend
65 mov Xq, 0x8000 ; x = 0.5 for 1/2 or less
66 jmp .lscaleend
68 .lscaleloop:
69 ; Interpolate U
70 mov INDEXq, Xq
71 sar INDEXq, 0x11
72 movzx COMPLd, BYTE [Uq + INDEXq]
73 movzx COMPRd, BYTE [Uq + INDEXq + 1]
74 mov FRACTIONq, Xq
75 and FRACTIONq, 0x1fffe
76 imul COMPRq, FRACTIONq
77 xor FRACTIONq, 0x1fffe
78 imul COMPLq, FRACTIONq
79 add COMPLq, COMPRq
80 shr COMPLq, 17
81 movq mm0, [TABLEq + 2048 + 8 * COMPLq]
83 ; Interpolate V
84 movzx COMPLd, BYTE [Vq + INDEXq]
85 movzx COMPRd, BYTE [Vq + INDEXq + 1]
86 ; Trick here to imul COMPL first then COMPR.
87 ; Saves two instruction. :)
88 imul COMPLq, FRACTIONq
89 xor FRACTIONq, 0x1fffe
90 imul COMPRq, FRACTIONq
91 add COMPLq, COMPRq
92 shr COMPLq, 17
93 paddsw mm0, [TABLEq + 4096 + 8 * COMPLq]
95 ; Interpolate first Y1.
96 lea INDEXq, [Xq + SOURCE_DXq] ; INDEXq now points to next pixel.
97 ; Xq points to current pixel.
98 mov FRACTIONq, Xq
99 sar Xq, 0x10
100 movzx COMPLd, BYTE [Yq + Xq]
101 movzx COMPRd, BYTE [Yq + Xq + 1]
102 and FRACTIONq, 0xffff
103 imul COMPRq, FRACTIONq
104 xor FRACTIONq, 0xffff
105 imul COMPLq, FRACTIONq
106 add COMPLq, COMPRq
107 shr COMPLq, 16
108 movq mm1, [TABLEq + 8 * COMPLq]
110 ; Interpolate Y2 if available.
111 cmp INDEXq, WIDTHq
112 jge .lscalelastpixel
114 lea Xq, [INDEXq + SOURCE_DXq] ; Xq points to next pixel.
115 ; INDEXq points to current pixel.
116 mov FRACTIONq, INDEXq
117 sar INDEXq, 0x10
118 movzx COMPLd, BYTE [Yq + INDEXq]
119 movzx COMPRd, BYTE [Yq + INDEXq + 1]
120 and FRACTIONq, 0xffff
121 imul COMPRq, FRACTIONq
122 xor FRACTIONq, 0xffff
123 imul COMPLq, FRACTIONq
124 add COMPLq, COMPRq
125 shr COMPLq, 16
126 movq mm2, [TABLEq + 8 * COMPLq]
128 paddsw mm1, mm0
129 paddsw mm2, mm0
130 psraw mm1, 0x6
131 psraw mm2, 0x6
132 packuswb mm1, mm2
133 movntq [ARGBq], mm1
134 add ARGBq, 0x8
136 .lscaleend:
137 cmp Xq, WIDTHq
138 jl .lscaleloop
139 jmp .epilogue
141 .lscalelastpixel:
142 paddsw mm1, mm0
143 psraw mm1, 6
144 packuswb mm1, mm1
145 movd [ARGBq], mm1
147 .epilogue
148 EPILOGUE