Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(179)

Side by Side Diff: media/base/simd/convert_rgb_to_yuv_ssse3.inc

Issue 7003082: Implements RGB to YV12 conversion in YASM. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
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.
4
5 ;
6 ; void media::simd::ConvertARGBtoYUVRow(const uint8* argb,
7 ; uint8* y,
8 ; uint8* u,
9 ; uint8* v,
10 ; int width);
11 ; void media::simd::ConvertRGBtoYUVRow(const uint8* rgb,
12 ; uint8* y,
13 ; uint8* u,
14 ; uint8* v,
15 ; int width);
16 ;
17 global SYMBOL PRIVATE
18 align function_align
19
20 SYMBOL:
21 %assign stack_offset 0
22 PROLOGUE 5, 6, 8, ARGB, Y, U, V, WIDTH, TEMP
23
24 ; Initialize constants used in this function.
25 LOAD_SYM TEMPq, SIMD_ConvertARGBtoYUV_kTable
26 movdqa xmm0, DQWORD [TEMPq + 0]
27 pshufd XMM_CONST_Y0, xmm0, 00000000B
28 pshufd XMM_CONST_Y1, xmm0, 01010101B
29 pshufd XMM_CONST_U, xmm0, 10101010B
30 pshufd XMM_CONST_V, xmm0, 11111111B
31
32 movd XMM_CONST_128, [TEMPq + 16]
33 pshufd XMM_CONST_128, XMM_CONST_128, 00000000B
34
35 .convert_one_pixel:
36 ; Divide the input width by two so it represents the offsets for u[] and v[].
37 ; When the width is odd, We read the rightmost ARGB pixel and convert its
38 ; colorspace to YUV. This code stores one Y pixel, one U pixel, and one V
39 ; pixel.
40 sar WIDTHq, 1
41 jnc .convert_two_pixels
42
43 ; Read one ARGB (or RGB) pixel.
44 READ_ARGB xmm0, 1
45
46 ; Calculate y[0] from one RGB pixel read above.
47 CALC_Y xmm1, xmm0
48 movd TEMPd, xmm1
49 mov BYTE [Yq + WIDTHq * 2], TEMPb
50
51 ; Calculate u[0] from one RGB pixel read above. If this is an odd line, the
52 ; output pixel contains the U value calculated in the previous call. We also
53 ; read this pixel and calculate their average.
54 INIT_UV TEMPd, Uq, 4
55 CALC_UV xmm1, xmm0, XMM_CONST_U, TEMPd
56 movd TEMPd, xmm1
57 mov BYTE [Uq + WIDTHq], TEMPb
58
59 ; Calculate v[0] from one RGB pixel. Same as u[0], we read the result of the
60 ; previous call and get their average.
61 INIT_UV TEMPd, Uq, 4
62 CALC_UV xmm1, xmm0, XMM_CONST_V, TEMPd
63 movd TEMPd, xmm1
64 mov BYTE [Vq + WIDTHq], TEMPb
65
66 .convert_two_pixels:
67 ; If the input width is not a multiple of four, read the rightmost two ARGB
68 ; pixels and convert their colorspace to YUV. This code stores two Y pixels,
69 ; one U pixel, and one V pixel.
70 test WIDTHb, 2 / 2
71 jz .convert_four_pixels
72 sub WIDTHb, 2 / 2
73
74 ; Read two ARGB (or RGB) pixels.
75 READ_ARGB xmm0, 2
76
77 ; Calculate r[0] and r[1] from two RGB pixels read above.
78 CALC_Y xmm1, xmm0
79 movd TEMPd, xmm1
80 mov WORD [Yq + WIDTHq * 2], TEMPw
81
82 ; Skip calculating u and v if the output buffer is NULL.
83 test Uq, Uq
84 jz .convert_four_pixels
85
86 ; Calculate u[0] from two RGB pixels read above. (For details, read the above
87 ; comment in .convert_one_pixel).
88 INIT_UV TEMPd, Uq, 2
89 CALC_UV xmm1, xmm0, XMM_CONST_U, TEMPd
90 movd TEMPd, xmm1
91 mov BYTE [Uq + WIDTHq], TEMPb
92
93 ; Calculate v[0] from two RGB pixels read above.
94 INIT_UV TEMPd, Vq, 2
95 CALC_UV xmm1, xmm0, XMM_CONST_V, TEMPd
96 movd TEMPd, xmm1
97 mov BYTE [Vq + WIDTHq], TEMPb
98
99 .convert_four_pixels:
100 ; Read four ARGB pixels and convert their colorspace to YUV. This code stores
101 ; four Y pixels, two U pixels, and two V pixels.
102 test WIDTHq, WIDTHq
103 jz .convert_finish
104
105 %if PIXELSIZE == 4
106 ; Check if the input buffer is aligned to a 16-byte boundary and use movdqa
107 ; for reading the ARGB pixels.
108 test ARGBw, 15
109 jnz .convert_four_pixels_unaligned
110
111 .convert_four_pixels_aligned:
112 sub WIDTHq, 4 / 2
113
114 ; Read four ARGB pixels. (We can use movdqa here since we have checked if the
115 ; source address is aligned.)
116 movdqa xmm0, DQWORD [ARGBq + WIDTHq * 4 * 2]
117
118 ; Calculate y[0], y[1], y[2],and, y[3] from the input ARGB pixels.
119 CALC_Y xmm1, xmm0
120 movd DWORD [Yq + WIDTHq * 2], xmm1
121
122 %if SUBSAMPLING == 0
123 ; Skip calculating u and v if the output buffer is NULL, which means we are
124 ; converting an odd line. (When we enable subsampling, these buffers must
125 ; contain the u and v values for the previous call, i.e. these variables must
126 ; not be NULL.)
127 test Uq, Uq
128 jz .convert_four_pixels_aligned_next
129 %endif
130
131 ; Calculate u[0] and u[1] from four ARGB pixels read above.
132 INIT_UV TEMPd, Uq, 4
133 CALC_UV xmm1, xmm0, XMM_CONST_U, TEMPd
134 movd TEMPd, xmm1
135 mov WORD [Uq + WIDTHq], TEMPw
136
137 ; Calculate v[0] and v[1] from four ARGB pixels read above.
138 INIT_UV TEMPd, Vq, 4
139 CALC_UV xmm1, xmm0, XMM_CONST_V, TEMPd
140 movd TEMPd, xmm1
141 mov WORD [Vq + WIDTHq], TEMPw
142
143 %if SUBSAMPLING == 0
144 .convert_four_pixels_aligned_next:
145 %endif
146
147 test WIDTHq, WIDTHq
148 jnz .convert_four_pixels_aligned
149
150 jmp .convert_finish
151 %endif
152
153 .convert_four_pixels_unaligned:
154 sub WIDTHq, 4 / 2
155
156 ; Read four ARGB (or RGB) pixels.
157 READ_ARGB xmm0, 4
158
159 ; Calculate y[0], y[1], y[2],and, y[3] from the input ARGB pixels.
160 CALC_Y xmm1, xmm0
161 movd DWORD [Yq + WIDTHq * 2], xmm1
162
163 %if SUBSAMPLING == 0
164 ; Skip calculating u and v if the output buffer is NULL.
165 test Uq, Uq
166 jz .convert_four_pixels_unaligned_next
167 %endif
168
169 ; Calculate u[0] and u[1] from the input ARGB pixels.
170 INIT_UV TEMPd, Uq, 4
171 CALC_UV xmm1, xmm0, XMM_CONST_U, TEMPd
172 movd TEMPd, xmm1
173 mov WORD [Uq + WIDTHq], TEMPw
174
175 ; Calculate v[0] and v[1] from the input ARGB pixels.
176 INIT_UV TEMPd, Vq, 4
177 CALC_UV xmm1, xmm0, XMM_CONST_V, TEMPd
178 movd TEMPd, xmm1
179 mov WORD [Vq + WIDTHq], TEMPw
180
181 %if SUBSAMPLING == 0
182 .convert_four_pixels_unaligned_next:
183 %endif
184
185 test WIDTHq, WIDTHq
186 jnz .convert_four_pixels_unaligned
187
188 .convert_finish:
189 ; Just exit this function since this is a void function.
190 RET
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698