| OLD | NEW |
| 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 26 matching lines...) Expand all Loading... |
| 37 height = -height; | 37 height = -height; |
| 38 src_argb = src_argb + (height - 1) * src_stride_argb; | 38 src_argb = src_argb + (height - 1) * src_stride_argb; |
| 39 src_stride_argb = -src_stride_argb; | 39 src_stride_argb = -src_stride_argb; |
| 40 } | 40 } |
| 41 | 41 |
| 42 CopyPlane(src_argb, src_stride_argb, dst_argb, dst_stride_argb, | 42 CopyPlane(src_argb, src_stride_argb, dst_argb, dst_stride_argb, |
| 43 width * 4, height); | 43 width * 4, height); |
| 44 return 0; | 44 return 0; |
| 45 } | 45 } |
| 46 | 46 |
| 47 // Convert I444 to ARGB. | 47 // Convert I422 to ARGB with matrix |
| 48 static int I444ToARGBMatrix(const uint8* src_y, int src_stride_y, | 48 static int I420ToARGBMatrix(const uint8* src_y, int src_stride_y, |
| 49 const uint8* src_u, int src_stride_u, | 49 const uint8* src_u, int src_stride_u, |
| 50 const uint8* src_v, int src_stride_v, | 50 const uint8* src_v, int src_stride_v, |
| 51 uint8* dst_argb, int dst_stride_argb, | 51 uint8* dst_argb, int dst_stride_argb, |
| 52 const struct YuvConstants* yuvconstants, | 52 const struct YuvConstants* yuvconstants, |
| 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 (*I422ToARGBRow)(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 const struct YuvConstants* yuvconstants, | 59 const struct YuvConstants* yuvconstants, |
| 60 int width) = I444ToARGBRow_C; | 60 int width) = I422ToARGBRow_C; |
| 61 if (!src_y || !src_u || !src_v || | 61 if (!src_y || !src_u || !src_v || !dst_argb || |
| 62 !dst_argb || | |
| 63 width <= 0 || height == 0) { | 62 width <= 0 || height == 0) { |
| 64 return -1; | 63 return -1; |
| 65 } | 64 } |
| 66 // Negative height means invert the image. | 65 // Negative height means invert the image. |
| 67 if (height < 0) { | 66 if (height < 0) { |
| 68 height = -height; | 67 height = -height; |
| 69 dst_argb = dst_argb + (height - 1) * dst_stride_argb; | 68 dst_argb = dst_argb + (height - 1) * dst_stride_argb; |
| 70 dst_stride_argb = -dst_stride_argb; | 69 dst_stride_argb = -dst_stride_argb; |
| 71 } | 70 } |
| 72 // Coalesce rows. | 71 #if defined(HAS_I422TOARGBROW_SSSE3) |
| 73 if (src_stride_y == width && | |
| 74 src_stride_u == width && | |
| 75 src_stride_v == width && | |
| 76 dst_stride_argb == width * 4) { | |
| 77 width *= height; | |
| 78 height = 1; | |
| 79 src_stride_y = src_stride_u = src_stride_v = dst_stride_argb = 0; | |
| 80 } | |
| 81 #if defined(HAS_I444TOARGBROW_SSSE3) | |
| 82 if (TestCpuFlag(kCpuHasSSSE3)) { | 72 if (TestCpuFlag(kCpuHasSSSE3)) { |
| 83 I444ToARGBRow = I444ToARGBRow_Any_SSSE3; | 73 I422ToARGBRow = I422ToARGBRow_Any_SSSE3; |
| 84 if (IS_ALIGNED(width, 8)) { | 74 if (IS_ALIGNED(width, 8)) { |
| 85 I444ToARGBRow = I444ToARGBRow_SSSE3; | 75 I422ToARGBRow = I422ToARGBRow_SSSE3; |
| 86 } | 76 } |
| 87 } | 77 } |
| 88 #endif | 78 #endif |
| 89 #if defined(HAS_I444TOARGBROW_AVX2) | 79 #if defined(HAS_I422TOARGBROW_AVX2) |
| 90 if (TestCpuFlag(kCpuHasAVX2)) { | 80 if (TestCpuFlag(kCpuHasAVX2)) { |
| 91 I444ToARGBRow = I444ToARGBRow_Any_AVX2; | 81 I422ToARGBRow = I422ToARGBRow_Any_AVX2; |
| 92 if (IS_ALIGNED(width, 16)) { | 82 if (IS_ALIGNED(width, 16)) { |
| 93 I444ToARGBRow = I444ToARGBRow_AVX2; | 83 I422ToARGBRow = I422ToARGBRow_AVX2; |
| 94 } | 84 } |
| 95 } | 85 } |
| 96 #endif | 86 #endif |
| 97 #if defined(HAS_I444TOARGBROW_NEON) | 87 #if defined(HAS_I422TOARGBROW_NEON) |
| 98 if (TestCpuFlag(kCpuHasNEON)) { | 88 if (TestCpuFlag(kCpuHasNEON)) { |
| 99 I444ToARGBRow = I444ToARGBRow_Any_NEON; | 89 I422ToARGBRow = I422ToARGBRow_Any_NEON; |
| 100 if (IS_ALIGNED(width, 8)) { | 90 if (IS_ALIGNED(width, 8)) { |
| 101 I444ToARGBRow = I444ToARGBRow_NEON; | 91 I422ToARGBRow = I422ToARGBRow_NEON; |
| 102 } | 92 } |
| 103 } | 93 } |
| 104 #endif | 94 #endif |
| 95 #if defined(HAS_I422TOARGBROW_MIPS_DSPR2) |
| 96 if (TestCpuFlag(kCpuHasMIPS_DSPR2) && IS_ALIGNED(width, 4) && |
| 97 IS_ALIGNED(src_y, 4) && IS_ALIGNED(src_stride_y, 4) && |
| 98 IS_ALIGNED(src_u, 2) && IS_ALIGNED(src_stride_u, 2) && |
| 99 IS_ALIGNED(src_v, 2) && IS_ALIGNED(src_stride_v, 2) && |
| 100 IS_ALIGNED(dst_argb, 4) && IS_ALIGNED(dst_stride_argb, 4)) { |
| 101 I422ToARGBRow = I422ToARGBRow_MIPS_DSPR2; |
| 102 } |
| 103 #endif |
| 105 | 104 |
| 106 for (y = 0; y < height; ++y) { | 105 for (y = 0; y < height; ++y) { |
| 107 I444ToARGBRow(src_y, src_u, src_v, dst_argb, yuvconstants, width); | 106 I422ToARGBRow(src_y, src_u, src_v, dst_argb, yuvconstants, width); |
| 108 dst_argb += dst_stride_argb; | 107 dst_argb += dst_stride_argb; |
| 109 src_y += src_stride_y; | 108 src_y += src_stride_y; |
| 110 src_u += src_stride_u; | 109 if (y & 1) { |
| 111 src_v += src_stride_v; | 110 src_u += src_stride_u; |
| 111 src_v += src_stride_v; |
| 112 } |
| 112 } | 113 } |
| 113 return 0; | 114 return 0; |
| 114 } | 115 } |
| 115 | 116 |
| 116 // Convert I444 to ARGB. | 117 // Convert I420 to ARGB. |
| 117 LIBYUV_API | 118 LIBYUV_API |
| 118 int I444ToARGB(const uint8* src_y, int src_stride_y, | 119 int I420ToARGB(const uint8* src_y, int src_stride_y, |
| 119 const uint8* src_u, int src_stride_u, | 120 const uint8* src_u, int src_stride_u, |
| 120 const uint8* src_v, int src_stride_v, | 121 const uint8* src_v, int src_stride_v, |
| 121 uint8* dst_argb, int dst_stride_argb, | 122 uint8* dst_argb, int dst_stride_argb, |
| 122 int width, int height) { | 123 int width, int height) { |
| 123 return I444ToARGBMatrix(src_y, src_stride_y, | 124 return I420ToARGBMatrix(src_y, src_stride_y, |
| 124 src_u, src_stride_u, | 125 src_u, src_stride_u, |
| 125 src_v, src_stride_v, | 126 src_v, src_stride_v, |
| 126 dst_argb, dst_stride_argb, | 127 dst_argb, dst_stride_argb, |
| 127 &kYuvIConstants, | 128 &kYuvIConstants, |
| 128 width, height); | 129 width, height); |
| 129 } | 130 } |
| 130 | 131 |
| 131 // Convert I444 to ABGR. | 132 // Convert I420 to ABGR. |
| 132 LIBYUV_API | 133 LIBYUV_API |
| 133 int I444ToABGR(const uint8* src_y, int src_stride_y, | 134 int I420ToABGR(const uint8* src_y, int src_stride_y, |
| 134 const uint8* src_u, int src_stride_u, | 135 const uint8* src_u, int src_stride_u, |
| 135 const uint8* src_v, int src_stride_v, | 136 const uint8* src_v, int src_stride_v, |
| 136 uint8* dst_abgr, int dst_stride_abgr, | 137 uint8* dst_abgr, int dst_stride_abgr, |
| 137 int width, int height) { | 138 int width, int height) { |
| 138 return I444ToARGBMatrix(src_y, src_stride_y, | 139 return I420ToARGBMatrix(src_y, src_stride_y, |
| 139 src_v, src_stride_v, // Swap U and V | 140 src_v, src_stride_v, // Swap U and V |
| 140 src_u, src_stride_u, | 141 src_u, src_stride_u, |
| 141 dst_abgr, dst_stride_abgr, | 142 dst_abgr, dst_stride_abgr, |
| 142 &kYvuIConstants, // Use Yvu matrix | 143 &kYvuIConstants, // Use Yvu matrix |
| 143 width, height); | 144 width, height); |
| 144 } | 145 } |
| 145 | 146 |
| 146 // Convert J444 to ARGB. | 147 // Convert J420 to ARGB. |
| 147 LIBYUV_API | 148 LIBYUV_API |
| 148 int J444ToARGB(const uint8* src_y, int src_stride_y, | 149 int J420ToARGB(const uint8* src_y, int src_stride_y, |
| 149 const uint8* src_u, int src_stride_u, | 150 const uint8* src_u, int src_stride_u, |
| 150 const uint8* src_v, int src_stride_v, | 151 const uint8* src_v, int src_stride_v, |
| 151 uint8* dst_argb, int dst_stride_argb, | 152 uint8* dst_argb, int dst_stride_argb, |
| 152 int width, int height) { | 153 int width, int height) { |
| 153 return I444ToARGBMatrix(src_y, src_stride_y, | 154 return I420ToARGBMatrix(src_y, src_stride_y, |
| 154 src_u, src_stride_u, | 155 src_u, src_stride_u, |
| 155 src_v, src_stride_v, | 156 src_v, src_stride_v, |
| 156 dst_argb, dst_stride_argb, | 157 dst_argb, dst_stride_argb, |
| 157 &kYuvJConstants, | 158 &kYuvJConstants, |
| 158 width, height); | 159 width, height); |
| 159 } | 160 } |
| 160 | 161 |
| 161 // Convert I422 to ARGB. | 162 // Convert J420 to ABGR. |
| 162 LIBYUV_API | 163 LIBYUV_API |
| 163 int I422ToARGB(const uint8* src_y, int src_stride_y, | 164 int J420ToABGR(const uint8* src_y, int src_stride_y, |
| 165 const uint8* src_u, int src_stride_u, |
| 166 const uint8* src_v, int src_stride_v, |
| 167 uint8* dst_abgr, int dst_stride_abgr, |
| 168 int width, int height) { |
| 169 return I420ToARGBMatrix(src_y, src_stride_y, |
| 170 src_v, src_stride_v, // Swap U and V |
| 171 src_u, src_stride_u, |
| 172 dst_abgr, dst_stride_abgr, |
| 173 &kYvuJConstants, // Use Yvu matrix |
| 174 width, height); |
| 175 } |
| 176 |
| 177 // Convert H420 to ARGB. |
| 178 LIBYUV_API |
| 179 int H420ToARGB(const uint8* src_y, int src_stride_y, |
| 164 const uint8* src_u, int src_stride_u, | 180 const uint8* src_u, int src_stride_u, |
| 165 const uint8* src_v, int src_stride_v, | 181 const uint8* src_v, int src_stride_v, |
| 166 uint8* dst_argb, int dst_stride_argb, | 182 uint8* dst_argb, int dst_stride_argb, |
| 167 int width, int height) { | 183 int width, int height) { |
| 184 return I420ToARGBMatrix(src_y, src_stride_y, |
| 185 src_u, src_stride_u, |
| 186 src_v, src_stride_v, |
| 187 dst_argb, dst_stride_argb, |
| 188 &kYuvHConstants, |
| 189 width, height); |
| 190 } |
| 191 |
| 192 // Convert H420 to ABGR. |
| 193 LIBYUV_API |
| 194 int H420ToABGR(const uint8* src_y, int src_stride_y, |
| 195 const uint8* src_u, int src_stride_u, |
| 196 const uint8* src_v, int src_stride_v, |
| 197 uint8* dst_abgr, int dst_stride_abgr, |
| 198 int width, int height) { |
| 199 return I420ToARGBMatrix(src_y, src_stride_y, |
| 200 src_v, src_stride_v, // Swap U and V |
| 201 src_u, src_stride_u, |
| 202 dst_abgr, dst_stride_abgr, |
| 203 &kYvuHConstants, // Use Yvu matrix |
| 204 width, height); |
| 205 } |
| 206 |
| 207 // Convert I422 to ARGB with matrix |
| 208 static int I422ToARGBMatrix(const uint8* src_y, int src_stride_y, |
| 209 const uint8* src_u, int src_stride_u, |
| 210 const uint8* src_v, int src_stride_v, |
| 211 uint8* dst_argb, int dst_stride_argb, |
| 212 const struct YuvConstants* yuvconstants, |
| 213 int width, int height) { |
| 168 int y; | 214 int y; |
| 169 void (*I422ToARGBRow)(const uint8* y_buf, | 215 void (*I422ToARGBRow)(const uint8* y_buf, |
| 170 const uint8* u_buf, | 216 const uint8* u_buf, |
| 171 const uint8* v_buf, | 217 const uint8* v_buf, |
| 172 uint8* rgb_buf, | 218 uint8* rgb_buf, |
| 173 const struct YuvConstants* yuvconstants, | 219 const struct YuvConstants* yuvconstants, |
| 174 int width) = I422ToARGBRow_C; | 220 int width) = I422ToARGBRow_C; |
| 175 if (!src_y || !src_u || !src_v || | 221 if (!src_y || !src_u || !src_v || |
| 176 !dst_argb || | 222 !dst_argb || |
| 177 width <= 0 || height == 0) { | 223 width <= 0 || height == 0) { |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 220 if (TestCpuFlag(kCpuHasMIPS_DSPR2) && IS_ALIGNED(width, 4) && | 266 if (TestCpuFlag(kCpuHasMIPS_DSPR2) && IS_ALIGNED(width, 4) && |
| 221 IS_ALIGNED(src_y, 4) && IS_ALIGNED(src_stride_y, 4) && | 267 IS_ALIGNED(src_y, 4) && IS_ALIGNED(src_stride_y, 4) && |
| 222 IS_ALIGNED(src_u, 2) && IS_ALIGNED(src_stride_u, 2) && | 268 IS_ALIGNED(src_u, 2) && IS_ALIGNED(src_stride_u, 2) && |
| 223 IS_ALIGNED(src_v, 2) && IS_ALIGNED(src_stride_v, 2) && | 269 IS_ALIGNED(src_v, 2) && IS_ALIGNED(src_stride_v, 2) && |
| 224 IS_ALIGNED(dst_argb, 4) && IS_ALIGNED(dst_stride_argb, 4)) { | 270 IS_ALIGNED(dst_argb, 4) && IS_ALIGNED(dst_stride_argb, 4)) { |
| 225 I422ToARGBRow = I422ToARGBRow_MIPS_DSPR2; | 271 I422ToARGBRow = I422ToARGBRow_MIPS_DSPR2; |
| 226 } | 272 } |
| 227 #endif | 273 #endif |
| 228 | 274 |
| 229 for (y = 0; y < height; ++y) { | 275 for (y = 0; y < height; ++y) { |
| 230 I422ToARGBRow(src_y, src_u, src_v, dst_argb, &kYuvIConstants, width); | 276 I422ToARGBRow(src_y, src_u, src_v, dst_argb, yuvconstants, width); |
| 231 dst_argb += dst_stride_argb; | 277 dst_argb += dst_stride_argb; |
| 232 src_y += src_stride_y; | 278 src_y += src_stride_y; |
| 233 src_u += src_stride_u; | 279 src_u += src_stride_u; |
| 234 src_v += src_stride_v; | 280 src_v += src_stride_v; |
| 235 } | 281 } |
| 236 return 0; | 282 return 0; |
| 237 } | 283 } |
| 238 | 284 |
| 239 // Convert I411 to ARGB. | 285 // Convert I422 to ARGB. |
| 240 LIBYUV_API | 286 LIBYUV_API |
| 241 int I411ToARGB(const uint8* src_y, int src_stride_y, | 287 int I422ToARGB(const uint8* src_y, int src_stride_y, |
| 242 const uint8* src_u, int src_stride_u, | 288 const uint8* src_u, int src_stride_u, |
| 243 const uint8* src_v, int src_stride_v, | 289 const uint8* src_v, int src_stride_v, |
| 244 uint8* dst_argb, int dst_stride_argb, | 290 uint8* dst_argb, int dst_stride_argb, |
| 245 int width, int height) { | 291 int width, int height) { |
| 292 return I422ToARGBMatrix(src_y, src_stride_y, |
| 293 src_u, src_stride_u, |
| 294 src_v, src_stride_v, |
| 295 dst_argb, dst_stride_argb, |
| 296 &kYuvIConstants, |
| 297 width, height); |
| 298 } |
| 299 |
| 300 // Convert I422 to ABGR. |
| 301 LIBYUV_API |
| 302 int I422ToABGR(const uint8* src_y, int src_stride_y, |
| 303 const uint8* src_u, int src_stride_u, |
| 304 const uint8* src_v, int src_stride_v, |
| 305 uint8* dst_abgr, int dst_stride_abgr, |
| 306 int width, int height) { |
| 307 return I422ToARGBMatrix(src_y, src_stride_y, |
| 308 src_v, src_stride_v, // Swap U and V |
| 309 src_u, src_stride_u, |
| 310 dst_abgr, dst_stride_abgr, |
| 311 &kYvuIConstants, // Use Yvu matrix |
| 312 width, height); |
| 313 } |
| 314 |
| 315 // Convert J422 to ARGB. |
| 316 LIBYUV_API |
| 317 int J422ToARGB(const uint8* src_y, int src_stride_y, |
| 318 const uint8* src_u, int src_stride_u, |
| 319 const uint8* src_v, int src_stride_v, |
| 320 uint8* dst_argb, int dst_stride_argb, |
| 321 int width, int height) { |
| 322 return I422ToARGBMatrix(src_y, src_stride_y, |
| 323 src_u, src_stride_u, |
| 324 src_v, src_stride_v, |
| 325 dst_argb, dst_stride_argb, |
| 326 &kYuvJConstants, |
| 327 width, height); |
| 328 } |
| 329 |
| 330 // Convert J422 to ABGR. |
| 331 LIBYUV_API |
| 332 int J422ToABGR(const uint8* src_y, int src_stride_y, |
| 333 const uint8* src_u, int src_stride_u, |
| 334 const uint8* src_v, int src_stride_v, |
| 335 uint8* dst_abgr, int dst_stride_abgr, |
| 336 int width, int height) { |
| 337 return I422ToARGBMatrix(src_y, src_stride_y, |
| 338 src_v, src_stride_v, // Swap U and V |
| 339 src_u, src_stride_u, |
| 340 dst_abgr, dst_stride_abgr, |
| 341 &kYvuJConstants, // Use Yvu matrix |
| 342 width, height); |
| 343 } |
| 344 |
| 345 // Convert H422 to ARGB. |
| 346 LIBYUV_API |
| 347 int H422ToARGB(const uint8* src_y, int src_stride_y, |
| 348 const uint8* src_u, int src_stride_u, |
| 349 const uint8* src_v, int src_stride_v, |
| 350 uint8* dst_argb, int dst_stride_argb, |
| 351 int width, int height) { |
| 352 return I422ToARGBMatrix(src_y, src_stride_y, |
| 353 src_u, src_stride_u, |
| 354 src_v, src_stride_v, |
| 355 dst_argb, dst_stride_argb, |
| 356 &kYuvHConstants, |
| 357 width, height); |
| 358 } |
| 359 |
| 360 // Convert H422 to ABGR. |
| 361 LIBYUV_API |
| 362 int H422ToABGR(const uint8* src_y, int src_stride_y, |
| 363 const uint8* src_u, int src_stride_u, |
| 364 const uint8* src_v, int src_stride_v, |
| 365 uint8* dst_abgr, int dst_stride_abgr, |
| 366 int width, int height) { |
| 367 return I422ToARGBMatrix(src_y, src_stride_y, |
| 368 src_v, src_stride_v, // Swap U and V |
| 369 src_u, src_stride_u, |
| 370 dst_abgr, dst_stride_abgr, |
| 371 &kYvuHConstants, // Use Yvu matrix |
| 372 width, height); |
| 373 } |
| 374 |
| 375 // Convert I444 to ARGB with matrix |
| 376 static int I444ToARGBMatrix(const uint8* src_y, int src_stride_y, |
| 377 const uint8* src_u, int src_stride_u, |
| 378 const uint8* src_v, int src_stride_v, |
| 379 uint8* dst_argb, int dst_stride_argb, |
| 380 const struct YuvConstants* yuvconstants, |
| 381 int width, int height) { |
| 246 int y; | 382 int y; |
| 247 void (*I411ToARGBRow)(const uint8* y_buf, | 383 void (*I444ToARGBRow)(const uint8* y_buf, |
| 248 const uint8* u_buf, | 384 const uint8* u_buf, |
| 249 const uint8* v_buf, | 385 const uint8* v_buf, |
| 250 uint8* rgb_buf, | 386 uint8* rgb_buf, |
| 251 const struct YuvConstants* yuvconstants, | 387 const struct YuvConstants* yuvconstants, |
| 252 int width) = I411ToARGBRow_C; | 388 int width) = I444ToARGBRow_C; |
| 253 if (!src_y || !src_u || !src_v || | 389 if (!src_y || !src_u || !src_v || |
| 254 !dst_argb || | 390 !dst_argb || |
| 255 width <= 0 || height == 0) { | 391 width <= 0 || height == 0) { |
| 256 return -1; | 392 return -1; |
| 257 } | 393 } |
| 258 // Negative height means invert the image. | 394 // Negative height means invert the image. |
| 259 if (height < 0) { | 395 if (height < 0) { |
| 260 height = -height; | 396 height = -height; |
| 261 dst_argb = dst_argb + (height - 1) * dst_stride_argb; | 397 dst_argb = dst_argb + (height - 1) * dst_stride_argb; |
| 262 dst_stride_argb = -dst_stride_argb; | 398 dst_stride_argb = -dst_stride_argb; |
| 263 } | 399 } |
| 264 // Coalesce rows. | 400 // Coalesce rows. |
| 265 if (src_stride_y == width && | 401 if (src_stride_y == width && |
| 266 src_stride_u * 4 == width && | 402 src_stride_u == width && |
| 267 src_stride_v * 4 == width && | 403 src_stride_v == width && |
| 268 dst_stride_argb == width * 4) { | 404 dst_stride_argb == width * 4) { |
| 269 width *= height; | 405 width *= height; |
| 270 height = 1; | 406 height = 1; |
| 271 src_stride_y = src_stride_u = src_stride_v = dst_stride_argb = 0; | 407 src_stride_y = src_stride_u = src_stride_v = dst_stride_argb = 0; |
| 272 } | 408 } |
| 273 #if defined(HAS_I411TOARGBROW_SSSE3) | 409 #if defined(HAS_I444TOARGBROW_SSSE3) |
| 274 if (TestCpuFlag(kCpuHasSSSE3)) { | 410 if (TestCpuFlag(kCpuHasSSSE3)) { |
| 275 I411ToARGBRow = I411ToARGBRow_Any_SSSE3; | 411 I444ToARGBRow = I444ToARGBRow_Any_SSSE3; |
| 276 if (IS_ALIGNED(width, 8)) { | 412 if (IS_ALIGNED(width, 8)) { |
| 277 I411ToARGBRow = I411ToARGBRow_SSSE3; | 413 I444ToARGBRow = I444ToARGBRow_SSSE3; |
| 278 } | 414 } |
| 279 } | 415 } |
| 280 #endif | 416 #endif |
| 281 #if defined(HAS_I411TOARGBROW_AVX2) | 417 #if defined(HAS_I444TOARGBROW_AVX2) |
| 282 if (TestCpuFlag(kCpuHasAVX2)) { | 418 if (TestCpuFlag(kCpuHasAVX2)) { |
| 283 I411ToARGBRow = I411ToARGBRow_Any_AVX2; | 419 I444ToARGBRow = I444ToARGBRow_Any_AVX2; |
| 284 if (IS_ALIGNED(width, 16)) { | 420 if (IS_ALIGNED(width, 16)) { |
| 285 I411ToARGBRow = I411ToARGBRow_AVX2; | 421 I444ToARGBRow = I444ToARGBRow_AVX2; |
| 286 } | 422 } |
| 287 } | 423 } |
| 288 #endif | 424 #endif |
| 289 #if defined(HAS_I411TOARGBROW_NEON) | 425 #if defined(HAS_I444TOARGBROW_NEON) |
| 290 if (TestCpuFlag(kCpuHasNEON)) { | 426 if (TestCpuFlag(kCpuHasNEON)) { |
| 291 I411ToARGBRow = I411ToARGBRow_Any_NEON; | 427 I444ToARGBRow = I444ToARGBRow_Any_NEON; |
| 292 if (IS_ALIGNED(width, 8)) { | 428 if (IS_ALIGNED(width, 8)) { |
| 293 I411ToARGBRow = I411ToARGBRow_NEON; | 429 I444ToARGBRow = I444ToARGBRow_NEON; |
| 294 } | 430 } |
| 295 } | 431 } |
| 296 #endif | 432 #endif |
| 297 | 433 |
| 298 for (y = 0; y < height; ++y) { | 434 for (y = 0; y < height; ++y) { |
| 299 I411ToARGBRow(src_y, src_u, src_v, dst_argb, &kYuvIConstants, width); | 435 I444ToARGBRow(src_y, src_u, src_v, dst_argb, yuvconstants, width); |
| 300 dst_argb += dst_stride_argb; | 436 dst_argb += dst_stride_argb; |
| 301 src_y += src_stride_y; | 437 src_y += src_stride_y; |
| 302 src_u += src_stride_u; | 438 src_u += src_stride_u; |
| 303 src_v += src_stride_v; | 439 src_v += src_stride_v; |
| 304 } | 440 } |
| 305 return 0; | 441 return 0; |
| 306 } | 442 } |
| 307 | 443 |
| 444 // Convert I444 to ARGB. |
| 445 LIBYUV_API |
| 446 int I444ToARGB(const uint8* src_y, int src_stride_y, |
| 447 const uint8* src_u, int src_stride_u, |
| 448 const uint8* src_v, int src_stride_v, |
| 449 uint8* dst_argb, int dst_stride_argb, |
| 450 int width, int height) { |
| 451 return I444ToARGBMatrix(src_y, src_stride_y, |
| 452 src_u, src_stride_u, |
| 453 src_v, src_stride_v, |
| 454 dst_argb, dst_stride_argb, |
| 455 &kYuvIConstants, |
| 456 width, height); |
| 457 } |
| 458 |
| 459 // Convert I444 to ABGR. |
| 460 LIBYUV_API |
| 461 int I444ToABGR(const uint8* src_y, int src_stride_y, |
| 462 const uint8* src_u, int src_stride_u, |
| 463 const uint8* src_v, int src_stride_v, |
| 464 uint8* dst_abgr, int dst_stride_abgr, |
| 465 int width, int height) { |
| 466 return I444ToARGBMatrix(src_y, src_stride_y, |
| 467 src_v, src_stride_v, // Swap U and V |
| 468 src_u, src_stride_u, |
| 469 dst_abgr, dst_stride_abgr, |
| 470 &kYvuIConstants, // Use Yvu matrix |
| 471 width, height); |
| 472 } |
| 473 |
| 474 // Convert J444 to ARGB. |
| 475 LIBYUV_API |
| 476 int J444ToARGB(const uint8* src_y, int src_stride_y, |
| 477 const uint8* src_u, int src_stride_u, |
| 478 const uint8* src_v, int src_stride_v, |
| 479 uint8* dst_argb, int dst_stride_argb, |
| 480 int width, int height) { |
| 481 return I444ToARGBMatrix(src_y, src_stride_y, |
| 482 src_u, src_stride_u, |
| 483 src_v, src_stride_v, |
| 484 dst_argb, dst_stride_argb, |
| 485 &kYuvJConstants, |
| 486 width, height); |
| 487 } |
| 488 |
| 489 // Convert I411 to ARGB. |
| 490 LIBYUV_API |
| 491 int I411ToARGB(const uint8* src_y, int src_stride_y, |
| 492 const uint8* src_u, int src_stride_u, |
| 493 const uint8* src_v, int src_stride_v, |
| 494 uint8* dst_argb, int dst_stride_argb, |
| 495 int width, int height) { |
| 496 int y; |
| 497 void (*I411ToARGBRow)(const uint8* y_buf, |
| 498 const uint8* u_buf, |
| 499 const uint8* v_buf, |
| 500 uint8* rgb_buf, |
| 501 const struct YuvConstants* yuvconstants, |
| 502 int width) = I411ToARGBRow_C; |
| 503 if (!src_y || !src_u || !src_v || |
| 504 !dst_argb || |
| 505 width <= 0 || height == 0) { |
| 506 return -1; |
| 507 } |
| 508 // Negative height means invert the image. |
| 509 if (height < 0) { |
| 510 height = -height; |
| 511 dst_argb = dst_argb + (height - 1) * dst_stride_argb; |
| 512 dst_stride_argb = -dst_stride_argb; |
| 513 } |
| 514 // Coalesce rows. |
| 515 if (src_stride_y == width && |
| 516 src_stride_u * 4 == width && |
| 517 src_stride_v * 4 == width && |
| 518 dst_stride_argb == width * 4) { |
| 519 width *= height; |
| 520 height = 1; |
| 521 src_stride_y = src_stride_u = src_stride_v = dst_stride_argb = 0; |
| 522 } |
| 523 #if defined(HAS_I411TOARGBROW_SSSE3) |
| 524 if (TestCpuFlag(kCpuHasSSSE3)) { |
| 525 I411ToARGBRow = I411ToARGBRow_Any_SSSE3; |
| 526 if (IS_ALIGNED(width, 8)) { |
| 527 I411ToARGBRow = I411ToARGBRow_SSSE3; |
| 528 } |
| 529 } |
| 530 #endif |
| 531 #if defined(HAS_I411TOARGBROW_AVX2) |
| 532 if (TestCpuFlag(kCpuHasAVX2)) { |
| 533 I411ToARGBRow = I411ToARGBRow_Any_AVX2; |
| 534 if (IS_ALIGNED(width, 16)) { |
| 535 I411ToARGBRow = I411ToARGBRow_AVX2; |
| 536 } |
| 537 } |
| 538 #endif |
| 539 #if defined(HAS_I411TOARGBROW_NEON) |
| 540 if (TestCpuFlag(kCpuHasNEON)) { |
| 541 I411ToARGBRow = I411ToARGBRow_Any_NEON; |
| 542 if (IS_ALIGNED(width, 8)) { |
| 543 I411ToARGBRow = I411ToARGBRow_NEON; |
| 544 } |
| 545 } |
| 546 #endif |
| 547 |
| 548 for (y = 0; y < height; ++y) { |
| 549 I411ToARGBRow(src_y, src_u, src_v, dst_argb, &kYuvIConstants, width); |
| 550 dst_argb += dst_stride_argb; |
| 551 src_y += src_stride_y; |
| 552 src_u += src_stride_u; |
| 553 src_v += src_stride_v; |
| 554 } |
| 555 return 0; |
| 556 } |
| 557 |
| 308 // Convert I420 with Alpha to preattenuated ARGB. | 558 // Convert I420 with Alpha to preattenuated ARGB. |
| 309 static int I420AlphaToARGBMatrix(const uint8* src_y, int src_stride_y, | 559 static int I420AlphaToARGBMatrix(const uint8* src_y, int src_stride_y, |
| 310 const uint8* src_u, int src_stride_u, | 560 const uint8* src_u, int src_stride_u, |
| 311 const uint8* src_v, int src_stride_v, | 561 const uint8* src_v, int src_stride_v, |
| 312 const uint8* src_a, int src_stride_a, | 562 const uint8* src_a, int src_stride_a, |
| 313 uint8* dst_argb, int dst_stride_argb, | 563 uint8* dst_argb, int dst_stride_argb, |
| 314 const struct YuvConstants* yuvconstants, | 564 const struct YuvConstants* yuvconstants, |
| 315 int width, int height, int attenuate) { | 565 int width, int height, int attenuate) { |
| 316 int y; | 566 int y; |
| 317 void (*I422AlphaToARGBRow)(const uint8* y_buf, | 567 void (*I422AlphaToARGBRow)(const uint8* y_buf, |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 401 src_a += src_stride_a; | 651 src_a += src_stride_a; |
| 402 src_y += src_stride_y; | 652 src_y += src_stride_y; |
| 403 if (y & 1) { | 653 if (y & 1) { |
| 404 src_u += src_stride_u; | 654 src_u += src_stride_u; |
| 405 src_v += src_stride_v; | 655 src_v += src_stride_v; |
| 406 } | 656 } |
| 407 } | 657 } |
| 408 return 0; | 658 return 0; |
| 409 } | 659 } |
| 410 | 660 |
| 411 // Convert I420 with Alpha to preattenuated ARGB. | 661 // Convert I420 with Alpha to ARGB. |
| 412 LIBYUV_API | 662 LIBYUV_API |
| 413 int I420AlphaToARGB(const uint8* src_y, int src_stride_y, | 663 int I420AlphaToARGB(const uint8* src_y, int src_stride_y, |
| 414 const uint8* src_u, int src_stride_u, | 664 const uint8* src_u, int src_stride_u, |
| 415 const uint8* src_v, int src_stride_v, | 665 const uint8* src_v, int src_stride_v, |
| 416 const uint8* src_a, int src_stride_a, | 666 const uint8* src_a, int src_stride_a, |
| 417 uint8* dst_argb, int dst_stride_argb, | 667 uint8* dst_argb, int dst_stride_argb, |
| 418 int width, int height, int attenuate) { | 668 int width, int height, int attenuate) { |
| 419 return I420AlphaToARGBMatrix(src_y, src_stride_y, | 669 return I420AlphaToARGBMatrix(src_y, src_stride_y, |
| 420 src_u, src_stride_u, | 670 src_u, src_stride_u, |
| 421 src_v, src_stride_v, | 671 src_v, src_stride_v, |
| 422 src_a, src_stride_a, | 672 src_a, src_stride_a, |
| 423 dst_argb, dst_stride_argb, | 673 dst_argb, dst_stride_argb, |
| 424 &kYuvIConstants, | 674 &kYuvIConstants, |
| 425 width, height, attenuate); | 675 width, height, attenuate); |
| 426 } | 676 } |
| 427 | 677 |
| 428 // Convert I420 with Alpha to preattenuated ARGB. | 678 // Convert I420 with Alpha to ABGR. |
| 429 LIBYUV_API | 679 LIBYUV_API |
| 430 int I420AlphaToABGR(const uint8* src_y, int src_stride_y, | 680 int I420AlphaToABGR(const uint8* src_y, int src_stride_y, |
| 431 const uint8* src_u, int src_stride_u, | 681 const uint8* src_u, int src_stride_u, |
| 432 const uint8* src_v, int src_stride_v, | 682 const uint8* src_v, int src_stride_v, |
| 433 const uint8* src_a, int src_stride_a, | 683 const uint8* src_a, int src_stride_a, |
| 434 uint8* dst_abgr, int dst_stride_abgr, | 684 uint8* dst_abgr, int dst_stride_abgr, |
| 435 int width, int height, int attenuate) { | 685 int width, int height, int attenuate) { |
| 436 return I420AlphaToARGBMatrix(src_y, src_stride_y, | 686 return I420AlphaToARGBMatrix(src_y, src_stride_y, |
| 437 src_v, src_stride_v, // Swap U and V | 687 src_v, src_stride_v, // Swap U and V |
| 438 src_u, src_stride_u, | 688 src_u, src_stride_u, |
| (...skipping 753 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1192 } | 1442 } |
| 1193 #endif | 1443 #endif |
| 1194 for (y = 0; y < height; ++y) { | 1444 for (y = 0; y < height; ++y) { |
| 1195 UYVYToARGBRow(src_uyvy, dst_argb, &kYuvIConstants, width); | 1445 UYVYToARGBRow(src_uyvy, dst_argb, &kYuvIConstants, width); |
| 1196 src_uyvy += src_stride_uyvy; | 1446 src_uyvy += src_stride_uyvy; |
| 1197 dst_argb += dst_stride_argb; | 1447 dst_argb += dst_stride_argb; |
| 1198 } | 1448 } |
| 1199 return 0; | 1449 return 0; |
| 1200 } | 1450 } |
| 1201 | 1451 |
| 1202 // Convert J420 to ARGB. | |
| 1203 LIBYUV_API | |
| 1204 int J420ToARGB(const uint8* src_y, int src_stride_y, | |
| 1205 const uint8* src_u, int src_stride_u, | |
| 1206 const uint8* src_v, int src_stride_v, | |
| 1207 uint8* dst_argb, int dst_stride_argb, | |
| 1208 int width, int height) { | |
| 1209 int y; | |
| 1210 void (*I422ToARGBRow)(const uint8* y_buf, | |
| 1211 const uint8* u_buf, | |
| 1212 const uint8* v_buf, | |
| 1213 uint8* rgb_buf, | |
| 1214 const struct YuvConstants* yuvconstants, | |
| 1215 int width) = I422ToARGBRow_C; | |
| 1216 if (!src_y || !src_u || !src_v || !dst_argb || | |
| 1217 width <= 0 || height == 0) { | |
| 1218 return -1; | |
| 1219 } | |
| 1220 // Negative height means invert the image. | |
| 1221 if (height < 0) { | |
| 1222 height = -height; | |
| 1223 dst_argb = dst_argb + (height - 1) * dst_stride_argb; | |
| 1224 dst_stride_argb = -dst_stride_argb; | |
| 1225 } | |
| 1226 #if defined(HAS_I422TOARGBROW_SSSE3) | |
| 1227 if (TestCpuFlag(kCpuHasSSSE3)) { | |
| 1228 I422ToARGBRow = I422ToARGBRow_Any_SSSE3; | |
| 1229 if (IS_ALIGNED(width, 8)) { | |
| 1230 I422ToARGBRow = I422ToARGBRow_SSSE3; | |
| 1231 } | |
| 1232 } | |
| 1233 #endif | |
| 1234 #if defined(HAS_I422TOARGBROW_AVX2) | |
| 1235 if (TestCpuFlag(kCpuHasAVX2)) { | |
| 1236 I422ToARGBRow = I422ToARGBRow_Any_AVX2; | |
| 1237 if (IS_ALIGNED(width, 16)) { | |
| 1238 I422ToARGBRow = I422ToARGBRow_AVX2; | |
| 1239 } | |
| 1240 } | |
| 1241 #endif | |
| 1242 #if defined(HAS_I422TOARGBROW_NEON) | |
| 1243 if (TestCpuFlag(kCpuHasNEON)) { | |
| 1244 I422ToARGBRow = I422ToARGBRow_Any_NEON; | |
| 1245 if (IS_ALIGNED(width, 8)) { | |
| 1246 I422ToARGBRow = I422ToARGBRow_NEON; | |
| 1247 } | |
| 1248 } | |
| 1249 #endif | |
| 1250 #if defined(HAS_I422TOARGBROW_MIPS_DSPR2) | |
| 1251 if (TestCpuFlag(kCpuHasMIPS_DSPR2) && IS_ALIGNED(width, 4) && | |
| 1252 IS_ALIGNED(src_y, 4) && IS_ALIGNED(src_stride_y, 4) && | |
| 1253 IS_ALIGNED(src_u, 2) && IS_ALIGNED(src_stride_u, 2) && | |
| 1254 IS_ALIGNED(src_v, 2) && IS_ALIGNED(src_stride_v, 2) && | |
| 1255 IS_ALIGNED(dst_argb, 4) && IS_ALIGNED(dst_stride_argb, 4)) { | |
| 1256 I422ToARGBRow = I422ToARGBRow_MIPS_DSPR2; | |
| 1257 } | |
| 1258 #endif | |
| 1259 | |
| 1260 for (y = 0; y < height; ++y) { | |
| 1261 I422ToARGBRow(src_y, src_u, src_v, dst_argb, &kYuvJConstants, width); | |
| 1262 dst_argb += dst_stride_argb; | |
| 1263 src_y += src_stride_y; | |
| 1264 if (y & 1) { | |
| 1265 src_u += src_stride_u; | |
| 1266 src_v += src_stride_v; | |
| 1267 } | |
| 1268 } | |
| 1269 return 0; | |
| 1270 } | |
| 1271 | |
| 1272 // Convert J422 to ARGB. | |
| 1273 LIBYUV_API | |
| 1274 int J422ToARGB(const uint8* src_y, int src_stride_y, | |
| 1275 const uint8* src_u, int src_stride_u, | |
| 1276 const uint8* src_v, int src_stride_v, | |
| 1277 uint8* dst_argb, int dst_stride_argb, | |
| 1278 int width, int height) { | |
| 1279 int y; | |
| 1280 void (*I422ToARGBRow)(const uint8* y_buf, | |
| 1281 const uint8* u_buf, | |
| 1282 const uint8* v_buf, | |
| 1283 uint8* rgb_buf, | |
| 1284 const struct YuvConstants* yuvconstants, | |
| 1285 int width) = I422ToARGBRow_C; | |
| 1286 if (!src_y || !src_u || !src_v || | |
| 1287 !dst_argb || | |
| 1288 width <= 0 || height == 0) { | |
| 1289 return -1; | |
| 1290 } | |
| 1291 // Negative height means invert the image. | |
| 1292 if (height < 0) { | |
| 1293 height = -height; | |
| 1294 dst_argb = dst_argb + (height - 1) * dst_stride_argb; | |
| 1295 dst_stride_argb = -dst_stride_argb; | |
| 1296 } | |
| 1297 // Coalesce rows. | |
| 1298 if (src_stride_y == width && | |
| 1299 src_stride_u * 2 == width && | |
| 1300 src_stride_v * 2 == width && | |
| 1301 dst_stride_argb == width * 4) { | |
| 1302 width *= height; | |
| 1303 height = 1; | |
| 1304 src_stride_y = src_stride_u = src_stride_v = dst_stride_argb = 0; | |
| 1305 } | |
| 1306 #if defined(HAS_I422TOARGBROW_SSSE3) | |
| 1307 if (TestCpuFlag(kCpuHasSSSE3)) { | |
| 1308 I422ToARGBRow = I422ToARGBRow_Any_SSSE3; | |
| 1309 if (IS_ALIGNED(width, 8)) { | |
| 1310 I422ToARGBRow = I422ToARGBRow_SSSE3; | |
| 1311 } | |
| 1312 } | |
| 1313 #endif | |
| 1314 #if defined(HAS_I422TOARGBROW_AVX2) | |
| 1315 if (TestCpuFlag(kCpuHasAVX2)) { | |
| 1316 I422ToARGBRow = I422ToARGBRow_Any_AVX2; | |
| 1317 if (IS_ALIGNED(width, 16)) { | |
| 1318 I422ToARGBRow = I422ToARGBRow_AVX2; | |
| 1319 } | |
| 1320 } | |
| 1321 #endif | |
| 1322 #if defined(HAS_I422TOARGBROW_NEON) | |
| 1323 if (TestCpuFlag(kCpuHasNEON)) { | |
| 1324 I422ToARGBRow = I422ToARGBRow_Any_NEON; | |
| 1325 if (IS_ALIGNED(width, 8)) { | |
| 1326 I422ToARGBRow = I422ToARGBRow_NEON; | |
| 1327 } | |
| 1328 } | |
| 1329 #endif | |
| 1330 #if defined(HAS_I422TOARGBROW_MIPS_DSPR2) | |
| 1331 if (TestCpuFlag(kCpuHasMIPS_DSPR2) && IS_ALIGNED(width, 4) && | |
| 1332 IS_ALIGNED(src_y, 4) && IS_ALIGNED(src_stride_y, 4) && | |
| 1333 IS_ALIGNED(src_u, 2) && IS_ALIGNED(src_stride_u, 2) && | |
| 1334 IS_ALIGNED(src_v, 2) && IS_ALIGNED(src_stride_v, 2) && | |
| 1335 IS_ALIGNED(dst_argb, 4) && IS_ALIGNED(dst_stride_argb, 4)) { | |
| 1336 I422ToARGBRow = I422ToARGBRow_MIPS_DSPR2; | |
| 1337 } | |
| 1338 #endif | |
| 1339 | |
| 1340 for (y = 0; y < height; ++y) { | |
| 1341 I422ToARGBRow(src_y, src_u, src_v, dst_argb, &kYuvJConstants, width); | |
| 1342 dst_argb += dst_stride_argb; | |
| 1343 src_y += src_stride_y; | |
| 1344 src_u += src_stride_u; | |
| 1345 src_v += src_stride_v; | |
| 1346 } | |
| 1347 return 0; | |
| 1348 } | |
| 1349 | |
| 1350 // Convert J420 to ABGR. | |
| 1351 LIBYUV_API | |
| 1352 int J420ToABGR(const uint8* src_y, int src_stride_y, | |
| 1353 const uint8* src_u, int src_stride_u, | |
| 1354 const uint8* src_v, int src_stride_v, | |
| 1355 uint8* dst_abgr, int dst_stride_abgr, | |
| 1356 int width, int height) { | |
| 1357 int y; | |
| 1358 void (*I422ToABGRRow)(const uint8* y_buf, | |
| 1359 const uint8* u_buf, | |
| 1360 const uint8* v_buf, | |
| 1361 uint8* rgb_buf, | |
| 1362 const struct YuvConstants* yuvconstants, | |
| 1363 int width) = I422ToABGRRow_C; | |
| 1364 if (!src_y || !src_u || !src_v || !dst_abgr || | |
| 1365 width <= 0 || height == 0) { | |
| 1366 return -1; | |
| 1367 } | |
| 1368 // Negative height means invert the image. | |
| 1369 if (height < 0) { | |
| 1370 height = -height; | |
| 1371 dst_abgr = dst_abgr + (height - 1) * dst_stride_abgr; | |
| 1372 dst_stride_abgr = -dst_stride_abgr; | |
| 1373 } | |
| 1374 #if defined(HAS_I422TOABGRROW_SSSE3) | |
| 1375 if (TestCpuFlag(kCpuHasSSSE3)) { | |
| 1376 I422ToABGRRow = I422ToABGRRow_Any_SSSE3; | |
| 1377 if (IS_ALIGNED(width, 8)) { | |
| 1378 I422ToABGRRow = I422ToABGRRow_SSSE3; | |
| 1379 } | |
| 1380 } | |
| 1381 #endif | |
| 1382 #if defined(HAS_I422TOABGRROW_AVX2) | |
| 1383 if (TestCpuFlag(kCpuHasAVX2)) { | |
| 1384 I422ToABGRRow = I422ToABGRRow_Any_AVX2; | |
| 1385 if (IS_ALIGNED(width, 16)) { | |
| 1386 I422ToABGRRow = I422ToABGRRow_AVX2; | |
| 1387 } | |
| 1388 } | |
| 1389 #endif | |
| 1390 #if defined(HAS_I422TOABGRROW_NEON) | |
| 1391 if (TestCpuFlag(kCpuHasNEON)) { | |
| 1392 I422ToABGRRow = I422ToABGRRow_Any_NEON; | |
| 1393 if (IS_ALIGNED(width, 8)) { | |
| 1394 I422ToABGRRow = I422ToABGRRow_NEON; | |
| 1395 } | |
| 1396 } | |
| 1397 #endif | |
| 1398 #if defined(HAS_I422TOABGRROW_MIPS_DSPR2) | |
| 1399 if (TestCpuFlag(kCpuHasMIPS_DSPR2) && IS_ALIGNED(width, 4) && | |
| 1400 IS_ALIGNED(src_y, 4) && IS_ALIGNED(src_stride_y, 4) && | |
| 1401 IS_ALIGNED(src_u, 2) && IS_ALIGNED(src_stride_u, 2) && | |
| 1402 IS_ALIGNED(src_v, 2) && IS_ALIGNED(src_stride_v, 2) && | |
| 1403 IS_ALIGNED(dst_abgr, 4) && IS_ALIGNED(dst_stride_abgr, 4)) { | |
| 1404 I422ToABGRRow = I422ToABGRRow_MIPS_DSPR2; | |
| 1405 } | |
| 1406 #endif | |
| 1407 | |
| 1408 for (y = 0; y < height; ++y) { | |
| 1409 I422ToABGRRow(src_y, src_u, src_v, dst_abgr, &kYuvJConstants, width); | |
| 1410 dst_abgr += dst_stride_abgr; | |
| 1411 src_y += src_stride_y; | |
| 1412 if (y & 1) { | |
| 1413 src_u += src_stride_u; | |
| 1414 src_v += src_stride_v; | |
| 1415 } | |
| 1416 } | |
| 1417 return 0; | |
| 1418 } | |
| 1419 | |
| 1420 // Convert J422 to ABGR. | |
| 1421 LIBYUV_API | |
| 1422 int J422ToABGR(const uint8* src_y, int src_stride_y, | |
| 1423 const uint8* src_u, int src_stride_u, | |
| 1424 const uint8* src_v, int src_stride_v, | |
| 1425 uint8* dst_abgr, int dst_stride_abgr, | |
| 1426 int width, int height) { | |
| 1427 int y; | |
| 1428 void (*I422ToABGRRow)(const uint8* y_buf, | |
| 1429 const uint8* u_buf, | |
| 1430 const uint8* v_buf, | |
| 1431 uint8* rgb_buf, | |
| 1432 const struct YuvConstants* yuvconstants, | |
| 1433 int width) = I422ToABGRRow_C; | |
| 1434 if (!src_y || !src_u || !src_v || | |
| 1435 !dst_abgr || | |
| 1436 width <= 0 || height == 0) { | |
| 1437 return -1; | |
| 1438 } | |
| 1439 // Negative height means invert the image. | |
| 1440 if (height < 0) { | |
| 1441 height = -height; | |
| 1442 dst_abgr = dst_abgr + (height - 1) * dst_stride_abgr; | |
| 1443 dst_stride_abgr = -dst_stride_abgr; | |
| 1444 } | |
| 1445 // Coalesce rows. | |
| 1446 if (src_stride_y == width && | |
| 1447 src_stride_u * 2 == width && | |
| 1448 src_stride_v * 2 == width && | |
| 1449 dst_stride_abgr == width * 4) { | |
| 1450 width *= height; | |
| 1451 height = 1; | |
| 1452 src_stride_y = src_stride_u = src_stride_v = dst_stride_abgr = 0; | |
| 1453 } | |
| 1454 #if defined(HAS_I422TOABGRROW_SSSE3) | |
| 1455 if (TestCpuFlag(kCpuHasSSSE3)) { | |
| 1456 I422ToABGRRow = I422ToABGRRow_Any_SSSE3; | |
| 1457 if (IS_ALIGNED(width, 8)) { | |
| 1458 I422ToABGRRow = I422ToABGRRow_SSSE3; | |
| 1459 } | |
| 1460 } | |
| 1461 #endif | |
| 1462 #if defined(HAS_I422TOABGRROW_AVX2) | |
| 1463 if (TestCpuFlag(kCpuHasAVX2)) { | |
| 1464 I422ToABGRRow = I422ToABGRRow_Any_AVX2; | |
| 1465 if (IS_ALIGNED(width, 16)) { | |
| 1466 I422ToABGRRow = I422ToABGRRow_AVX2; | |
| 1467 } | |
| 1468 } | |
| 1469 #endif | |
| 1470 #if defined(HAS_I422TOABGRROW_NEON) | |
| 1471 if (TestCpuFlag(kCpuHasNEON)) { | |
| 1472 I422ToABGRRow = I422ToABGRRow_Any_NEON; | |
| 1473 if (IS_ALIGNED(width, 8)) { | |
| 1474 I422ToABGRRow = I422ToABGRRow_NEON; | |
| 1475 } | |
| 1476 } | |
| 1477 #endif | |
| 1478 #if defined(HAS_I422TOABGRROW_MIPS_DSPR2) | |
| 1479 if (TestCpuFlag(kCpuHasMIPS_DSPR2) && IS_ALIGNED(width, 4) && | |
| 1480 IS_ALIGNED(src_y, 4) && IS_ALIGNED(src_stride_y, 4) && | |
| 1481 IS_ALIGNED(src_u, 2) && IS_ALIGNED(src_stride_u, 2) && | |
| 1482 IS_ALIGNED(src_v, 2) && IS_ALIGNED(src_stride_v, 2) && | |
| 1483 IS_ALIGNED(dst_abgr, 4) && IS_ALIGNED(dst_stride_abgr, 4)) { | |
| 1484 I422ToABGRRow = I422ToABGRRow_MIPS_DSPR2; | |
| 1485 } | |
| 1486 #endif | |
| 1487 | |
| 1488 for (y = 0; y < height; ++y) { | |
| 1489 I422ToABGRRow(src_y, src_u, src_v, dst_abgr, &kYuvJConstants, width); | |
| 1490 dst_abgr += dst_stride_abgr; | |
| 1491 src_y += src_stride_y; | |
| 1492 src_u += src_stride_u; | |
| 1493 src_v += src_stride_v; | |
| 1494 } | |
| 1495 return 0; | |
| 1496 } | |
| 1497 | |
| 1498 // Convert H420 to ARGB. | |
| 1499 LIBYUV_API | |
| 1500 int H420ToARGB(const uint8* src_y, int src_stride_y, | |
| 1501 const uint8* src_u, int src_stride_u, | |
| 1502 const uint8* src_v, int src_stride_v, | |
| 1503 uint8* dst_argb, int dst_stride_argb, | |
| 1504 int width, int height) { | |
| 1505 int y; | |
| 1506 void (*I422ToARGBRow)(const uint8* y_buf, | |
| 1507 const uint8* u_buf, | |
| 1508 const uint8* v_buf, | |
| 1509 uint8* rgb_buf, | |
| 1510 const struct YuvConstants* yuvconstants, | |
| 1511 int width) = I422ToARGBRow_C; | |
| 1512 if (!src_y || !src_u || !src_v || !dst_argb || | |
| 1513 width <= 0 || height == 0) { | |
| 1514 return -1; | |
| 1515 } | |
| 1516 // Negative height means invert the image. | |
| 1517 if (height < 0) { | |
| 1518 height = -height; | |
| 1519 dst_argb = dst_argb + (height - 1) * dst_stride_argb; | |
| 1520 dst_stride_argb = -dst_stride_argb; | |
| 1521 } | |
| 1522 #if defined(HAS_I422TOARGBROW_SSSE3) | |
| 1523 if (TestCpuFlag(kCpuHasSSSE3)) { | |
| 1524 I422ToARGBRow = I422ToARGBRow_Any_SSSE3; | |
| 1525 if (IS_ALIGNED(width, 8)) { | |
| 1526 I422ToARGBRow = I422ToARGBRow_SSSE3; | |
| 1527 } | |
| 1528 } | |
| 1529 #endif | |
| 1530 #if defined(HAS_I422TOARGBROW_AVX2) | |
| 1531 if (TestCpuFlag(kCpuHasAVX2)) { | |
| 1532 I422ToARGBRow = I422ToARGBRow_Any_AVX2; | |
| 1533 if (IS_ALIGNED(width, 16)) { | |
| 1534 I422ToARGBRow = I422ToARGBRow_AVX2; | |
| 1535 } | |
| 1536 } | |
| 1537 #endif | |
| 1538 #if defined(HAS_I422TOARGBROW_NEON) | |
| 1539 if (TestCpuFlag(kCpuHasNEON)) { | |
| 1540 I422ToARGBRow = I422ToARGBRow_Any_NEON; | |
| 1541 if (IS_ALIGNED(width, 8)) { | |
| 1542 I422ToARGBRow = I422ToARGBRow_NEON; | |
| 1543 } | |
| 1544 } | |
| 1545 #endif | |
| 1546 #if defined(HAS_I422TOARGBROW_MIPS_DSPR2) | |
| 1547 if (TestCpuFlag(kCpuHasMIPS_DSPR2) && IS_ALIGNED(width, 4) && | |
| 1548 IS_ALIGNED(src_y, 4) && IS_ALIGNED(src_stride_y, 4) && | |
| 1549 IS_ALIGNED(src_u, 2) && IS_ALIGNED(src_stride_u, 2) && | |
| 1550 IS_ALIGNED(src_v, 2) && IS_ALIGNED(src_stride_v, 2) && | |
| 1551 IS_ALIGNED(dst_argb, 4) && IS_ALIGNED(dst_stride_argb, 4)) { | |
| 1552 I422ToARGBRow = I422ToARGBRow_MIPS_DSPR2; | |
| 1553 } | |
| 1554 #endif | |
| 1555 | |
| 1556 for (y = 0; y < height; ++y) { | |
| 1557 I422ToARGBRow(src_y, src_u, src_v, dst_argb, &kYuvHConstants, width); | |
| 1558 dst_argb += dst_stride_argb; | |
| 1559 src_y += src_stride_y; | |
| 1560 if (y & 1) { | |
| 1561 src_u += src_stride_u; | |
| 1562 src_v += src_stride_v; | |
| 1563 } | |
| 1564 } | |
| 1565 return 0; | |
| 1566 } | |
| 1567 | |
| 1568 // Convert H422 to ARGB. | |
| 1569 LIBYUV_API | |
| 1570 int H422ToARGB(const uint8* src_y, int src_stride_y, | |
| 1571 const uint8* src_u, int src_stride_u, | |
| 1572 const uint8* src_v, int src_stride_v, | |
| 1573 uint8* dst_argb, int dst_stride_argb, | |
| 1574 int width, int height) { | |
| 1575 int y; | |
| 1576 void (*I422ToARGBRow)(const uint8* y_buf, | |
| 1577 const uint8* u_buf, | |
| 1578 const uint8* v_buf, | |
| 1579 uint8* rgb_buf, | |
| 1580 const struct YuvConstants* yuvconstants, | |
| 1581 int width) = I422ToARGBRow_C; | |
| 1582 if (!src_y || !src_u || !src_v || | |
| 1583 !dst_argb || | |
| 1584 width <= 0 || height == 0) { | |
| 1585 return -1; | |
| 1586 } | |
| 1587 // Negative height means invert the image. | |
| 1588 if (height < 0) { | |
| 1589 height = -height; | |
| 1590 dst_argb = dst_argb + (height - 1) * dst_stride_argb; | |
| 1591 dst_stride_argb = -dst_stride_argb; | |
| 1592 } | |
| 1593 // Coalesce rows. | |
| 1594 if (src_stride_y == width && | |
| 1595 src_stride_u * 2 == width && | |
| 1596 src_stride_v * 2 == width && | |
| 1597 dst_stride_argb == width * 4) { | |
| 1598 width *= height; | |
| 1599 height = 1; | |
| 1600 src_stride_y = src_stride_u = src_stride_v = dst_stride_argb = 0; | |
| 1601 } | |
| 1602 #if defined(HAS_I422TOARGBROW_SSSE3) | |
| 1603 if (TestCpuFlag(kCpuHasSSSE3)) { | |
| 1604 I422ToARGBRow = I422ToARGBRow_Any_SSSE3; | |
| 1605 if (IS_ALIGNED(width, 8)) { | |
| 1606 I422ToARGBRow = I422ToARGBRow_SSSE3; | |
| 1607 } | |
| 1608 } | |
| 1609 #endif | |
| 1610 #if defined(HAS_I422TOARGBROW_AVX2) | |
| 1611 if (TestCpuFlag(kCpuHasAVX2)) { | |
| 1612 I422ToARGBRow = I422ToARGBRow_Any_AVX2; | |
| 1613 if (IS_ALIGNED(width, 16)) { | |
| 1614 I422ToARGBRow = I422ToARGBRow_AVX2; | |
| 1615 } | |
| 1616 } | |
| 1617 #endif | |
| 1618 #if defined(HAS_I422TOARGBROW_NEON) | |
| 1619 if (TestCpuFlag(kCpuHasNEON)) { | |
| 1620 I422ToARGBRow = I422ToARGBRow_Any_NEON; | |
| 1621 if (IS_ALIGNED(width, 8)) { | |
| 1622 I422ToARGBRow = I422ToARGBRow_NEON; | |
| 1623 } | |
| 1624 } | |
| 1625 #endif | |
| 1626 #if defined(HAS_I422TOARGBROW_MIPS_DSPR2) | |
| 1627 if (TestCpuFlag(kCpuHasMIPS_DSPR2) && IS_ALIGNED(width, 4) && | |
| 1628 IS_ALIGNED(src_y, 4) && IS_ALIGNED(src_stride_y, 4) && | |
| 1629 IS_ALIGNED(src_u, 2) && IS_ALIGNED(src_stride_u, 2) && | |
| 1630 IS_ALIGNED(src_v, 2) && IS_ALIGNED(src_stride_v, 2) && | |
| 1631 IS_ALIGNED(dst_argb, 4) && IS_ALIGNED(dst_stride_argb, 4)) { | |
| 1632 I422ToARGBRow = I422ToARGBRow_MIPS_DSPR2; | |
| 1633 } | |
| 1634 #endif | |
| 1635 | |
| 1636 for (y = 0; y < height; ++y) { | |
| 1637 I422ToARGBRow(src_y, src_u, src_v, dst_argb, &kYuvHConstants, width); | |
| 1638 dst_argb += dst_stride_argb; | |
| 1639 src_y += src_stride_y; | |
| 1640 src_u += src_stride_u; | |
| 1641 src_v += src_stride_v; | |
| 1642 } | |
| 1643 return 0; | |
| 1644 } | |
| 1645 | |
| 1646 // Convert H420 to ABGR. | |
| 1647 LIBYUV_API | |
| 1648 int H420ToABGR(const uint8* src_y, int src_stride_y, | |
| 1649 const uint8* src_u, int src_stride_u, | |
| 1650 const uint8* src_v, int src_stride_v, | |
| 1651 uint8* dst_abgr, int dst_stride_abgr, | |
| 1652 int width, int height) { | |
| 1653 int y; | |
| 1654 void (*I422ToABGRRow)(const uint8* y_buf, | |
| 1655 const uint8* u_buf, | |
| 1656 const uint8* v_buf, | |
| 1657 uint8* rgb_buf, | |
| 1658 const struct YuvConstants* yuvconstants, | |
| 1659 int width) = I422ToABGRRow_C; | |
| 1660 if (!src_y || !src_u || !src_v || !dst_abgr || | |
| 1661 width <= 0 || height == 0) { | |
| 1662 return -1; | |
| 1663 } | |
| 1664 // Negative height means invert the image. | |
| 1665 if (height < 0) { | |
| 1666 height = -height; | |
| 1667 dst_abgr = dst_abgr + (height - 1) * dst_stride_abgr; | |
| 1668 dst_stride_abgr = -dst_stride_abgr; | |
| 1669 } | |
| 1670 #if defined(HAS_I422TOABGRROW_SSSE3) | |
| 1671 if (TestCpuFlag(kCpuHasSSSE3)) { | |
| 1672 I422ToABGRRow = I422ToABGRRow_Any_SSSE3; | |
| 1673 if (IS_ALIGNED(width, 8)) { | |
| 1674 I422ToABGRRow = I422ToABGRRow_SSSE3; | |
| 1675 } | |
| 1676 } | |
| 1677 #endif | |
| 1678 #if defined(HAS_I422TOABGRROW_AVX2) | |
| 1679 if (TestCpuFlag(kCpuHasAVX2)) { | |
| 1680 I422ToABGRRow = I422ToABGRRow_Any_AVX2; | |
| 1681 if (IS_ALIGNED(width, 16)) { | |
| 1682 I422ToABGRRow = I422ToABGRRow_AVX2; | |
| 1683 } | |
| 1684 } | |
| 1685 #endif | |
| 1686 #if defined(HAS_I422TOABGRROW_NEON) | |
| 1687 if (TestCpuFlag(kCpuHasNEON)) { | |
| 1688 I422ToABGRRow = I422ToABGRRow_Any_NEON; | |
| 1689 if (IS_ALIGNED(width, 8)) { | |
| 1690 I422ToABGRRow = I422ToABGRRow_NEON; | |
| 1691 } | |
| 1692 } | |
| 1693 #endif | |
| 1694 #if defined(HAS_I422TOABGRROW_MIPS_DSPR2) | |
| 1695 if (TestCpuFlag(kCpuHasMIPS_DSPR2) && IS_ALIGNED(width, 4) && | |
| 1696 IS_ALIGNED(src_y, 4) && IS_ALIGNED(src_stride_y, 4) && | |
| 1697 IS_ALIGNED(src_u, 2) && IS_ALIGNED(src_stride_u, 2) && | |
| 1698 IS_ALIGNED(src_v, 2) && IS_ALIGNED(src_stride_v, 2) && | |
| 1699 IS_ALIGNED(dst_abgr, 4) && IS_ALIGNED(dst_stride_abgr, 4)) { | |
| 1700 I422ToABGRRow = I422ToABGRRow_MIPS_DSPR2; | |
| 1701 } | |
| 1702 #endif | |
| 1703 | |
| 1704 for (y = 0; y < height; ++y) { | |
| 1705 I422ToABGRRow(src_y, src_u, src_v, dst_abgr, &kYuvHConstants, width); | |
| 1706 dst_abgr += dst_stride_abgr; | |
| 1707 src_y += src_stride_y; | |
| 1708 if (y & 1) { | |
| 1709 src_u += src_stride_u; | |
| 1710 src_v += src_stride_v; | |
| 1711 } | |
| 1712 } | |
| 1713 return 0; | |
| 1714 } | |
| 1715 | |
| 1716 // Convert H422 to ABGR. | |
| 1717 LIBYUV_API | |
| 1718 int H422ToABGR(const uint8* src_y, int src_stride_y, | |
| 1719 const uint8* src_u, int src_stride_u, | |
| 1720 const uint8* src_v, int src_stride_v, | |
| 1721 uint8* dst_abgr, int dst_stride_abgr, | |
| 1722 int width, int height) { | |
| 1723 int y; | |
| 1724 void (*I422ToABGRRow)(const uint8* y_buf, | |
| 1725 const uint8* u_buf, | |
| 1726 const uint8* v_buf, | |
| 1727 uint8* rgb_buf, | |
| 1728 const struct YuvConstants* yuvconstants, | |
| 1729 int width) = I422ToABGRRow_C; | |
| 1730 if (!src_y || !src_u || !src_v || | |
| 1731 !dst_abgr || | |
| 1732 width <= 0 || height == 0) { | |
| 1733 return -1; | |
| 1734 } | |
| 1735 // Negative height means invert the image. | |
| 1736 if (height < 0) { | |
| 1737 height = -height; | |
| 1738 dst_abgr = dst_abgr + (height - 1) * dst_stride_abgr; | |
| 1739 dst_stride_abgr = -dst_stride_abgr; | |
| 1740 } | |
| 1741 // Coalesce rows. | |
| 1742 if (src_stride_y == width && | |
| 1743 src_stride_u * 2 == width && | |
| 1744 src_stride_v * 2 == width && | |
| 1745 dst_stride_abgr == width * 4) { | |
| 1746 width *= height; | |
| 1747 height = 1; | |
| 1748 src_stride_y = src_stride_u = src_stride_v = dst_stride_abgr = 0; | |
| 1749 } | |
| 1750 #if defined(HAS_I422TOABGRROW_SSSE3) | |
| 1751 if (TestCpuFlag(kCpuHasSSSE3)) { | |
| 1752 I422ToABGRRow = I422ToABGRRow_Any_SSSE3; | |
| 1753 if (IS_ALIGNED(width, 8)) { | |
| 1754 I422ToABGRRow = I422ToABGRRow_SSSE3; | |
| 1755 } | |
| 1756 } | |
| 1757 #endif | |
| 1758 #if defined(HAS_I422TOABGRROW_AVX2) | |
| 1759 if (TestCpuFlag(kCpuHasAVX2)) { | |
| 1760 I422ToABGRRow = I422ToABGRRow_Any_AVX2; | |
| 1761 if (IS_ALIGNED(width, 16)) { | |
| 1762 I422ToABGRRow = I422ToABGRRow_AVX2; | |
| 1763 } | |
| 1764 } | |
| 1765 #endif | |
| 1766 #if defined(HAS_I422TOABGRROW_NEON) | |
| 1767 if (TestCpuFlag(kCpuHasNEON)) { | |
| 1768 I422ToABGRRow = I422ToABGRRow_Any_NEON; | |
| 1769 if (IS_ALIGNED(width, 8)) { | |
| 1770 I422ToABGRRow = I422ToABGRRow_NEON; | |
| 1771 } | |
| 1772 } | |
| 1773 #endif | |
| 1774 #if defined(HAS_I422TOABGRROW_MIPS_DSPR2) | |
| 1775 if (TestCpuFlag(kCpuHasMIPS_DSPR2) && IS_ALIGNED(width, 4) && | |
| 1776 IS_ALIGNED(src_y, 4) && IS_ALIGNED(src_stride_y, 4) && | |
| 1777 IS_ALIGNED(src_u, 2) && IS_ALIGNED(src_stride_u, 2) && | |
| 1778 IS_ALIGNED(src_v, 2) && IS_ALIGNED(src_stride_v, 2) && | |
| 1779 IS_ALIGNED(dst_abgr, 4) && IS_ALIGNED(dst_stride_abgr, 4)) { | |
| 1780 I422ToABGRRow = I422ToABGRRow_MIPS_DSPR2; | |
| 1781 } | |
| 1782 #endif | |
| 1783 | |
| 1784 for (y = 0; y < height; ++y) { | |
| 1785 I422ToABGRRow(src_y, src_u, src_v, dst_abgr, &kYuvHConstants, width); | |
| 1786 dst_abgr += dst_stride_abgr; | |
| 1787 src_y += src_stride_y; | |
| 1788 src_u += src_stride_u; | |
| 1789 src_v += src_stride_v; | |
| 1790 } | |
| 1791 return 0; | |
| 1792 } | |
| 1793 | |
| 1794 #ifdef __cplusplus | 1452 #ifdef __cplusplus |
| 1795 } // extern "C" | 1453 } // extern "C" |
| 1796 } // namespace libyuv | 1454 } // namespace libyuv |
| 1797 #endif | 1455 #endif |
| OLD | NEW |