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

Side by Side Diff: source/convert_argb.cc

Issue 1363503002: yuvconstants for all YUV to RGB conversion functions. (Closed) Base URL: https://chromium.googlesource.com/libyuv/libyuv@master
Patch Set: mips dspr2 add constants parameter Created 5 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
« no previous file with comments | « include/libyuv/row.h ('k') | source/convert_from.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2011 The LibYuv Project Authors. All rights reserved. 2 * Copyright 2011 The LibYuv Project Authors. All rights reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source 5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
49 int I444ToARGB(const uint8* src_y, int src_stride_y, 49 int I444ToARGB(const uint8* src_y, int src_stride_y,
50 const uint8* src_u, int src_stride_u, 50 const uint8* src_u, int src_stride_u,
51 const uint8* src_v, int src_stride_v, 51 const uint8* src_v, int src_stride_v,
52 uint8* dst_argb, int dst_stride_argb, 52 uint8* dst_argb, int dst_stride_argb,
53 int width, int height) { 53 int width, int height) {
54 int y; 54 int y;
55 void (*I444ToARGBRow)(const uint8* y_buf, 55 void (*I444ToARGBRow)(const uint8* y_buf,
56 const uint8* u_buf, 56 const uint8* u_buf,
57 const uint8* v_buf, 57 const uint8* v_buf,
58 uint8* rgb_buf, 58 uint8* rgb_buf,
59 struct YuvConstants* yuvconstants,
59 int width) = I444ToARGBRow_C; 60 int width) = I444ToARGBRow_C;
60 if (!src_y || !src_u || !src_v || 61 if (!src_y || !src_u || !src_v ||
61 !dst_argb || 62 !dst_argb ||
62 width <= 0 || height == 0) { 63 width <= 0 || height == 0) {
63 return -1; 64 return -1;
64 } 65 }
65 // Negative height means invert the image. 66 // Negative height means invert the image.
66 if (height < 0) { 67 if (height < 0) {
67 height = -height; 68 height = -height;
68 dst_argb = dst_argb + (height - 1) * dst_stride_argb; 69 dst_argb = dst_argb + (height - 1) * dst_stride_argb;
(...skipping 27 matching lines...) Expand all
96 #if defined(HAS_I444TOARGBROW_NEON) 97 #if defined(HAS_I444TOARGBROW_NEON)
97 if (TestCpuFlag(kCpuHasNEON)) { 98 if (TestCpuFlag(kCpuHasNEON)) {
98 I444ToARGBRow = I444ToARGBRow_Any_NEON; 99 I444ToARGBRow = I444ToARGBRow_Any_NEON;
99 if (IS_ALIGNED(width, 8)) { 100 if (IS_ALIGNED(width, 8)) {
100 I444ToARGBRow = I444ToARGBRow_NEON; 101 I444ToARGBRow = I444ToARGBRow_NEON;
101 } 102 }
102 } 103 }
103 #endif 104 #endif
104 105
105 for (y = 0; y < height; ++y) { 106 for (y = 0; y < height; ++y) {
106 I444ToARGBRow(src_y, src_u, src_v, dst_argb, width); 107 I444ToARGBRow(src_y, src_u, src_v, dst_argb, &kYuvConstants, width);
107 dst_argb += dst_stride_argb; 108 dst_argb += dst_stride_argb;
108 src_y += src_stride_y; 109 src_y += src_stride_y;
109 src_u += src_stride_u; 110 src_u += src_stride_u;
110 src_v += src_stride_v; 111 src_v += src_stride_v;
111 } 112 }
112 return 0; 113 return 0;
113 } 114 }
114 115
115 // Convert I444 to ABGR. 116 // Convert I444 to ABGR.
116 LIBYUV_API 117 LIBYUV_API
117 int I444ToABGR(const uint8* src_y, int src_stride_y, 118 int I444ToABGR(const uint8* src_y, int src_stride_y,
118 const uint8* src_u, int src_stride_u, 119 const uint8* src_u, int src_stride_u,
119 const uint8* src_v, int src_stride_v, 120 const uint8* src_v, int src_stride_v,
120 uint8* dst_abgr, int dst_stride_abgr, 121 uint8* dst_abgr, int dst_stride_abgr,
121 int width, int height) { 122 int width, int height) {
122 int y; 123 int y;
123 void (*I444ToABGRRow)(const uint8* y_buf, 124 void (*I444ToABGRRow)(const uint8* y_buf,
124 const uint8* u_buf, 125 const uint8* u_buf,
125 const uint8* v_buf, 126 const uint8* v_buf,
126 uint8* rgb_buf, 127 uint8* rgb_buf,
128 struct YuvConstants* yuvconstants,
127 int width) = I444ToABGRRow_C; 129 int width) = I444ToABGRRow_C;
128 if (!src_y || !src_u || !src_v || 130 if (!src_y || !src_u || !src_v ||
129 !dst_abgr || 131 !dst_abgr ||
130 width <= 0 || height == 0) { 132 width <= 0 || height == 0) {
131 return -1; 133 return -1;
132 } 134 }
133 // Negative height means invert the image. 135 // Negative height means invert the image.
134 if (height < 0) { 136 if (height < 0) {
135 height = -height; 137 height = -height;
136 dst_abgr = dst_abgr + (height - 1) * dst_stride_abgr; 138 dst_abgr = dst_abgr + (height - 1) * dst_stride_abgr;
(...skipping 27 matching lines...) Expand all
164 #if defined(HAS_I444TOABGRROW_NEON) 166 #if defined(HAS_I444TOABGRROW_NEON)
165 if (TestCpuFlag(kCpuHasNEON)) { 167 if (TestCpuFlag(kCpuHasNEON)) {
166 I444ToABGRRow = I444ToABGRRow_Any_NEON; 168 I444ToABGRRow = I444ToABGRRow_Any_NEON;
167 if (IS_ALIGNED(width, 8)) { 169 if (IS_ALIGNED(width, 8)) {
168 I444ToABGRRow = I444ToABGRRow_NEON; 170 I444ToABGRRow = I444ToABGRRow_NEON;
169 } 171 }
170 } 172 }
171 #endif 173 #endif
172 174
173 for (y = 0; y < height; ++y) { 175 for (y = 0; y < height; ++y) {
174 I444ToABGRRow(src_y, src_u, src_v, dst_abgr, width); 176 I444ToABGRRow(src_y, src_u, src_v, dst_abgr, &kYuvConstants, width);
175 dst_abgr += dst_stride_abgr; 177 dst_abgr += dst_stride_abgr;
176 src_y += src_stride_y; 178 src_y += src_stride_y;
177 src_u += src_stride_u; 179 src_u += src_stride_u;
178 src_v += src_stride_v; 180 src_v += src_stride_v;
179 } 181 }
180 return 0; 182 return 0;
181 } 183 }
182 184
183 // Convert I422 to ARGB. 185 // Convert I422 to ARGB.
184 LIBYUV_API 186 LIBYUV_API
185 int I422ToARGB(const uint8* src_y, int src_stride_y, 187 int I422ToARGB(const uint8* src_y, int src_stride_y,
186 const uint8* src_u, int src_stride_u, 188 const uint8* src_u, int src_stride_u,
187 const uint8* src_v, int src_stride_v, 189 const uint8* src_v, int src_stride_v,
188 uint8* dst_argb, int dst_stride_argb, 190 uint8* dst_argb, int dst_stride_argb,
189 int width, int height) { 191 int width, int height) {
190 int y; 192 int y;
191 void (*I422ToARGBRow)(const uint8* y_buf, 193 void (*I422ToARGBRow)(const uint8* y_buf,
192 const uint8* u_buf, 194 const uint8* u_buf,
193 const uint8* v_buf, 195 const uint8* v_buf,
194 uint8* rgb_buf, 196 uint8* rgb_buf,
197 struct YuvConstants* yuvconstants,
195 int width) = I422ToARGBRow_C; 198 int width) = I422ToARGBRow_C;
196 if (!src_y || !src_u || !src_v || 199 if (!src_y || !src_u || !src_v ||
197 !dst_argb || 200 !dst_argb ||
198 width <= 0 || height == 0) { 201 width <= 0 || height == 0) {
199 return -1; 202 return -1;
200 } 203 }
201 // Negative height means invert the image. 204 // Negative height means invert the image.
202 if (height < 0) { 205 if (height < 0) {
203 height = -height; 206 height = -height;
204 dst_argb = dst_argb + (height - 1) * dst_stride_argb; 207 dst_argb = dst_argb + (height - 1) * dst_stride_argb;
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
241 if (TestCpuFlag(kCpuHasMIPS_DSPR2) && IS_ALIGNED(width, 4) && 244 if (TestCpuFlag(kCpuHasMIPS_DSPR2) && IS_ALIGNED(width, 4) &&
242 IS_ALIGNED(src_y, 4) && IS_ALIGNED(src_stride_y, 4) && 245 IS_ALIGNED(src_y, 4) && IS_ALIGNED(src_stride_y, 4) &&
243 IS_ALIGNED(src_u, 2) && IS_ALIGNED(src_stride_u, 2) && 246 IS_ALIGNED(src_u, 2) && IS_ALIGNED(src_stride_u, 2) &&
244 IS_ALIGNED(src_v, 2) && IS_ALIGNED(src_stride_v, 2) && 247 IS_ALIGNED(src_v, 2) && IS_ALIGNED(src_stride_v, 2) &&
245 IS_ALIGNED(dst_argb, 4) && IS_ALIGNED(dst_stride_argb, 4)) { 248 IS_ALIGNED(dst_argb, 4) && IS_ALIGNED(dst_stride_argb, 4)) {
246 I422ToARGBRow = I422ToARGBRow_MIPS_DSPR2; 249 I422ToARGBRow = I422ToARGBRow_MIPS_DSPR2;
247 } 250 }
248 #endif 251 #endif
249 252
250 for (y = 0; y < height; ++y) { 253 for (y = 0; y < height; ++y) {
251 I422ToARGBRow(src_y, src_u, src_v, dst_argb, width); 254 I422ToARGBRow(src_y, src_u, src_v, dst_argb, &kYuvConstants, width);
252 dst_argb += dst_stride_argb; 255 dst_argb += dst_stride_argb;
253 src_y += src_stride_y; 256 src_y += src_stride_y;
254 src_u += src_stride_u; 257 src_u += src_stride_u;
255 src_v += src_stride_v; 258 src_v += src_stride_v;
256 } 259 }
257 return 0; 260 return 0;
258 } 261 }
259 262
260 // Convert I411 to ARGB. 263 // Convert I411 to ARGB.
261 LIBYUV_API 264 LIBYUV_API
262 int I411ToARGB(const uint8* src_y, int src_stride_y, 265 int I411ToARGB(const uint8* src_y, int src_stride_y,
263 const uint8* src_u, int src_stride_u, 266 const uint8* src_u, int src_stride_u,
264 const uint8* src_v, int src_stride_v, 267 const uint8* src_v, int src_stride_v,
265 uint8* dst_argb, int dst_stride_argb, 268 uint8* dst_argb, int dst_stride_argb,
266 int width, int height) { 269 int width, int height) {
267 int y; 270 int y;
268 void (*I411ToARGBRow)(const uint8* y_buf, 271 void (*I411ToARGBRow)(const uint8* y_buf,
269 const uint8* u_buf, 272 const uint8* u_buf,
270 const uint8* v_buf, 273 const uint8* v_buf,
271 uint8* rgb_buf, 274 uint8* rgb_buf,
275 struct YuvConstants* yuvconstants,
272 int width) = I411ToARGBRow_C; 276 int width) = I411ToARGBRow_C;
273 if (!src_y || !src_u || !src_v || 277 if (!src_y || !src_u || !src_v ||
274 !dst_argb || 278 !dst_argb ||
275 width <= 0 || height == 0) { 279 width <= 0 || height == 0) {
276 return -1; 280 return -1;
277 } 281 }
278 // Negative height means invert the image. 282 // Negative height means invert the image.
279 if (height < 0) { 283 if (height < 0) {
280 height = -height; 284 height = -height;
281 dst_argb = dst_argb + (height - 1) * dst_stride_argb; 285 dst_argb = dst_argb + (height - 1) * dst_stride_argb;
(...skipping 27 matching lines...) Expand all
309 #if defined(HAS_I411TOARGBROW_NEON) 313 #if defined(HAS_I411TOARGBROW_NEON)
310 if (TestCpuFlag(kCpuHasNEON)) { 314 if (TestCpuFlag(kCpuHasNEON)) {
311 I411ToARGBRow = I411ToARGBRow_Any_NEON; 315 I411ToARGBRow = I411ToARGBRow_Any_NEON;
312 if (IS_ALIGNED(width, 8)) { 316 if (IS_ALIGNED(width, 8)) {
313 I411ToARGBRow = I411ToARGBRow_NEON; 317 I411ToARGBRow = I411ToARGBRow_NEON;
314 } 318 }
315 } 319 }
316 #endif 320 #endif
317 321
318 for (y = 0; y < height; ++y) { 322 for (y = 0; y < height; ++y) {
319 I411ToARGBRow(src_y, src_u, src_v, dst_argb, width); 323 I411ToARGBRow(src_y, src_u, src_v, dst_argb, &kYuvConstants, width);
320 dst_argb += dst_stride_argb; 324 dst_argb += dst_stride_argb;
321 src_y += src_stride_y; 325 src_y += src_stride_y;
322 src_u += src_stride_u; 326 src_u += src_stride_u;
323 src_v += src_stride_v; 327 src_v += src_stride_v;
324 } 328 }
325 return 0; 329 return 0;
326 } 330 }
327 331
328 // Convert I420 with Alpha to preattenuated ARGB. 332 // Convert I420 with Alpha to preattenuated ARGB.
329 LIBYUV_API 333 LIBYUV_API
330 int I420AlphaToARGB(const uint8* src_y, int src_stride_y, 334 int I420AlphaToARGB(const uint8* src_y, int src_stride_y,
331 const uint8* src_u, int src_stride_u, 335 const uint8* src_u, int src_stride_u,
332 const uint8* src_v, int src_stride_v, 336 const uint8* src_v, int src_stride_v,
333 const uint8* src_a, int src_stride_a, 337 const uint8* src_a, int src_stride_a,
334 uint8* dst_argb, int dst_stride_argb, 338 uint8* dst_argb, int dst_stride_argb,
335 int width, int height) { 339 int width, int height) {
336 int y; 340 int y;
337 void (*I422ToARGBRow)(const uint8* y_buf, 341 void (*I422ToARGBRow)(const uint8* y_buf,
338 const uint8* u_buf, 342 const uint8* u_buf,
339 const uint8* v_buf, 343 const uint8* v_buf,
340 uint8* rgb_buf, 344 uint8* rgb_buf,
345 struct YuvConstants* yuvconstants,
341 int width) = I422ToARGBRow_C; 346 int width) = I422ToARGBRow_C;
342 void (*ARGBCopyYToAlphaRow)(const uint8* src_y, uint8* dst_argb, int width) = 347 void (*ARGBCopyYToAlphaRow)(const uint8* src_y, uint8* dst_argb, int width) =
343 ARGBCopyYToAlphaRow_C; 348 ARGBCopyYToAlphaRow_C;
344 void (*ARGBAttenuateRow)(const uint8* src_argb, uint8* dst_argb, 349 void (*ARGBAttenuateRow)(const uint8* src_argb, uint8* dst_argb,
345 int width) = ARGBAttenuateRow_C; 350 int width) = ARGBAttenuateRow_C;
346 if (!src_y || !src_u || !src_v || !dst_argb || 351 if (!src_y || !src_u || !src_v || !dst_argb ||
347 width <= 0 || height == 0) { 352 width <= 0 || height == 0) {
348 return -1; 353 return -1;
349 } 354 }
350 // Negative height means invert the image. 355 // Negative height means invert the image.
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
429 #if defined(HAS_ARGBATTENUATEROW_NEON) 434 #if defined(HAS_ARGBATTENUATEROW_NEON)
430 if (TestCpuFlag(kCpuHasNEON)) { 435 if (TestCpuFlag(kCpuHasNEON)) {
431 ARGBAttenuateRow = ARGBAttenuateRow_Any_NEON; 436 ARGBAttenuateRow = ARGBAttenuateRow_Any_NEON;
432 if (IS_ALIGNED(width, 8)) { 437 if (IS_ALIGNED(width, 8)) {
433 ARGBAttenuateRow = ARGBAttenuateRow_NEON; 438 ARGBAttenuateRow = ARGBAttenuateRow_NEON;
434 } 439 }
435 } 440 }
436 #endif 441 #endif
437 442
438 for (y = 0; y < height; ++y) { 443 for (y = 0; y < height; ++y) {
439 I422ToARGBRow(src_y, src_u, src_v, dst_argb, width); 444 I422ToARGBRow(src_y, src_u, src_v, dst_argb, &kYuvConstants, width);
440 ARGBCopyYToAlphaRow(src_a, dst_argb, width); 445 ARGBCopyYToAlphaRow(src_a, dst_argb, width);
441 ARGBAttenuateRow(dst_argb, dst_argb, width); 446 ARGBAttenuateRow(dst_argb, dst_argb, width);
442 dst_argb += dst_stride_argb; 447 dst_argb += dst_stride_argb;
443 src_a += src_stride_a; 448 src_a += src_stride_a;
444 src_y += src_stride_y; 449 src_y += src_stride_y;
445 if (y & 1) { 450 if (y & 1) {
446 src_u += src_stride_u; 451 src_u += src_stride_u;
447 src_v += src_stride_v; 452 src_v += src_stride_v;
448 } 453 }
449 } 454 }
450 return 0; 455 return 0;
451 } 456 }
452 // Convert I420 with Alpha to preattenuated ABGR. 457 // Convert I420 with Alpha to preattenuated ABGR.
453 LIBYUV_API 458 LIBYUV_API
454 int I420AlphaToABGR(const uint8* src_y, int src_stride_y, 459 int I420AlphaToABGR(const uint8* src_y, int src_stride_y,
455 const uint8* src_u, int src_stride_u, 460 const uint8* src_u, int src_stride_u,
456 const uint8* src_v, int src_stride_v, 461 const uint8* src_v, int src_stride_v,
457 const uint8* src_a, int src_stride_a, 462 const uint8* src_a, int src_stride_a,
458 uint8* dst_abgr, int dst_stride_abgr, 463 uint8* dst_abgr, int dst_stride_abgr,
459 int width, int height) { 464 int width, int height) {
460 int y; 465 int y;
461 void (*I422ToABGRRow)(const uint8* y_buf, 466 void (*I422ToABGRRow)(const uint8* y_buf,
462 const uint8* u_buf, 467 const uint8* u_buf,
463 const uint8* v_buf, 468 const uint8* v_buf,
464 uint8* rgb_buf, 469 uint8* rgb_buf,
470 struct YuvConstants* yuvconstants,
465 int width) = I422ToABGRRow_C; 471 int width) = I422ToABGRRow_C;
466 void (*ARGBCopyYToAlphaRow)(const uint8* src_y, uint8* dst_argb, int width) = 472 void (*ARGBCopyYToAlphaRow)(const uint8* src_y, uint8* dst_argb, int width) =
467 ARGBCopyYToAlphaRow_C; 473 ARGBCopyYToAlphaRow_C;
468 void (*ARGBAttenuateRow)(const uint8* src_argb, uint8* dst_argb, 474 void (*ARGBAttenuateRow)(const uint8* src_argb, uint8* dst_argb,
469 int width) = ARGBAttenuateRow_C; 475 int width) = ARGBAttenuateRow_C;
470 if (!src_y || !src_u || !src_v || !dst_abgr || 476 if (!src_y || !src_u || !src_v || !dst_abgr ||
471 width <= 0 || height == 0) { 477 width <= 0 || height == 0) {
472 return -1; 478 return -1;
473 } 479 }
474 // Negative height means invert the image. 480 // Negative height means invert the image.
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
553 #if defined(HAS_ARGBATTENUATEROW_NEON) 559 #if defined(HAS_ARGBATTENUATEROW_NEON)
554 if (TestCpuFlag(kCpuHasNEON)) { 560 if (TestCpuFlag(kCpuHasNEON)) {
555 ARGBAttenuateRow = ARGBAttenuateRow_Any_NEON; 561 ARGBAttenuateRow = ARGBAttenuateRow_Any_NEON;
556 if (IS_ALIGNED(width, 8)) { 562 if (IS_ALIGNED(width, 8)) {
557 ARGBAttenuateRow = ARGBAttenuateRow_NEON; 563 ARGBAttenuateRow = ARGBAttenuateRow_NEON;
558 } 564 }
559 } 565 }
560 #endif 566 #endif
561 567
562 for (y = 0; y < height; ++y) { 568 for (y = 0; y < height; ++y) {
563 I422ToABGRRow(src_y, src_u, src_v, dst_abgr, width); 569 I422ToABGRRow(src_y, src_u, src_v, dst_abgr, &kYuvConstants, width);
564 ARGBCopyYToAlphaRow(src_a, dst_abgr, width); 570 ARGBCopyYToAlphaRow(src_a, dst_abgr, width);
565 ARGBAttenuateRow(dst_abgr, dst_abgr, width); 571 ARGBAttenuateRow(dst_abgr, dst_abgr, width);
566 dst_abgr += dst_stride_abgr; 572 dst_abgr += dst_stride_abgr;
567 src_a += src_stride_a; 573 src_a += src_stride_a;
568 src_y += src_stride_y; 574 src_y += src_stride_y;
569 if (y & 1) { 575 if (y & 1) {
570 src_u += src_stride_u; 576 src_u += src_stride_u;
571 src_v += src_stride_v; 577 src_v += src_stride_v;
572 } 578 }
573 } 579 }
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
632 } 638 }
633 return 0; 639 return 0;
634 } 640 }
635 641
636 // Convert J400 to ARGB. 642 // Convert J400 to ARGB.
637 LIBYUV_API 643 LIBYUV_API
638 int J400ToARGB(const uint8* src_y, int src_stride_y, 644 int J400ToARGB(const uint8* src_y, int src_stride_y,
639 uint8* dst_argb, int dst_stride_argb, 645 uint8* dst_argb, int dst_stride_argb,
640 int width, int height) { 646 int width, int height) {
641 int y; 647 int y;
642 void (*J400ToARGBRow)(const uint8* src_y, uint8* dst_argb, int pix) = 648 void (*J400ToARGBRow)(const uint8* src_y, uint8* dst_argb, int width) =
643 J400ToARGBRow_C; 649 J400ToARGBRow_C;
644 if (!src_y || !dst_argb || 650 if (!src_y || !dst_argb ||
645 width <= 0 || height == 0) { 651 width <= 0 || height == 0) {
646 return -1; 652 return -1;
647 } 653 }
648 // Negative height means invert the image. 654 // Negative height means invert the image.
649 if (height < 0) { 655 if (height < 0) {
650 height = -height; 656 height = -height;
651 src_y = src_y + (height - 1) * src_stride_y; 657 src_y = src_y + (height - 1) * src_stride_y;
652 src_stride_y = -src_stride_y; 658 src_stride_y = -src_stride_y;
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
759 (const uint8*)(&kShuffleMaskRGBAToARGB), 765 (const uint8*)(&kShuffleMaskRGBAToARGB),
760 width, height); 766 width, height);
761 } 767 }
762 768
763 // Convert RGB24 to ARGB. 769 // Convert RGB24 to ARGB.
764 LIBYUV_API 770 LIBYUV_API
765 int RGB24ToARGB(const uint8* src_rgb24, int src_stride_rgb24, 771 int RGB24ToARGB(const uint8* src_rgb24, int src_stride_rgb24,
766 uint8* dst_argb, int dst_stride_argb, 772 uint8* dst_argb, int dst_stride_argb,
767 int width, int height) { 773 int width, int height) {
768 int y; 774 int y;
769 void (*RGB24ToARGBRow)(const uint8* src_rgb, uint8* dst_argb, int pix) = 775 void (*RGB24ToARGBRow)(const uint8* src_rgb, uint8* dst_argb, int width) =
770 RGB24ToARGBRow_C; 776 RGB24ToARGBRow_C;
771 if (!src_rgb24 || !dst_argb || 777 if (!src_rgb24 || !dst_argb ||
772 width <= 0 || height == 0) { 778 width <= 0 || height == 0) {
773 return -1; 779 return -1;
774 } 780 }
775 // Negative height means invert the image. 781 // Negative height means invert the image.
776 if (height < 0) { 782 if (height < 0) {
777 height = -height; 783 height = -height;
778 src_rgb24 = src_rgb24 + (height - 1) * src_stride_rgb24; 784 src_rgb24 = src_rgb24 + (height - 1) * src_stride_rgb24;
779 src_stride_rgb24 = -src_stride_rgb24; 785 src_stride_rgb24 = -src_stride_rgb24;
(...skipping 29 matching lines...) Expand all
809 } 815 }
810 return 0; 816 return 0;
811 } 817 }
812 818
813 // Convert RAW to ARGB. 819 // Convert RAW to ARGB.
814 LIBYUV_API 820 LIBYUV_API
815 int RAWToARGB(const uint8* src_raw, int src_stride_raw, 821 int RAWToARGB(const uint8* src_raw, int src_stride_raw,
816 uint8* dst_argb, int dst_stride_argb, 822 uint8* dst_argb, int dst_stride_argb,
817 int width, int height) { 823 int width, int height) {
818 int y; 824 int y;
819 void (*RAWToARGBRow)(const uint8* src_rgb, uint8* dst_argb, int pix) = 825 void (*RAWToARGBRow)(const uint8* src_rgb, uint8* dst_argb, int width) =
820 RAWToARGBRow_C; 826 RAWToARGBRow_C;
821 if (!src_raw || !dst_argb || 827 if (!src_raw || !dst_argb ||
822 width <= 0 || height == 0) { 828 width <= 0 || height == 0) {
823 return -1; 829 return -1;
824 } 830 }
825 // Negative height means invert the image. 831 // Negative height means invert the image.
826 if (height < 0) { 832 if (height < 0) {
827 height = -height; 833 height = -height;
828 src_raw = src_raw + (height - 1) * src_stride_raw; 834 src_raw = src_raw + (height - 1) * src_stride_raw;
829 src_stride_raw = -src_stride_raw; 835 src_stride_raw = -src_stride_raw;
(...skipping 29 matching lines...) Expand all
859 } 865 }
860 return 0; 866 return 0;
861 } 867 }
862 868
863 // Convert RGB565 to ARGB. 869 // Convert RGB565 to ARGB.
864 LIBYUV_API 870 LIBYUV_API
865 int RGB565ToARGB(const uint8* src_rgb565, int src_stride_rgb565, 871 int RGB565ToARGB(const uint8* src_rgb565, int src_stride_rgb565,
866 uint8* dst_argb, int dst_stride_argb, 872 uint8* dst_argb, int dst_stride_argb,
867 int width, int height) { 873 int width, int height) {
868 int y; 874 int y;
869 void (*RGB565ToARGBRow)(const uint8* src_rgb565, uint8* dst_argb, int pix) = 875 void (*RGB565ToARGBRow)(const uint8* src_rgb565, uint8* dst_argb, int width) =
870 RGB565ToARGBRow_C; 876 RGB565ToARGBRow_C;
871 if (!src_rgb565 || !dst_argb || 877 if (!src_rgb565 || !dst_argb ||
872 width <= 0 || height == 0) { 878 width <= 0 || height == 0) {
873 return -1; 879 return -1;
874 } 880 }
875 // Negative height means invert the image. 881 // Negative height means invert the image.
876 if (height < 0) { 882 if (height < 0) {
877 height = -height; 883 height = -height;
878 src_rgb565 = src_rgb565 + (height - 1) * src_stride_rgb565; 884 src_rgb565 = src_rgb565 + (height - 1) * src_stride_rgb565;
879 src_stride_rgb565 = -src_stride_rgb565; 885 src_stride_rgb565 = -src_stride_rgb565;
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
918 return 0; 924 return 0;
919 } 925 }
920 926
921 // Convert ARGB1555 to ARGB. 927 // Convert ARGB1555 to ARGB.
922 LIBYUV_API 928 LIBYUV_API
923 int ARGB1555ToARGB(const uint8* src_argb1555, int src_stride_argb1555, 929 int ARGB1555ToARGB(const uint8* src_argb1555, int src_stride_argb1555,
924 uint8* dst_argb, int dst_stride_argb, 930 uint8* dst_argb, int dst_stride_argb,
925 int width, int height) { 931 int width, int height) {
926 int y; 932 int y;
927 void (*ARGB1555ToARGBRow)(const uint8* src_argb1555, uint8* dst_argb, 933 void (*ARGB1555ToARGBRow)(const uint8* src_argb1555, uint8* dst_argb,
928 int pix) = ARGB1555ToARGBRow_C; 934 int width) = ARGB1555ToARGBRow_C;
929 if (!src_argb1555 || !dst_argb || 935 if (!src_argb1555 || !dst_argb ||
930 width <= 0 || height == 0) { 936 width <= 0 || height == 0) {
931 return -1; 937 return -1;
932 } 938 }
933 // Negative height means invert the image. 939 // Negative height means invert the image.
934 if (height < 0) { 940 if (height < 0) {
935 height = -height; 941 height = -height;
936 src_argb1555 = src_argb1555 + (height - 1) * src_stride_argb1555; 942 src_argb1555 = src_argb1555 + (height - 1) * src_stride_argb1555;
937 src_stride_argb1555 = -src_stride_argb1555; 943 src_stride_argb1555 = -src_stride_argb1555;
938 } 944 }
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
976 return 0; 982 return 0;
977 } 983 }
978 984
979 // Convert ARGB4444 to ARGB. 985 // Convert ARGB4444 to ARGB.
980 LIBYUV_API 986 LIBYUV_API
981 int ARGB4444ToARGB(const uint8* src_argb4444, int src_stride_argb4444, 987 int ARGB4444ToARGB(const uint8* src_argb4444, int src_stride_argb4444,
982 uint8* dst_argb, int dst_stride_argb, 988 uint8* dst_argb, int dst_stride_argb,
983 int width, int height) { 989 int width, int height) {
984 int y; 990 int y;
985 void (*ARGB4444ToARGBRow)(const uint8* src_argb4444, uint8* dst_argb, 991 void (*ARGB4444ToARGBRow)(const uint8* src_argb4444, uint8* dst_argb,
986 int pix) = ARGB4444ToARGBRow_C; 992 int width) = ARGB4444ToARGBRow_C;
987 if (!src_argb4444 || !dst_argb || 993 if (!src_argb4444 || !dst_argb ||
988 width <= 0 || height == 0) { 994 width <= 0 || height == 0) {
989 return -1; 995 return -1;
990 } 996 }
991 // Negative height means invert the image. 997 // Negative height means invert the image.
992 if (height < 0) { 998 if (height < 0) {
993 height = -height; 999 height = -height;
994 src_argb4444 = src_argb4444 + (height - 1) * src_stride_argb4444; 1000 src_argb4444 = src_argb4444 + (height - 1) * src_stride_argb4444;
995 src_stride_argb4444 = -src_stride_argb4444; 1001 src_stride_argb4444 = -src_stride_argb4444;
996 } 1002 }
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
1037 // Convert NV12 to ARGB. 1043 // Convert NV12 to ARGB.
1038 LIBYUV_API 1044 LIBYUV_API
1039 int NV12ToARGB(const uint8* src_y, int src_stride_y, 1045 int NV12ToARGB(const uint8* src_y, int src_stride_y,
1040 const uint8* src_uv, int src_stride_uv, 1046 const uint8* src_uv, int src_stride_uv,
1041 uint8* dst_argb, int dst_stride_argb, 1047 uint8* dst_argb, int dst_stride_argb,
1042 int width, int height) { 1048 int width, int height) {
1043 int y; 1049 int y;
1044 void (*NV12ToARGBRow)(const uint8* y_buf, 1050 void (*NV12ToARGBRow)(const uint8* y_buf,
1045 const uint8* uv_buf, 1051 const uint8* uv_buf,
1046 uint8* rgb_buf, 1052 uint8* rgb_buf,
1053 struct YuvConstants* yuvconstants,
1047 int width) = NV12ToARGBRow_C; 1054 int width) = NV12ToARGBRow_C;
1048 if (!src_y || !src_uv || !dst_argb || 1055 if (!src_y || !src_uv || !dst_argb ||
1049 width <= 0 || height == 0) { 1056 width <= 0 || height == 0) {
1050 return -1; 1057 return -1;
1051 } 1058 }
1052 // Negative height means invert the image. 1059 // Negative height means invert the image.
1053 if (height < 0) { 1060 if (height < 0) {
1054 height = -height; 1061 height = -height;
1055 dst_argb = dst_argb + (height - 1) * dst_stride_argb; 1062 dst_argb = dst_argb + (height - 1) * dst_stride_argb;
1056 dst_stride_argb = -dst_stride_argb; 1063 dst_stride_argb = -dst_stride_argb;
(...skipping 17 matching lines...) Expand all
1074 #if defined(HAS_NV12TOARGBROW_NEON) 1081 #if defined(HAS_NV12TOARGBROW_NEON)
1075 if (TestCpuFlag(kCpuHasNEON)) { 1082 if (TestCpuFlag(kCpuHasNEON)) {
1076 NV12ToARGBRow = NV12ToARGBRow_Any_NEON; 1083 NV12ToARGBRow = NV12ToARGBRow_Any_NEON;
1077 if (IS_ALIGNED(width, 8)) { 1084 if (IS_ALIGNED(width, 8)) {
1078 NV12ToARGBRow = NV12ToARGBRow_NEON; 1085 NV12ToARGBRow = NV12ToARGBRow_NEON;
1079 } 1086 }
1080 } 1087 }
1081 #endif 1088 #endif
1082 1089
1083 for (y = 0; y < height; ++y) { 1090 for (y = 0; y < height; ++y) {
1084 NV12ToARGBRow(src_y, src_uv, dst_argb, width); 1091 NV12ToARGBRow(src_y, src_uv, dst_argb, &kYuvConstants, width);
1085 dst_argb += dst_stride_argb; 1092 dst_argb += dst_stride_argb;
1086 src_y += src_stride_y; 1093 src_y += src_stride_y;
1087 if (y & 1) { 1094 if (y & 1) {
1088 src_uv += src_stride_uv; 1095 src_uv += src_stride_uv;
1089 } 1096 }
1090 } 1097 }
1091 return 0; 1098 return 0;
1092 } 1099 }
1093 1100
1094 // Convert NV21 to ARGB. 1101 // Convert NV21 to ARGB.
1095 LIBYUV_API 1102 LIBYUV_API
1096 int NV21ToARGB(const uint8* src_y, int src_stride_y, 1103 int NV21ToARGB(const uint8* src_y, int src_stride_y,
1097 const uint8* src_uv, int src_stride_uv, 1104 const uint8* src_uv, int src_stride_uv,
1098 uint8* dst_argb, int dst_stride_argb, 1105 uint8* dst_argb, int dst_stride_argb,
1099 int width, int height) { 1106 int width, int height) {
1100 int y; 1107 int y;
1101 void (*NV21ToARGBRow)(const uint8* y_buf, 1108 void (*NV12ToARGBRow)(const uint8* y_buf,
1102 const uint8* uv_buf, 1109 const uint8* uv_buf,
1103 uint8* rgb_buf, 1110 uint8* rgb_buf,
1104 int width) = NV21ToARGBRow_C; 1111 struct YuvConstants* yuvconstants,
1112 int width) = NV12ToARGBRow_C;
1105 if (!src_y || !src_uv || !dst_argb || 1113 if (!src_y || !src_uv || !dst_argb ||
1106 width <= 0 || height == 0) { 1114 width <= 0 || height == 0) {
1107 return -1; 1115 return -1;
1108 } 1116 }
1109 // Negative height means invert the image. 1117 // Negative height means invert the image.
1110 if (height < 0) { 1118 if (height < 0) {
1111 height = -height; 1119 height = -height;
1112 dst_argb = dst_argb + (height - 1) * dst_stride_argb; 1120 dst_argb = dst_argb + (height - 1) * dst_stride_argb;
1113 dst_stride_argb = -dst_stride_argb; 1121 dst_stride_argb = -dst_stride_argb;
1114 } 1122 }
1115 #if defined(HAS_NV21TOARGBROW_SSSE3) 1123 #if defined(HAS_NV12TOARGBROW_SSSE3)
1116 if (TestCpuFlag(kCpuHasSSSE3)) { 1124 if (TestCpuFlag(kCpuHasSSSE3)) {
1117 NV21ToARGBRow = NV21ToARGBRow_Any_SSSE3; 1125 NV12ToARGBRow = NV12ToARGBRow_Any_SSSE3;
1118 if (IS_ALIGNED(width, 8)) { 1126 if (IS_ALIGNED(width, 8)) {
1119 NV21ToARGBRow = NV21ToARGBRow_SSSE3; 1127 NV12ToARGBRow = NV12ToARGBRow_SSSE3;
1120 } 1128 }
1121 } 1129 }
1122 #endif 1130 #endif
1123 #if defined(HAS_NV21TOARGBROW_AVX2) 1131 #if defined(HAS_NV12TOARGBROW_AVX2)
1124 if (TestCpuFlag(kCpuHasAVX2)) { 1132 if (TestCpuFlag(kCpuHasAVX2)) {
1125 NV21ToARGBRow = NV21ToARGBRow_Any_AVX2; 1133 NV12ToARGBRow = NV12ToARGBRow_Any_AVX2;
1126 if (IS_ALIGNED(width, 16)) { 1134 if (IS_ALIGNED(width, 16)) {
1127 NV21ToARGBRow = NV21ToARGBRow_AVX2; 1135 NV12ToARGBRow = NV12ToARGBRow_AVX2;
1128 } 1136 }
1129 } 1137 }
1130 #endif 1138 #endif
1131 #if defined(HAS_NV21TOARGBROW_NEON) 1139 #if defined(HAS_NV12TOARGBROW_NEON)
1132 if (TestCpuFlag(kCpuHasNEON)) { 1140 if (TestCpuFlag(kCpuHasNEON)) {
1133 NV21ToARGBRow = NV21ToARGBRow_Any_NEON; 1141 NV12ToARGBRow = NV12ToARGBRow_Any_NEON;
1134 if (IS_ALIGNED(width, 8)) { 1142 if (IS_ALIGNED(width, 8)) {
1135 NV21ToARGBRow = NV21ToARGBRow_NEON; 1143 NV12ToARGBRow = NV12ToARGBRow_NEON;
1136 } 1144 }
1137 } 1145 }
1138 #endif 1146 #endif
1139 1147
1140 for (y = 0; y < height; ++y) { 1148 for (y = 0; y < height; ++y) {
1141 NV21ToARGBRow(src_y, src_uv, dst_argb, width); 1149 NV12ToARGBRow(src_y, src_uv, dst_argb, &kYvuConstants, width);
1142 dst_argb += dst_stride_argb; 1150 dst_argb += dst_stride_argb;
1143 src_y += src_stride_y; 1151 src_y += src_stride_y;
1144 if (y & 1) { 1152 if (y & 1) {
1145 src_uv += src_stride_uv; 1153 src_uv += src_stride_uv;
1146 } 1154 }
1147 } 1155 }
1148 return 0; 1156 return 0;
1149 } 1157 }
1150 1158
1151 // Convert M420 to ARGB. 1159 // Convert M420 to ARGB.
1152 LIBYUV_API 1160 LIBYUV_API
1153 int M420ToARGB(const uint8* src_m420, int src_stride_m420, 1161 int M420ToARGB(const uint8* src_m420, int src_stride_m420,
1154 uint8* dst_argb, int dst_stride_argb, 1162 uint8* dst_argb, int dst_stride_argb,
1155 int width, int height) { 1163 int width, int height) {
1156 int y; 1164 int y;
1157 void (*NV12ToARGBRow)(const uint8* y_buf, 1165 void (*NV12ToARGBRow)(const uint8* y_buf,
1158 const uint8* uv_buf, 1166 const uint8* uv_buf,
1159 uint8* rgb_buf, 1167 uint8* rgb_buf,
1168 struct YuvConstants* yuvconstants,
1160 int width) = NV12ToARGBRow_C; 1169 int width) = NV12ToARGBRow_C;
1161 if (!src_m420 || !dst_argb || 1170 if (!src_m420 || !dst_argb ||
1162 width <= 0 || height == 0) { 1171 width <= 0 || height == 0) {
1163 return -1; 1172 return -1;
1164 } 1173 }
1165 // Negative height means invert the image. 1174 // Negative height means invert the image.
1166 if (height < 0) { 1175 if (height < 0) {
1167 height = -height; 1176 height = -height;
1168 dst_argb = dst_argb + (height - 1) * dst_stride_argb; 1177 dst_argb = dst_argb + (height - 1) * dst_stride_argb;
1169 dst_stride_argb = -dst_stride_argb; 1178 dst_stride_argb = -dst_stride_argb;
(...skipping 17 matching lines...) Expand all
1187 #if defined(HAS_NV12TOARGBROW_NEON) 1196 #if defined(HAS_NV12TOARGBROW_NEON)
1188 if (TestCpuFlag(kCpuHasNEON)) { 1197 if (TestCpuFlag(kCpuHasNEON)) {
1189 NV12ToARGBRow = NV12ToARGBRow_Any_NEON; 1198 NV12ToARGBRow = NV12ToARGBRow_Any_NEON;
1190 if (IS_ALIGNED(width, 8)) { 1199 if (IS_ALIGNED(width, 8)) {
1191 NV12ToARGBRow = NV12ToARGBRow_NEON; 1200 NV12ToARGBRow = NV12ToARGBRow_NEON;
1192 } 1201 }
1193 } 1202 }
1194 #endif 1203 #endif
1195 1204
1196 for (y = 0; y < height - 1; y += 2) { 1205 for (y = 0; y < height - 1; y += 2) {
1197 NV12ToARGBRow(src_m420, src_m420 + src_stride_m420 * 2, dst_argb, width); 1206 NV12ToARGBRow(src_m420, src_m420 + src_stride_m420 * 2, dst_argb,
1207 &kYuvConstants, width);
1198 NV12ToARGBRow(src_m420 + src_stride_m420, src_m420 + src_stride_m420 * 2, 1208 NV12ToARGBRow(src_m420 + src_stride_m420, src_m420 + src_stride_m420 * 2,
1199 dst_argb + dst_stride_argb, width); 1209 dst_argb + dst_stride_argb, &kYuvConstants, width);
1200 dst_argb += dst_stride_argb * 2; 1210 dst_argb += dst_stride_argb * 2;
1201 src_m420 += src_stride_m420 * 3; 1211 src_m420 += src_stride_m420 * 3;
1202 } 1212 }
1203 if (height & 1) { 1213 if (height & 1) {
1204 NV12ToARGBRow(src_m420, src_m420 + src_stride_m420 * 2, dst_argb, width); 1214 NV12ToARGBRow(src_m420, src_m420 + src_stride_m420 * 2, dst_argb,
1215 &kYuvConstants, width);
1205 } 1216 }
1206 return 0; 1217 return 0;
1207 } 1218 }
1208 1219
1209 // Convert YUY2 to ARGB. 1220 // Convert YUY2 to ARGB.
1210 LIBYUV_API 1221 LIBYUV_API
1211 int YUY2ToARGB(const uint8* src_yuy2, int src_stride_yuy2, 1222 int YUY2ToARGB(const uint8* src_yuy2, int src_stride_yuy2,
1212 uint8* dst_argb, int dst_stride_argb, 1223 uint8* dst_argb, int dst_stride_argb,
1213 int width, int height) { 1224 int width, int height) {
1214 int y; 1225 int y;
1215 void (*YUY2ToARGBRow)(const uint8* src_yuy2, uint8* dst_argb, int pix) = 1226 void (*YUY2ToARGBRow)(const uint8* src_yuy2,
1227 uint8* dst_argb,
1228 struct YuvConstants* yuvconstants,
1229 int width) =
1216 YUY2ToARGBRow_C; 1230 YUY2ToARGBRow_C;
1217 if (!src_yuy2 || !dst_argb || 1231 if (!src_yuy2 || !dst_argb ||
1218 width <= 0 || height == 0) { 1232 width <= 0 || height == 0) {
1219 return -1; 1233 return -1;
1220 } 1234 }
1221 // Negative height means invert the image. 1235 // Negative height means invert the image.
1222 if (height < 0) { 1236 if (height < 0) {
1223 height = -height; 1237 height = -height;
1224 src_yuy2 = src_yuy2 + (height - 1) * src_stride_yuy2; 1238 src_yuy2 = src_yuy2 + (height - 1) * src_stride_yuy2;
1225 src_stride_yuy2 = -src_stride_yuy2; 1239 src_stride_yuy2 = -src_stride_yuy2;
(...skipping 23 matching lines...) Expand all
1249 #endif 1263 #endif
1250 #if defined(HAS_YUY2TOARGBROW_NEON) 1264 #if defined(HAS_YUY2TOARGBROW_NEON)
1251 if (TestCpuFlag(kCpuHasNEON)) { 1265 if (TestCpuFlag(kCpuHasNEON)) {
1252 YUY2ToARGBRow = YUY2ToARGBRow_Any_NEON; 1266 YUY2ToARGBRow = YUY2ToARGBRow_Any_NEON;
1253 if (IS_ALIGNED(width, 8)) { 1267 if (IS_ALIGNED(width, 8)) {
1254 YUY2ToARGBRow = YUY2ToARGBRow_NEON; 1268 YUY2ToARGBRow = YUY2ToARGBRow_NEON;
1255 } 1269 }
1256 } 1270 }
1257 #endif 1271 #endif
1258 for (y = 0; y < height; ++y) { 1272 for (y = 0; y < height; ++y) {
1259 YUY2ToARGBRow(src_yuy2, dst_argb, width); 1273 YUY2ToARGBRow(src_yuy2, dst_argb, &kYuvConstants, width);
1260 src_yuy2 += src_stride_yuy2; 1274 src_yuy2 += src_stride_yuy2;
1261 dst_argb += dst_stride_argb; 1275 dst_argb += dst_stride_argb;
1262 } 1276 }
1263 return 0; 1277 return 0;
1264 } 1278 }
1265 1279
1266 // Convert UYVY to ARGB. 1280 // Convert UYVY to ARGB.
1267 LIBYUV_API 1281 LIBYUV_API
1268 int UYVYToARGB(const uint8* src_uyvy, int src_stride_uyvy, 1282 int UYVYToARGB(const uint8* src_uyvy, int src_stride_uyvy,
1269 uint8* dst_argb, int dst_stride_argb, 1283 uint8* dst_argb, int dst_stride_argb,
1270 int width, int height) { 1284 int width, int height) {
1271 int y; 1285 int y;
1272 void (*UYVYToARGBRow)(const uint8* src_uyvy, uint8* dst_argb, int pix) = 1286 void (*UYVYToARGBRow)(const uint8* src_uyvy,
1287 uint8* dst_argb,
1288 struct YuvConstants* yuvconstants,
1289 int width) =
1273 UYVYToARGBRow_C; 1290 UYVYToARGBRow_C;
1274 if (!src_uyvy || !dst_argb || 1291 if (!src_uyvy || !dst_argb ||
1275 width <= 0 || height == 0) { 1292 width <= 0 || height == 0) {
1276 return -1; 1293 return -1;
1277 } 1294 }
1278 // Negative height means invert the image. 1295 // Negative height means invert the image.
1279 if (height < 0) { 1296 if (height < 0) {
1280 height = -height; 1297 height = -height;
1281 src_uyvy = src_uyvy + (height - 1) * src_stride_uyvy; 1298 src_uyvy = src_uyvy + (height - 1) * src_stride_uyvy;
1282 src_stride_uyvy = -src_stride_uyvy; 1299 src_stride_uyvy = -src_stride_uyvy;
(...skipping 23 matching lines...) Expand all
1306 #endif 1323 #endif
1307 #if defined(HAS_UYVYTOARGBROW_NEON) 1324 #if defined(HAS_UYVYTOARGBROW_NEON)
1308 if (TestCpuFlag(kCpuHasNEON)) { 1325 if (TestCpuFlag(kCpuHasNEON)) {
1309 UYVYToARGBRow = UYVYToARGBRow_Any_NEON; 1326 UYVYToARGBRow = UYVYToARGBRow_Any_NEON;
1310 if (IS_ALIGNED(width, 8)) { 1327 if (IS_ALIGNED(width, 8)) {
1311 UYVYToARGBRow = UYVYToARGBRow_NEON; 1328 UYVYToARGBRow = UYVYToARGBRow_NEON;
1312 } 1329 }
1313 } 1330 }
1314 #endif 1331 #endif
1315 for (y = 0; y < height; ++y) { 1332 for (y = 0; y < height; ++y) {
1316 UYVYToARGBRow(src_uyvy, dst_argb, width); 1333 UYVYToARGBRow(src_uyvy, dst_argb, &kYuvConstants, width);
1317 src_uyvy += src_stride_uyvy; 1334 src_uyvy += src_stride_uyvy;
1318 dst_argb += dst_stride_argb; 1335 dst_argb += dst_stride_argb;
1319 } 1336 }
1320 return 0; 1337 return 0;
1321 } 1338 }
1322 1339
1323 // Convert J420 to ARGB. 1340 // Convert J420 to ARGB.
1324 LIBYUV_API 1341 LIBYUV_API
1325 int J420ToARGB(const uint8* src_y, int src_stride_y, 1342 int J420ToARGB(const uint8* src_y, int src_stride_y,
1326 const uint8* src_u, int src_stride_u, 1343 const uint8* src_u, int src_stride_u,
1327 const uint8* src_v, int src_stride_v, 1344 const uint8* src_v, int src_stride_v,
1328 uint8* dst_argb, int dst_stride_argb, 1345 uint8* dst_argb, int dst_stride_argb,
1329 int width, int height) { 1346 int width, int height) {
1330 int y; 1347 int y;
1331 void (*J422ToARGBRow)(const uint8* y_buf, 1348 void (*I422ToARGBRow)(const uint8* y_buf,
1332 const uint8* u_buf, 1349 const uint8* u_buf,
1333 const uint8* v_buf, 1350 const uint8* v_buf,
1334 uint8* rgb_buf, 1351 uint8* rgb_buf,
1335 int width) = J422ToARGBRow_C; 1352 struct YuvConstants* yuvconstants,
1353 int width) = I422ToARGBRow_C;
1336 if (!src_y || !src_u || !src_v || !dst_argb || 1354 if (!src_y || !src_u || !src_v || !dst_argb ||
1337 width <= 0 || height == 0) { 1355 width <= 0 || height == 0) {
1338 return -1; 1356 return -1;
1339 } 1357 }
1340 // Negative height means invert the image. 1358 // Negative height means invert the image.
1341 if (height < 0) { 1359 if (height < 0) {
1342 height = -height; 1360 height = -height;
1343 dst_argb = dst_argb + (height - 1) * dst_stride_argb; 1361 dst_argb = dst_argb + (height - 1) * dst_stride_argb;
1344 dst_stride_argb = -dst_stride_argb; 1362 dst_stride_argb = -dst_stride_argb;
1345 } 1363 }
1346 #if defined(HAS_J422TOARGBROW_SSSE3) 1364 #if defined(HAS_I422TOARGBROW_SSSE3)
1347 if (TestCpuFlag(kCpuHasSSSE3)) { 1365 if (TestCpuFlag(kCpuHasSSSE3)) {
1348 J422ToARGBRow = J422ToARGBRow_Any_SSSE3; 1366 I422ToARGBRow = I422ToARGBRow_Any_SSSE3;
1349 if (IS_ALIGNED(width, 8)) { 1367 if (IS_ALIGNED(width, 8)) {
1350 J422ToARGBRow = J422ToARGBRow_SSSE3; 1368 I422ToARGBRow = I422ToARGBRow_SSSE3;
1351 } 1369 }
1352 } 1370 }
1353 #endif 1371 #endif
1354 #if defined(HAS_J422TOARGBROW_AVX2) 1372 #if defined(HAS_I422TOARGBROW_AVX2)
1355 if (TestCpuFlag(kCpuHasAVX2)) { 1373 if (TestCpuFlag(kCpuHasAVX2)) {
1356 J422ToARGBRow = J422ToARGBRow_Any_AVX2; 1374 I422ToARGBRow = I422ToARGBRow_Any_AVX2;
1357 if (IS_ALIGNED(width, 16)) { 1375 if (IS_ALIGNED(width, 16)) {
1358 J422ToARGBRow = J422ToARGBRow_AVX2; 1376 I422ToARGBRow = I422ToARGBRow_AVX2;
1359 } 1377 }
1360 } 1378 }
1361 #endif 1379 #endif
1362 #if defined(HAS_J422TOARGBROW_NEON) 1380 #if defined(HAS_I422TOARGBROW_NEON)
1363 if (TestCpuFlag(kCpuHasNEON)) { 1381 if (TestCpuFlag(kCpuHasNEON)) {
1364 J422ToARGBRow = J422ToARGBRow_Any_NEON; 1382 I422ToARGBRow = I422ToARGBRow_Any_NEON;
1365 if (IS_ALIGNED(width, 8)) { 1383 if (IS_ALIGNED(width, 8)) {
1366 J422ToARGBRow = J422ToARGBRow_NEON; 1384 I422ToARGBRow = I422ToARGBRow_NEON;
1367 } 1385 }
1368 } 1386 }
1369 #endif 1387 #endif
1370 #if defined(HAS_J422TOARGBROW_MIPS_DSPR2) 1388 #if defined(HAS_I422TOARGBROW_MIPS_DSPR2)
1371 if (TestCpuFlag(kCpuHasMIPS_DSPR2) && IS_ALIGNED(width, 4) && 1389 if (TestCpuFlag(kCpuHasMIPS_DSPR2) && IS_ALIGNED(width, 4) &&
1372 IS_ALIGNED(src_y, 4) && IS_ALIGNED(src_stride_y, 4) && 1390 IS_ALIGNED(src_y, 4) && IS_ALIGNED(src_stride_y, 4) &&
1373 IS_ALIGNED(src_u, 2) && IS_ALIGNED(src_stride_u, 2) && 1391 IS_ALIGNED(src_u, 2) && IS_ALIGNED(src_stride_u, 2) &&
1374 IS_ALIGNED(src_v, 2) && IS_ALIGNED(src_stride_v, 2) && 1392 IS_ALIGNED(src_v, 2) && IS_ALIGNED(src_stride_v, 2) &&
1375 IS_ALIGNED(dst_argb, 4) && IS_ALIGNED(dst_stride_argb, 4)) { 1393 IS_ALIGNED(dst_argb, 4) && IS_ALIGNED(dst_stride_argb, 4)) {
1376 J422ToARGBRow = J422ToARGBRow_MIPS_DSPR2; 1394 I422ToARGBRow = I422ToARGBRow_MIPS_DSPR2;
1377 } 1395 }
1378 #endif 1396 #endif
1379 1397
1380 for (y = 0; y < height; ++y) { 1398 for (y = 0; y < height; ++y) {
1381 J422ToARGBRow(src_y, src_u, src_v, dst_argb, width); 1399 I422ToARGBRow(src_y, src_u, src_v, dst_argb, &kYuvJConstants, width);
1382 dst_argb += dst_stride_argb; 1400 dst_argb += dst_stride_argb;
1383 src_y += src_stride_y; 1401 src_y += src_stride_y;
1384 if (y & 1) { 1402 if (y & 1) {
1385 src_u += src_stride_u; 1403 src_u += src_stride_u;
1386 src_v += src_stride_v; 1404 src_v += src_stride_v;
1387 } 1405 }
1388 } 1406 }
1389 return 0; 1407 return 0;
1390 } 1408 }
1391 1409
1392 // Convert J422 to ARGB. 1410 // Convert J422 to ARGB.
1393 LIBYUV_API 1411 LIBYUV_API
1394 int J422ToARGB(const uint8* src_y, int src_stride_y, 1412 int J422ToARGB(const uint8* src_y, int src_stride_y,
1395 const uint8* src_u, int src_stride_u, 1413 const uint8* src_u, int src_stride_u,
1396 const uint8* src_v, int src_stride_v, 1414 const uint8* src_v, int src_stride_v,
1397 uint8* dst_argb, int dst_stride_argb, 1415 uint8* dst_argb, int dst_stride_argb,
1398 int width, int height) { 1416 int width, int height) {
1399 int y; 1417 int y;
1400 void (*J422ToARGBRow)(const uint8* y_buf, 1418 void (*I422ToARGBRow)(const uint8* y_buf,
1401 const uint8* u_buf, 1419 const uint8* u_buf,
1402 const uint8* v_buf, 1420 const uint8* v_buf,
1403 uint8* rgb_buf, 1421 uint8* rgb_buf,
1404 int width) = J422ToARGBRow_C; 1422 struct YuvConstants* yuvconstants,
1423 int width) = I422ToARGBRow_C;
1405 if (!src_y || !src_u || !src_v || 1424 if (!src_y || !src_u || !src_v ||
1406 !dst_argb || 1425 !dst_argb ||
1407 width <= 0 || height == 0) { 1426 width <= 0 || height == 0) {
1408 return -1; 1427 return -1;
1409 } 1428 }
1410 // Negative height means invert the image. 1429 // Negative height means invert the image.
1411 if (height < 0) { 1430 if (height < 0) {
1412 height = -height; 1431 height = -height;
1413 dst_argb = dst_argb + (height - 1) * dst_stride_argb; 1432 dst_argb = dst_argb + (height - 1) * dst_stride_argb;
1414 dst_stride_argb = -dst_stride_argb; 1433 dst_stride_argb = -dst_stride_argb;
1415 } 1434 }
1416 // Coalesce rows. 1435 // Coalesce rows.
1417 if (src_stride_y == width && 1436 if (src_stride_y == width &&
1418 src_stride_u * 2 == width && 1437 src_stride_u * 2 == width &&
1419 src_stride_v * 2 == width && 1438 src_stride_v * 2 == width &&
1420 dst_stride_argb == width * 4) { 1439 dst_stride_argb == width * 4) {
1421 width *= height; 1440 width *= height;
1422 height = 1; 1441 height = 1;
1423 src_stride_y = src_stride_u = src_stride_v = dst_stride_argb = 0; 1442 src_stride_y = src_stride_u = src_stride_v = dst_stride_argb = 0;
1424 } 1443 }
1425 #if defined(HAS_J422TOARGBROW_SSSE3) 1444 #if defined(HAS_I422TOARGBROW_SSSE3)
1426 if (TestCpuFlag(kCpuHasSSSE3)) { 1445 if (TestCpuFlag(kCpuHasSSSE3)) {
1427 J422ToARGBRow = J422ToARGBRow_Any_SSSE3; 1446 I422ToARGBRow = I422ToARGBRow_Any_SSSE3;
1428 if (IS_ALIGNED(width, 8)) { 1447 if (IS_ALIGNED(width, 8)) {
1429 J422ToARGBRow = J422ToARGBRow_SSSE3; 1448 I422ToARGBRow = I422ToARGBRow_SSSE3;
1430 } 1449 }
1431 } 1450 }
1432 #endif 1451 #endif
1433 #if defined(HAS_J422TOARGBROW_AVX2) 1452 #if defined(HAS_I422TOARGBROW_AVX2)
1434 if (TestCpuFlag(kCpuHasAVX2)) { 1453 if (TestCpuFlag(kCpuHasAVX2)) {
1435 J422ToARGBRow = J422ToARGBRow_Any_AVX2; 1454 I422ToARGBRow = I422ToARGBRow_Any_AVX2;
1436 if (IS_ALIGNED(width, 16)) { 1455 if (IS_ALIGNED(width, 16)) {
1437 J422ToARGBRow = J422ToARGBRow_AVX2; 1456 I422ToARGBRow = I422ToARGBRow_AVX2;
1438 } 1457 }
1439 } 1458 }
1440 #endif 1459 #endif
1441 #if defined(HAS_J422TOARGBROW_NEON) 1460 #if defined(HAS_I422TOARGBROW_NEON)
1442 if (TestCpuFlag(kCpuHasNEON)) { 1461 if (TestCpuFlag(kCpuHasNEON)) {
1443 J422ToARGBRow = J422ToARGBRow_Any_NEON; 1462 I422ToARGBRow = I422ToARGBRow_Any_NEON;
1444 if (IS_ALIGNED(width, 8)) { 1463 if (IS_ALIGNED(width, 8)) {
1445 J422ToARGBRow = J422ToARGBRow_NEON; 1464 I422ToARGBRow = I422ToARGBRow_NEON;
1446 } 1465 }
1447 } 1466 }
1448 #endif 1467 #endif
1449 #if defined(HAS_J422TOARGBROW_MIPS_DSPR2) 1468 #if defined(HAS_I422TOARGBROW_MIPS_DSPR2)
1450 if (TestCpuFlag(kCpuHasMIPS_DSPR2) && IS_ALIGNED(width, 4) && 1469 if (TestCpuFlag(kCpuHasMIPS_DSPR2) && IS_ALIGNED(width, 4) &&
1451 IS_ALIGNED(src_y, 4) && IS_ALIGNED(src_stride_y, 4) && 1470 IS_ALIGNED(src_y, 4) && IS_ALIGNED(src_stride_y, 4) &&
1452 IS_ALIGNED(src_u, 2) && IS_ALIGNED(src_stride_u, 2) && 1471 IS_ALIGNED(src_u, 2) && IS_ALIGNED(src_stride_u, 2) &&
1453 IS_ALIGNED(src_v, 2) && IS_ALIGNED(src_stride_v, 2) && 1472 IS_ALIGNED(src_v, 2) && IS_ALIGNED(src_stride_v, 2) &&
1454 IS_ALIGNED(dst_argb, 4) && IS_ALIGNED(dst_stride_argb, 4)) { 1473 IS_ALIGNED(dst_argb, 4) && IS_ALIGNED(dst_stride_argb, 4)) {
1455 J422ToARGBRow = J422ToARGBRow_MIPS_DSPR2; 1474 I422ToARGBRow = I422ToARGBRow_MIPS_DSPR2;
1456 } 1475 }
1457 #endif 1476 #endif
1458 1477
1459 for (y = 0; y < height; ++y) { 1478 for (y = 0; y < height; ++y) {
1460 J422ToARGBRow(src_y, src_u, src_v, dst_argb, width); 1479 I422ToARGBRow(src_y, src_u, src_v, dst_argb, &kYuvJConstants, width);
1461 dst_argb += dst_stride_argb; 1480 dst_argb += dst_stride_argb;
1462 src_y += src_stride_y; 1481 src_y += src_stride_y;
1463 src_u += src_stride_u; 1482 src_u += src_stride_u;
1464 src_v += src_stride_v; 1483 src_v += src_stride_v;
1465 } 1484 }
1466 return 0; 1485 return 0;
1467 } 1486 }
1468 1487
1469 // Convert J420 to ABGR. 1488 // Convert J420 to ABGR.
1470 LIBYUV_API 1489 LIBYUV_API
1471 int J420ToABGR(const uint8* src_y, int src_stride_y, 1490 int J420ToABGR(const uint8* src_y, int src_stride_y,
1472 const uint8* src_u, int src_stride_u, 1491 const uint8* src_u, int src_stride_u,
1473 const uint8* src_v, int src_stride_v, 1492 const uint8* src_v, int src_stride_v,
1474 uint8* dst_abgr, int dst_stride_abgr, 1493 uint8* dst_abgr, int dst_stride_abgr,
1475 int width, int height) { 1494 int width, int height) {
1476 int y; 1495 int y;
1477 void (*J422ToABGRRow)(const uint8* y_buf, 1496 void (*I422ToABGRRow)(const uint8* y_buf,
1478 const uint8* u_buf, 1497 const uint8* u_buf,
1479 const uint8* v_buf, 1498 const uint8* v_buf,
1480 uint8* rgb_buf, 1499 uint8* rgb_buf,
1481 int width) = J422ToABGRRow_C; 1500 struct YuvConstants* yuvconstants,
1501 int width) = I422ToABGRRow_C;
1482 if (!src_y || !src_u || !src_v || !dst_abgr || 1502 if (!src_y || !src_u || !src_v || !dst_abgr ||
1483 width <= 0 || height == 0) { 1503 width <= 0 || height == 0) {
1484 return -1; 1504 return -1;
1485 } 1505 }
1486 // Negative height means invert the image. 1506 // Negative height means invert the image.
1487 if (height < 0) { 1507 if (height < 0) {
1488 height = -height; 1508 height = -height;
1489 dst_abgr = dst_abgr + (height - 1) * dst_stride_abgr; 1509 dst_abgr = dst_abgr + (height - 1) * dst_stride_abgr;
1490 dst_stride_abgr = -dst_stride_abgr; 1510 dst_stride_abgr = -dst_stride_abgr;
1491 } 1511 }
1492 #if defined(HAS_J422TOABGRROW_SSSE3) 1512 #if defined(HAS_I422TOABGRROW_SSSE3)
1493 if (TestCpuFlag(kCpuHasSSSE3)) { 1513 if (TestCpuFlag(kCpuHasSSSE3)) {
1494 J422ToABGRRow = J422ToABGRRow_Any_SSSE3; 1514 I422ToABGRRow = I422ToABGRRow_Any_SSSE3;
1495 if (IS_ALIGNED(width, 8)) { 1515 if (IS_ALIGNED(width, 8)) {
1496 J422ToABGRRow = J422ToABGRRow_SSSE3; 1516 I422ToABGRRow = I422ToABGRRow_SSSE3;
1497 } 1517 }
1498 } 1518 }
1499 #endif 1519 #endif
1500 #if defined(HAS_J422TOABGRROW_AVX2) 1520 #if defined(HAS_I422TOABGRROW_AVX2)
1501 if (TestCpuFlag(kCpuHasAVX2)) { 1521 if (TestCpuFlag(kCpuHasAVX2)) {
1502 J422ToABGRRow = J422ToABGRRow_Any_AVX2; 1522 I422ToABGRRow = I422ToABGRRow_Any_AVX2;
1503 if (IS_ALIGNED(width, 16)) { 1523 if (IS_ALIGNED(width, 16)) {
1504 J422ToABGRRow = J422ToABGRRow_AVX2; 1524 I422ToABGRRow = I422ToABGRRow_AVX2;
1505 } 1525 }
1506 } 1526 }
1507 #endif 1527 #endif
1508 #if defined(HAS_J422TOABGRROW_NEON) 1528 #if defined(HAS_I422TOABGRROW_NEON)
1509 if (TestCpuFlag(kCpuHasNEON)) { 1529 if (TestCpuFlag(kCpuHasNEON)) {
1510 J422ToABGRRow = J422ToABGRRow_Any_NEON; 1530 I422ToABGRRow = I422ToABGRRow_Any_NEON;
1511 if (IS_ALIGNED(width, 8)) { 1531 if (IS_ALIGNED(width, 8)) {
1512 J422ToABGRRow = J422ToABGRRow_NEON; 1532 I422ToABGRRow = I422ToABGRRow_NEON;
1513 } 1533 }
1514 } 1534 }
1515 #endif 1535 #endif
1516 #if defined(HAS_J422TOABGRROW_MIPS_DSPR2) 1536 #if defined(HAS_I422TOABGRROW_MIPS_DSPR2)
1517 if (TestCpuFlag(kCpuHasMIPS_DSPR2) && IS_ALIGNED(width, 4) && 1537 if (TestCpuFlag(kCpuHasMIPS_DSPR2) && IS_ALIGNED(width, 4) &&
1518 IS_ALIGNED(src_y, 4) && IS_ALIGNED(src_stride_y, 4) && 1538 IS_ALIGNED(src_y, 4) && IS_ALIGNED(src_stride_y, 4) &&
1519 IS_ALIGNED(src_u, 2) && IS_ALIGNED(src_stride_u, 2) && 1539 IS_ALIGNED(src_u, 2) && IS_ALIGNED(src_stride_u, 2) &&
1520 IS_ALIGNED(src_v, 2) && IS_ALIGNED(src_stride_v, 2) && 1540 IS_ALIGNED(src_v, 2) && IS_ALIGNED(src_stride_v, 2) &&
1521 IS_ALIGNED(dst_abgr, 4) && IS_ALIGNED(dst_stride_abgr, 4)) { 1541 IS_ALIGNED(dst_abgr, 4) && IS_ALIGNED(dst_stride_abgr, 4)) {
1522 J422ToABGRRow = J422ToABGRRow_MIPS_DSPR2; 1542 I422ToABGRRow = I422ToABGRRow_MIPS_DSPR2;
1523 } 1543 }
1524 #endif 1544 #endif
1525 1545
1526 for (y = 0; y < height; ++y) { 1546 for (y = 0; y < height; ++y) {
1527 J422ToABGRRow(src_y, src_u, src_v, dst_abgr, width); 1547 I422ToABGRRow(src_y, src_u, src_v, dst_abgr, &kYuvJConstants, width);
1528 dst_abgr += dst_stride_abgr; 1548 dst_abgr += dst_stride_abgr;
1529 src_y += src_stride_y; 1549 src_y += src_stride_y;
1530 if (y & 1) { 1550 if (y & 1) {
1531 src_u += src_stride_u; 1551 src_u += src_stride_u;
1532 src_v += src_stride_v; 1552 src_v += src_stride_v;
1533 } 1553 }
1534 } 1554 }
1535 return 0; 1555 return 0;
1536 } 1556 }
1537 1557
1538 // Convert J422 to ABGR. 1558 // Convert J422 to ABGR.
1539 LIBYUV_API 1559 LIBYUV_API
1540 int J422ToABGR(const uint8* src_y, int src_stride_y, 1560 int J422ToABGR(const uint8* src_y, int src_stride_y,
1541 const uint8* src_u, int src_stride_u, 1561 const uint8* src_u, int src_stride_u,
1542 const uint8* src_v, int src_stride_v, 1562 const uint8* src_v, int src_stride_v,
1543 uint8* dst_abgr, int dst_stride_abgr, 1563 uint8* dst_abgr, int dst_stride_abgr,
1544 int width, int height) { 1564 int width, int height) {
1545 int y; 1565 int y;
1546 void (*J422ToABGRRow)(const uint8* y_buf, 1566 void (*I422ToABGRRow)(const uint8* y_buf,
1547 const uint8* u_buf, 1567 const uint8* u_buf,
1548 const uint8* v_buf, 1568 const uint8* v_buf,
1549 uint8* rgb_buf, 1569 uint8* rgb_buf,
1550 int width) = J422ToABGRRow_C; 1570 struct YuvConstants* yuvconstants,
1571 int width) = I422ToABGRRow_C;
1551 if (!src_y || !src_u || !src_v || 1572 if (!src_y || !src_u || !src_v ||
1552 !dst_abgr || 1573 !dst_abgr ||
1553 width <= 0 || height == 0) { 1574 width <= 0 || height == 0) {
1554 return -1; 1575 return -1;
1555 } 1576 }
1556 // Negative height means invert the image. 1577 // Negative height means invert the image.
1557 if (height < 0) { 1578 if (height < 0) {
1558 height = -height; 1579 height = -height;
1559 dst_abgr = dst_abgr + (height - 1) * dst_stride_abgr; 1580 dst_abgr = dst_abgr + (height - 1) * dst_stride_abgr;
1560 dst_stride_abgr = -dst_stride_abgr; 1581 dst_stride_abgr = -dst_stride_abgr;
1561 } 1582 }
1562 // Coalesce rows. 1583 // Coalesce rows.
1563 if (src_stride_y == width && 1584 if (src_stride_y == width &&
1564 src_stride_u * 2 == width && 1585 src_stride_u * 2 == width &&
1565 src_stride_v * 2 == width && 1586 src_stride_v * 2 == width &&
1566 dst_stride_abgr == width * 4) { 1587 dst_stride_abgr == width * 4) {
1567 width *= height; 1588 width *= height;
1568 height = 1; 1589 height = 1;
1569 src_stride_y = src_stride_u = src_stride_v = dst_stride_abgr = 0; 1590 src_stride_y = src_stride_u = src_stride_v = dst_stride_abgr = 0;
1570 } 1591 }
1571 #if defined(HAS_J422TOABGRROW_SSSE3) 1592 #if defined(HAS_I422TOABGRROW_SSSE3)
1572 if (TestCpuFlag(kCpuHasSSSE3)) { 1593 if (TestCpuFlag(kCpuHasSSSE3)) {
1573 J422ToABGRRow = J422ToABGRRow_Any_SSSE3; 1594 I422ToABGRRow = I422ToABGRRow_Any_SSSE3;
1574 if (IS_ALIGNED(width, 8)) { 1595 if (IS_ALIGNED(width, 8)) {
1575 J422ToABGRRow = J422ToABGRRow_SSSE3; 1596 I422ToABGRRow = I422ToABGRRow_SSSE3;
1576 } 1597 }
1577 } 1598 }
1578 #endif 1599 #endif
1579 #if defined(HAS_J422TOABGRROW_AVX2) 1600 #if defined(HAS_I422TOABGRROW_AVX2)
1580 if (TestCpuFlag(kCpuHasAVX2)) { 1601 if (TestCpuFlag(kCpuHasAVX2)) {
1581 J422ToABGRRow = J422ToABGRRow_Any_AVX2; 1602 I422ToABGRRow = I422ToABGRRow_Any_AVX2;
1582 if (IS_ALIGNED(width, 16)) { 1603 if (IS_ALIGNED(width, 16)) {
1583 J422ToABGRRow = J422ToABGRRow_AVX2; 1604 I422ToABGRRow = I422ToABGRRow_AVX2;
1584 } 1605 }
1585 } 1606 }
1586 #endif 1607 #endif
1587 #if defined(HAS_J422TOABGRROW_NEON) 1608 #if defined(HAS_I422TOABGRROW_NEON)
1588 if (TestCpuFlag(kCpuHasNEON)) { 1609 if (TestCpuFlag(kCpuHasNEON)) {
1589 J422ToABGRRow = J422ToABGRRow_Any_NEON; 1610 I422ToABGRRow = I422ToABGRRow_Any_NEON;
1590 if (IS_ALIGNED(width, 8)) { 1611 if (IS_ALIGNED(width, 8)) {
1591 J422ToABGRRow = J422ToABGRRow_NEON; 1612 I422ToABGRRow = I422ToABGRRow_NEON;
1592 } 1613 }
1593 } 1614 }
1594 #endif 1615 #endif
1595 #if defined(HAS_J422TOABGRROW_MIPS_DSPR2) 1616 #if defined(HAS_I422TOABGRROW_MIPS_DSPR2)
1596 if (TestCpuFlag(kCpuHasMIPS_DSPR2) && IS_ALIGNED(width, 4) && 1617 if (TestCpuFlag(kCpuHasMIPS_DSPR2) && IS_ALIGNED(width, 4) &&
1597 IS_ALIGNED(src_y, 4) && IS_ALIGNED(src_stride_y, 4) && 1618 IS_ALIGNED(src_y, 4) && IS_ALIGNED(src_stride_y, 4) &&
1598 IS_ALIGNED(src_u, 2) && IS_ALIGNED(src_stride_u, 2) && 1619 IS_ALIGNED(src_u, 2) && IS_ALIGNED(src_stride_u, 2) &&
1599 IS_ALIGNED(src_v, 2) && IS_ALIGNED(src_stride_v, 2) && 1620 IS_ALIGNED(src_v, 2) && IS_ALIGNED(src_stride_v, 2) &&
1600 IS_ALIGNED(dst_abgr, 4) && IS_ALIGNED(dst_stride_abgr, 4)) { 1621 IS_ALIGNED(dst_abgr, 4) && IS_ALIGNED(dst_stride_abgr, 4)) {
1601 J422ToABGRRow = J422ToABGRRow_MIPS_DSPR2; 1622 I422ToABGRRow = I422ToABGRRow_MIPS_DSPR2;
1602 } 1623 }
1603 #endif 1624 #endif
1604 1625
1605 for (y = 0; y < height; ++y) { 1626 for (y = 0; y < height; ++y) {
1606 J422ToABGRRow(src_y, src_u, src_v, dst_abgr, width); 1627 I422ToABGRRow(src_y, src_u, src_v, dst_abgr, &kYuvJConstants, width);
1607 dst_abgr += dst_stride_abgr; 1628 dst_abgr += dst_stride_abgr;
1608 src_y += src_stride_y; 1629 src_y += src_stride_y;
1609 src_u += src_stride_u; 1630 src_u += src_stride_u;
1610 src_v += src_stride_v; 1631 src_v += src_stride_v;
1611 } 1632 }
1612 return 0; 1633 return 0;
1613 } 1634 }
1614 1635
1615 // Convert H420 to ARGB. 1636 // Convert H420 to ARGB.
1616 LIBYUV_API 1637 LIBYUV_API
1617 int H420ToARGB(const uint8* src_y, int src_stride_y, 1638 int H420ToARGB(const uint8* src_y, int src_stride_y,
1618 const uint8* src_u, int src_stride_u, 1639 const uint8* src_u, int src_stride_u,
1619 const uint8* src_v, int src_stride_v, 1640 const uint8* src_v, int src_stride_v,
1620 uint8* dst_argb, int dst_stride_argb, 1641 uint8* dst_argb, int dst_stride_argb,
1621 int width, int height) { 1642 int width, int height) {
1622 int y; 1643 int y;
1623 void (*H422ToARGBRow)(const uint8* y_buf, 1644 void (*I422ToARGBRow)(const uint8* y_buf,
1624 const uint8* u_buf, 1645 const uint8* u_buf,
1625 const uint8* v_buf, 1646 const uint8* v_buf,
1626 uint8* rgb_buf, 1647 uint8* rgb_buf,
1627 int width) = H422ToARGBRow_C; 1648 struct YuvConstants* yuvconstants,
1649 int width) = I422ToARGBRow_C;
1628 if (!src_y || !src_u || !src_v || !dst_argb || 1650 if (!src_y || !src_u || !src_v || !dst_argb ||
1629 width <= 0 || height == 0) { 1651 width <= 0 || height == 0) {
1630 return -1; 1652 return -1;
1631 } 1653 }
1632 // Negative height means invert the image. 1654 // Negative height means invert the image.
1633 if (height < 0) { 1655 if (height < 0) {
1634 height = -height; 1656 height = -height;
1635 dst_argb = dst_argb + (height - 1) * dst_stride_argb; 1657 dst_argb = dst_argb + (height - 1) * dst_stride_argb;
1636 dst_stride_argb = -dst_stride_argb; 1658 dst_stride_argb = -dst_stride_argb;
1637 } 1659 }
1638 #if defined(HAS_H422TOARGBROW_SSSE3) 1660 #if defined(HAS_I422TOARGBROW_SSSE3)
1639 if (TestCpuFlag(kCpuHasSSSE3)) { 1661 if (TestCpuFlag(kCpuHasSSSE3)) {
1640 H422ToARGBRow = H422ToARGBRow_Any_SSSE3; 1662 I422ToARGBRow = I422ToARGBRow_Any_SSSE3;
1641 if (IS_ALIGNED(width, 8)) { 1663 if (IS_ALIGNED(width, 8)) {
1642 H422ToARGBRow = H422ToARGBRow_SSSE3; 1664 I422ToARGBRow = I422ToARGBRow_SSSE3;
1643 } 1665 }
1644 } 1666 }
1645 #endif 1667 #endif
1646 #if defined(HAS_H422TOARGBROW_AVX2) 1668 #if defined(HAS_I422TOARGBROW_AVX2)
1647 if (TestCpuFlag(kCpuHasAVX2)) { 1669 if (TestCpuFlag(kCpuHasAVX2)) {
1648 H422ToARGBRow = H422ToARGBRow_Any_AVX2; 1670 I422ToARGBRow = I422ToARGBRow_Any_AVX2;
1649 if (IS_ALIGNED(width, 16)) { 1671 if (IS_ALIGNED(width, 16)) {
1650 H422ToARGBRow = H422ToARGBRow_AVX2; 1672 I422ToARGBRow = I422ToARGBRow_AVX2;
1651 } 1673 }
1652 } 1674 }
1653 #endif 1675 #endif
1654 #if defined(HAS_H422TOARGBROW_NEON) 1676 #if defined(HAS_I422TOARGBROW_NEON)
1655 if (TestCpuFlag(kCpuHasNEON)) { 1677 if (TestCpuFlag(kCpuHasNEON)) {
1656 H422ToARGBRow = H422ToARGBRow_Any_NEON; 1678 I422ToARGBRow = I422ToARGBRow_Any_NEON;
1657 if (IS_ALIGNED(width, 8)) { 1679 if (IS_ALIGNED(width, 8)) {
1658 H422ToARGBRow = H422ToARGBRow_NEON; 1680 I422ToARGBRow = I422ToARGBRow_NEON;
1659 } 1681 }
1660 } 1682 }
1661 #endif 1683 #endif
1662 #if defined(HAS_H422TOARGBROW_MIPS_DSPR2) 1684 #if defined(HAS_I422TOARGBROW_MIPS_DSPR2)
1663 if (TestCpuFlag(kCpuHasMIPS_DSPR2) && IS_ALIGNED(width, 4) && 1685 if (TestCpuFlag(kCpuHasMIPS_DSPR2) && IS_ALIGNED(width, 4) &&
1664 IS_ALIGNED(src_y, 4) && IS_ALIGNED(src_stride_y, 4) && 1686 IS_ALIGNED(src_y, 4) && IS_ALIGNED(src_stride_y, 4) &&
1665 IS_ALIGNED(src_u, 2) && IS_ALIGNED(src_stride_u, 2) && 1687 IS_ALIGNED(src_u, 2) && IS_ALIGNED(src_stride_u, 2) &&
1666 IS_ALIGNED(src_v, 2) && IS_ALIGNED(src_stride_v, 2) && 1688 IS_ALIGNED(src_v, 2) && IS_ALIGNED(src_stride_v, 2) &&
1667 IS_ALIGNED(dst_argb, 4) && IS_ALIGNED(dst_stride_argb, 4)) { 1689 IS_ALIGNED(dst_argb, 4) && IS_ALIGNED(dst_stride_argb, 4)) {
1668 H422ToARGBRow = H422ToARGBRow_MIPS_DSPR2; 1690 I422ToARGBRow = I422ToARGBRow_MIPS_DSPR2;
1669 } 1691 }
1670 #endif 1692 #endif
1671 1693
1672 for (y = 0; y < height; ++y) { 1694 for (y = 0; y < height; ++y) {
1673 H422ToARGBRow(src_y, src_u, src_v, dst_argb, width); 1695 I422ToARGBRow(src_y, src_u, src_v, dst_argb, &kYuvHConstants, width);
1674 dst_argb += dst_stride_argb; 1696 dst_argb += dst_stride_argb;
1675 src_y += src_stride_y; 1697 src_y += src_stride_y;
1676 if (y & 1) { 1698 if (y & 1) {
1677 src_u += src_stride_u; 1699 src_u += src_stride_u;
1678 src_v += src_stride_v; 1700 src_v += src_stride_v;
1679 } 1701 }
1680 } 1702 }
1681 return 0; 1703 return 0;
1682 } 1704 }
1683 1705
1684 // Convert H422 to ARGB. 1706 // Convert H422 to ARGB.
1685 LIBYUV_API 1707 LIBYUV_API
1686 int H422ToARGB(const uint8* src_y, int src_stride_y, 1708 int H422ToARGB(const uint8* src_y, int src_stride_y,
1687 const uint8* src_u, int src_stride_u, 1709 const uint8* src_u, int src_stride_u,
1688 const uint8* src_v, int src_stride_v, 1710 const uint8* src_v, int src_stride_v,
1689 uint8* dst_argb, int dst_stride_argb, 1711 uint8* dst_argb, int dst_stride_argb,
1690 int width, int height) { 1712 int width, int height) {
1691 int y; 1713 int y;
1692 void (*H422ToARGBRow)(const uint8* y_buf, 1714 void (*I422ToARGBRow)(const uint8* y_buf,
1693 const uint8* u_buf, 1715 const uint8* u_buf,
1694 const uint8* v_buf, 1716 const uint8* v_buf,
1695 uint8* rgb_buf, 1717 uint8* rgb_buf,
1696 int width) = H422ToARGBRow_C; 1718 struct YuvConstants* yuvconstants,
1719 int width) = I422ToARGBRow_C;
1697 if (!src_y || !src_u || !src_v || 1720 if (!src_y || !src_u || !src_v ||
1698 !dst_argb || 1721 !dst_argb ||
1699 width <= 0 || height == 0) { 1722 width <= 0 || height == 0) {
1700 return -1; 1723 return -1;
1701 } 1724 }
1702 // Negative height means invert the image. 1725 // Negative height means invert the image.
1703 if (height < 0) { 1726 if (height < 0) {
1704 height = -height; 1727 height = -height;
1705 dst_argb = dst_argb + (height - 1) * dst_stride_argb; 1728 dst_argb = dst_argb + (height - 1) * dst_stride_argb;
1706 dst_stride_argb = -dst_stride_argb; 1729 dst_stride_argb = -dst_stride_argb;
1707 } 1730 }
1708 // Coalesce rows. 1731 // Coalesce rows.
1709 if (src_stride_y == width && 1732 if (src_stride_y == width &&
1710 src_stride_u * 2 == width && 1733 src_stride_u * 2 == width &&
1711 src_stride_v * 2 == width && 1734 src_stride_v * 2 == width &&
1712 dst_stride_argb == width * 4) { 1735 dst_stride_argb == width * 4) {
1713 width *= height; 1736 width *= height;
1714 height = 1; 1737 height = 1;
1715 src_stride_y = src_stride_u = src_stride_v = dst_stride_argb = 0; 1738 src_stride_y = src_stride_u = src_stride_v = dst_stride_argb = 0;
1716 } 1739 }
1717 #if defined(HAS_H422TOARGBROW_SSSE3) 1740 #if defined(HAS_I422TOARGBROW_SSSE3)
1718 if (TestCpuFlag(kCpuHasSSSE3)) { 1741 if (TestCpuFlag(kCpuHasSSSE3)) {
1719 H422ToARGBRow = H422ToARGBRow_Any_SSSE3; 1742 I422ToARGBRow = I422ToARGBRow_Any_SSSE3;
1720 if (IS_ALIGNED(width, 8)) { 1743 if (IS_ALIGNED(width, 8)) {
1721 H422ToARGBRow = H422ToARGBRow_SSSE3; 1744 I422ToARGBRow = I422ToARGBRow_SSSE3;
1722 } 1745 }
1723 } 1746 }
1724 #endif 1747 #endif
1725 #if defined(HAS_H422TOARGBROW_AVX2) 1748 #if defined(HAS_I422TOARGBROW_AVX2)
1726 if (TestCpuFlag(kCpuHasAVX2)) { 1749 if (TestCpuFlag(kCpuHasAVX2)) {
1727 H422ToARGBRow = H422ToARGBRow_Any_AVX2; 1750 I422ToARGBRow = I422ToARGBRow_Any_AVX2;
1728 if (IS_ALIGNED(width, 16)) { 1751 if (IS_ALIGNED(width, 16)) {
1729 H422ToARGBRow = H422ToARGBRow_AVX2; 1752 I422ToARGBRow = I422ToARGBRow_AVX2;
1730 } 1753 }
1731 } 1754 }
1732 #endif 1755 #endif
1733 #if defined(HAS_H422TOARGBROW_NEON) 1756 #if defined(HAS_I422TOARGBROW_NEON)
1734 if (TestCpuFlag(kCpuHasNEON)) { 1757 if (TestCpuFlag(kCpuHasNEON)) {
1735 H422ToARGBRow = H422ToARGBRow_Any_NEON; 1758 I422ToARGBRow = I422ToARGBRow_Any_NEON;
1736 if (IS_ALIGNED(width, 8)) { 1759 if (IS_ALIGNED(width, 8)) {
1737 H422ToARGBRow = H422ToARGBRow_NEON; 1760 I422ToARGBRow = I422ToARGBRow_NEON;
1738 } 1761 }
1739 } 1762 }
1740 #endif 1763 #endif
1741 #if defined(HAS_H422TOARGBROW_MIPS_DSPR2) 1764 #if defined(HAS_I422TOARGBROW_MIPS_DSPR2)
1742 if (TestCpuFlag(kCpuHasMIPS_DSPR2) && IS_ALIGNED(width, 4) && 1765 if (TestCpuFlag(kCpuHasMIPS_DSPR2) && IS_ALIGNED(width, 4) &&
1743 IS_ALIGNED(src_y, 4) && IS_ALIGNED(src_stride_y, 4) && 1766 IS_ALIGNED(src_y, 4) && IS_ALIGNED(src_stride_y, 4) &&
1744 IS_ALIGNED(src_u, 2) && IS_ALIGNED(src_stride_u, 2) && 1767 IS_ALIGNED(src_u, 2) && IS_ALIGNED(src_stride_u, 2) &&
1745 IS_ALIGNED(src_v, 2) && IS_ALIGNED(src_stride_v, 2) && 1768 IS_ALIGNED(src_v, 2) && IS_ALIGNED(src_stride_v, 2) &&
1746 IS_ALIGNED(dst_argb, 4) && IS_ALIGNED(dst_stride_argb, 4)) { 1769 IS_ALIGNED(dst_argb, 4) && IS_ALIGNED(dst_stride_argb, 4)) {
1747 H422ToARGBRow = H422ToARGBRow_MIPS_DSPR2; 1770 I422ToARGBRow = I422ToARGBRow_MIPS_DSPR2;
1748 } 1771 }
1749 #endif 1772 #endif
1750 1773
1751 for (y = 0; y < height; ++y) { 1774 for (y = 0; y < height; ++y) {
1752 H422ToARGBRow(src_y, src_u, src_v, dst_argb, width); 1775 I422ToARGBRow(src_y, src_u, src_v, dst_argb, &kYuvHConstants, width);
1753 dst_argb += dst_stride_argb; 1776 dst_argb += dst_stride_argb;
1754 src_y += src_stride_y; 1777 src_y += src_stride_y;
1755 src_u += src_stride_u; 1778 src_u += src_stride_u;
1756 src_v += src_stride_v; 1779 src_v += src_stride_v;
1757 } 1780 }
1758 return 0; 1781 return 0;
1759 } 1782 }
1760 1783
1761 // Convert H420 to ABGR. 1784 // Convert H420 to ABGR.
1762 LIBYUV_API 1785 LIBYUV_API
1763 int H420ToABGR(const uint8* src_y, int src_stride_y, 1786 int H420ToABGR(const uint8* src_y, int src_stride_y,
1764 const uint8* src_u, int src_stride_u, 1787 const uint8* src_u, int src_stride_u,
1765 const uint8* src_v, int src_stride_v, 1788 const uint8* src_v, int src_stride_v,
1766 uint8* dst_abgr, int dst_stride_abgr, 1789 uint8* dst_abgr, int dst_stride_abgr,
1767 int width, int height) { 1790 int width, int height) {
1768 int y; 1791 int y;
1769 void (*H422ToABGRRow)(const uint8* y_buf, 1792 void (*I422ToABGRRow)(const uint8* y_buf,
1770 const uint8* u_buf, 1793 const uint8* u_buf,
1771 const uint8* v_buf, 1794 const uint8* v_buf,
1772 uint8* rgb_buf, 1795 uint8* rgb_buf,
1773 int width) = H422ToABGRRow_C; 1796 struct YuvConstants* yuvconstants,
1797 int width) = I422ToABGRRow_C;
1774 if (!src_y || !src_u || !src_v || !dst_abgr || 1798 if (!src_y || !src_u || !src_v || !dst_abgr ||
1775 width <= 0 || height == 0) { 1799 width <= 0 || height == 0) {
1776 return -1; 1800 return -1;
1777 } 1801 }
1778 // Negative height means invert the image. 1802 // Negative height means invert the image.
1779 if (height < 0) { 1803 if (height < 0) {
1780 height = -height; 1804 height = -height;
1781 dst_abgr = dst_abgr + (height - 1) * dst_stride_abgr; 1805 dst_abgr = dst_abgr + (height - 1) * dst_stride_abgr;
1782 dst_stride_abgr = -dst_stride_abgr; 1806 dst_stride_abgr = -dst_stride_abgr;
1783 } 1807 }
1784 #if defined(HAS_H422TOABGRROW_SSSE3) 1808 #if defined(HAS_I422TOABGRROW_SSSE3)
1785 if (TestCpuFlag(kCpuHasSSSE3)) { 1809 if (TestCpuFlag(kCpuHasSSSE3)) {
1786 H422ToABGRRow = H422ToABGRRow_Any_SSSE3; 1810 I422ToABGRRow = I422ToABGRRow_Any_SSSE3;
1787 if (IS_ALIGNED(width, 8)) { 1811 if (IS_ALIGNED(width, 8)) {
1788 H422ToABGRRow = H422ToABGRRow_SSSE3; 1812 I422ToABGRRow = I422ToABGRRow_SSSE3;
1789 } 1813 }
1790 } 1814 }
1791 #endif 1815 #endif
1792 #if defined(HAS_H422TOABGRROW_AVX2) 1816 #if defined(HAS_I422TOABGRROW_AVX2)
1793 if (TestCpuFlag(kCpuHasAVX2)) { 1817 if (TestCpuFlag(kCpuHasAVX2)) {
1794 H422ToABGRRow = H422ToABGRRow_Any_AVX2; 1818 I422ToABGRRow = I422ToABGRRow_Any_AVX2;
1795 if (IS_ALIGNED(width, 16)) { 1819 if (IS_ALIGNED(width, 16)) {
1796 H422ToABGRRow = H422ToABGRRow_AVX2; 1820 I422ToABGRRow = I422ToABGRRow_AVX2;
1797 } 1821 }
1798 } 1822 }
1799 #endif 1823 #endif
1800 #if defined(HAS_H422TOABGRROW_NEON) 1824 #if defined(HAS_I422TOABGRROW_NEON)
1801 if (TestCpuFlag(kCpuHasNEON)) { 1825 if (TestCpuFlag(kCpuHasNEON)) {
1802 H422ToABGRRow = H422ToABGRRow_Any_NEON; 1826 I422ToABGRRow = I422ToABGRRow_Any_NEON;
1803 if (IS_ALIGNED(width, 8)) { 1827 if (IS_ALIGNED(width, 8)) {
1804 H422ToABGRRow = H422ToABGRRow_NEON; 1828 I422ToABGRRow = I422ToABGRRow_NEON;
1805 } 1829 }
1806 } 1830 }
1807 #endif 1831 #endif
1808 #if defined(HAS_H422TOABGRROW_MIPS_DSPR2) 1832 #if defined(HAS_I422TOABGRROW_MIPS_DSPR2)
1809 if (TestCpuFlag(kCpuHasMIPS_DSPR2) && IS_ALIGNED(width, 4) && 1833 if (TestCpuFlag(kCpuHasMIPS_DSPR2) && IS_ALIGNED(width, 4) &&
1810 IS_ALIGNED(src_y, 4) && IS_ALIGNED(src_stride_y, 4) && 1834 IS_ALIGNED(src_y, 4) && IS_ALIGNED(src_stride_y, 4) &&
1811 IS_ALIGNED(src_u, 2) && IS_ALIGNED(src_stride_u, 2) && 1835 IS_ALIGNED(src_u, 2) && IS_ALIGNED(src_stride_u, 2) &&
1812 IS_ALIGNED(src_v, 2) && IS_ALIGNED(src_stride_v, 2) && 1836 IS_ALIGNED(src_v, 2) && IS_ALIGNED(src_stride_v, 2) &&
1813 IS_ALIGNED(dst_abgr, 4) && IS_ALIGNED(dst_stride_abgr, 4)) { 1837 IS_ALIGNED(dst_abgr, 4) && IS_ALIGNED(dst_stride_abgr, 4)) {
1814 H422ToABGRRow = H422ToABGRRow_MIPS_DSPR2; 1838 I422ToABGRRow = I422ToABGRRow_MIPS_DSPR2;
1815 } 1839 }
1816 #endif 1840 #endif
1817 1841
1818 for (y = 0; y < height; ++y) { 1842 for (y = 0; y < height; ++y) {
1819 H422ToABGRRow(src_y, src_u, src_v, dst_abgr, width); 1843 I422ToABGRRow(src_y, src_u, src_v, dst_abgr, &kYuvHConstants, width);
1820 dst_abgr += dst_stride_abgr; 1844 dst_abgr += dst_stride_abgr;
1821 src_y += src_stride_y; 1845 src_y += src_stride_y;
1822 if (y & 1) { 1846 if (y & 1) {
1823 src_u += src_stride_u; 1847 src_u += src_stride_u;
1824 src_v += src_stride_v; 1848 src_v += src_stride_v;
1825 } 1849 }
1826 } 1850 }
1827 return 0; 1851 return 0;
1828 } 1852 }
1829 1853
1830 // Convert H422 to ABGR. 1854 // Convert H422 to ABGR.
1831 LIBYUV_API 1855 LIBYUV_API
1832 int H422ToABGR(const uint8* src_y, int src_stride_y, 1856 int H422ToABGR(const uint8* src_y, int src_stride_y,
1833 const uint8* src_u, int src_stride_u, 1857 const uint8* src_u, int src_stride_u,
1834 const uint8* src_v, int src_stride_v, 1858 const uint8* src_v, int src_stride_v,
1835 uint8* dst_abgr, int dst_stride_abgr, 1859 uint8* dst_abgr, int dst_stride_abgr,
1836 int width, int height) { 1860 int width, int height) {
1837 int y; 1861 int y;
1838 void (*H422ToABGRRow)(const uint8* y_buf, 1862 void (*I422ToABGRRow)(const uint8* y_buf,
1839 const uint8* u_buf, 1863 const uint8* u_buf,
1840 const uint8* v_buf, 1864 const uint8* v_buf,
1841 uint8* rgb_buf, 1865 uint8* rgb_buf,
1842 int width) = H422ToABGRRow_C; 1866 struct YuvConstants* yuvconstants,
1867 int width) = I422ToABGRRow_C;
1843 if (!src_y || !src_u || !src_v || 1868 if (!src_y || !src_u || !src_v ||
1844 !dst_abgr || 1869 !dst_abgr ||
1845 width <= 0 || height == 0) { 1870 width <= 0 || height == 0) {
1846 return -1; 1871 return -1;
1847 } 1872 }
1848 // Negative height means invert the image. 1873 // Negative height means invert the image.
1849 if (height < 0) { 1874 if (height < 0) {
1850 height = -height; 1875 height = -height;
1851 dst_abgr = dst_abgr + (height - 1) * dst_stride_abgr; 1876 dst_abgr = dst_abgr + (height - 1) * dst_stride_abgr;
1852 dst_stride_abgr = -dst_stride_abgr; 1877 dst_stride_abgr = -dst_stride_abgr;
1853 } 1878 }
1854 // Coalesce rows. 1879 // Coalesce rows.
1855 if (src_stride_y == width && 1880 if (src_stride_y == width &&
1856 src_stride_u * 2 == width && 1881 src_stride_u * 2 == width &&
1857 src_stride_v * 2 == width && 1882 src_stride_v * 2 == width &&
1858 dst_stride_abgr == width * 4) { 1883 dst_stride_abgr == width * 4) {
1859 width *= height; 1884 width *= height;
1860 height = 1; 1885 height = 1;
1861 src_stride_y = src_stride_u = src_stride_v = dst_stride_abgr = 0; 1886 src_stride_y = src_stride_u = src_stride_v = dst_stride_abgr = 0;
1862 } 1887 }
1863 #if defined(HAS_H422TOABGRROW_SSSE3) 1888 #if defined(HAS_I422TOABGRROW_SSSE3)
1864 if (TestCpuFlag(kCpuHasSSSE3)) { 1889 if (TestCpuFlag(kCpuHasSSSE3)) {
1865 H422ToABGRRow = H422ToABGRRow_Any_SSSE3; 1890 I422ToABGRRow = I422ToABGRRow_Any_SSSE3;
1866 if (IS_ALIGNED(width, 8)) { 1891 if (IS_ALIGNED(width, 8)) {
1867 H422ToABGRRow = H422ToABGRRow_SSSE3; 1892 I422ToABGRRow = I422ToABGRRow_SSSE3;
1868 } 1893 }
1869 } 1894 }
1870 #endif 1895 #endif
1871 #if defined(HAS_H422TOABGRROW_AVX2) 1896 #if defined(HAS_I422TOABGRROW_AVX2)
1872 if (TestCpuFlag(kCpuHasAVX2)) { 1897 if (TestCpuFlag(kCpuHasAVX2)) {
1873 H422ToABGRRow = H422ToABGRRow_Any_AVX2; 1898 I422ToABGRRow = I422ToABGRRow_Any_AVX2;
1874 if (IS_ALIGNED(width, 16)) { 1899 if (IS_ALIGNED(width, 16)) {
1875 H422ToABGRRow = H422ToABGRRow_AVX2; 1900 I422ToABGRRow = I422ToABGRRow_AVX2;
1876 } 1901 }
1877 } 1902 }
1878 #endif 1903 #endif
1879 #if defined(HAS_H422TOABGRROW_NEON) 1904 #if defined(HAS_I422TOABGRROW_NEON)
1880 if (TestCpuFlag(kCpuHasNEON)) { 1905 if (TestCpuFlag(kCpuHasNEON)) {
1881 H422ToABGRRow = H422ToABGRRow_Any_NEON; 1906 I422ToABGRRow = I422ToABGRRow_Any_NEON;
1882 if (IS_ALIGNED(width, 8)) { 1907 if (IS_ALIGNED(width, 8)) {
1883 H422ToABGRRow = H422ToABGRRow_NEON; 1908 I422ToABGRRow = I422ToABGRRow_NEON;
1884 } 1909 }
1885 } 1910 }
1886 #endif 1911 #endif
1887 #if defined(HAS_H422TOABGRROW_MIPS_DSPR2) 1912 #if defined(HAS_I422TOABGRROW_MIPS_DSPR2)
1888 if (TestCpuFlag(kCpuHasMIPS_DSPR2) && IS_ALIGNED(width, 4) && 1913 if (TestCpuFlag(kCpuHasMIPS_DSPR2) && IS_ALIGNED(width, 4) &&
1889 IS_ALIGNED(src_y, 4) && IS_ALIGNED(src_stride_y, 4) && 1914 IS_ALIGNED(src_y, 4) && IS_ALIGNED(src_stride_y, 4) &&
1890 IS_ALIGNED(src_u, 2) && IS_ALIGNED(src_stride_u, 2) && 1915 IS_ALIGNED(src_u, 2) && IS_ALIGNED(src_stride_u, 2) &&
1891 IS_ALIGNED(src_v, 2) && IS_ALIGNED(src_stride_v, 2) && 1916 IS_ALIGNED(src_v, 2) && IS_ALIGNED(src_stride_v, 2) &&
1892 IS_ALIGNED(dst_abgr, 4) && IS_ALIGNED(dst_stride_abgr, 4)) { 1917 IS_ALIGNED(dst_abgr, 4) && IS_ALIGNED(dst_stride_abgr, 4)) {
1893 H422ToABGRRow = H422ToABGRRow_MIPS_DSPR2; 1918 I422ToABGRRow = I422ToABGRRow_MIPS_DSPR2;
1894 } 1919 }
1895 #endif 1920 #endif
1896 1921
1897 for (y = 0; y < height; ++y) { 1922 for (y = 0; y < height; ++y) {
1898 H422ToABGRRow(src_y, src_u, src_v, dst_abgr, width); 1923 I422ToABGRRow(src_y, src_u, src_v, dst_abgr, &kYuvHConstants, width);
1899 dst_abgr += dst_stride_abgr; 1924 dst_abgr += dst_stride_abgr;
1900 src_y += src_stride_y; 1925 src_y += src_stride_y;
1901 src_u += src_stride_u; 1926 src_u += src_stride_u;
1902 src_v += src_stride_v; 1927 src_v += src_stride_v;
1903 } 1928 }
1904 return 0; 1929 return 0;
1905 } 1930 }
1906 1931
1907 #ifdef __cplusplus 1932 #ifdef __cplusplus
1908 } // extern "C" 1933 } // extern "C"
1909 } // namespace libyuv 1934 } // namespace libyuv
1910 #endif 1935 #endif
OLDNEW
« no previous file with comments | « include/libyuv/row.h ('k') | source/convert_from.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698