Chromium Code Reviews| 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 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 219 CopyRow(src, dst, width); | 219 CopyRow(src, dst, width); |
| 220 CopyRow(src + src_stride_0, dst + dst_stride, width); | 220 CopyRow(src + src_stride_0, dst + dst_stride, width); |
| 221 src += src_stride_0 + src_stride_1; | 221 src += src_stride_0 + src_stride_1; |
| 222 dst += dst_stride * 2; | 222 dst += dst_stride * 2; |
| 223 } | 223 } |
| 224 if (height & 1) { | 224 if (height & 1) { |
| 225 CopyRow(src, dst, width); | 225 CopyRow(src, dst, width); |
| 226 } | 226 } |
| 227 } | 227 } |
| 228 | 228 |
| 229 // Support function for NV12 etc UV channels. | 229 LIBYUV_API |
| 230 // Width and height are plane sizes (typically half pixel width). | 230 int SplitUVPlane(const uint8* src_uv, int src_stride_uv, |
|
fbarchard1
2016/08/24 17:42:24
keep this comment.
| |
| 231 static void SplitUVPlane(const uint8* src_uv, int src_stride_uv, | 231 uint8* dst_u, int dst_stride_u, |
| 232 uint8* dst_u, int dst_stride_u, | 232 uint8* dst_v, int dst_stride_v, |
| 233 uint8* dst_v, int dst_stride_v, | 233 int width, int height) { |
| 234 int width, int height) { | 234 if (!src_uv || !dst_u || !dst_v || width <= 0 || height == 0) { |
| 235 int y; | 235 return -1; |
| 236 void (*SplitUVRow)(const uint8* src_uv, uint8* dst_u, uint8* dst_v, | 236 } |
| 237 int width) = SplitUVRow_C; | |
| 238 // Negative height means invert the image. | 237 // Negative height means invert the image. |
| 239 if (height < 0) { | 238 if (height < 0) { |
| 240 height = -height; | 239 height = -height; |
| 241 dst_u = dst_u + (height - 1) * dst_stride_u; | 240 dst_u = dst_u + (height - 1) * dst_stride_u; |
| 242 dst_v = dst_v + (height - 1) * dst_stride_v; | 241 dst_v = dst_v + (height - 1) * dst_stride_v; |
| 243 dst_stride_u = -dst_stride_u; | 242 dst_stride_u = -dst_stride_u; |
| 244 dst_stride_v = -dst_stride_v; | 243 dst_stride_v = -dst_stride_v; |
| 245 } | 244 } |
| 246 // Coalesce rows. | 245 // Coalesce rows. |
| 247 if (src_stride_uv == width * 2 && | 246 if (src_stride_uv == width * 2 && |
| 248 dst_stride_u == width && | 247 dst_stride_u == width && |
| 249 dst_stride_v == width) { | 248 dst_stride_v == width) { |
| 250 width *= height; | 249 width *= height; |
| 251 height = 1; | 250 height = 1; |
| 252 src_stride_uv = dst_stride_u = dst_stride_v = 0; | 251 src_stride_uv = dst_stride_u = dst_stride_v = 0; |
| 253 } | 252 } |
| 254 #if defined(HAS_SPLITUVROW_SSE2) | 253 SplitUVRowFunction SplitUVRow = GetOptimizedSplitUVRowFunction( |
| 255 if (TestCpuFlag(kCpuHasSSE2)) { | 254 src_uv, src_stride_uv, dst_u, dst_stride_u, dst_v, dst_stride_v, width); |
| 256 SplitUVRow = SplitUVRow_Any_SSE2; | |
| 257 if (IS_ALIGNED(width, 16)) { | |
| 258 SplitUVRow = SplitUVRow_SSE2; | |
| 259 } | |
| 260 } | |
| 261 #endif | |
| 262 #if defined(HAS_SPLITUVROW_AVX2) | |
| 263 if (TestCpuFlag(kCpuHasAVX2)) { | |
| 264 SplitUVRow = SplitUVRow_Any_AVX2; | |
| 265 if (IS_ALIGNED(width, 32)) { | |
| 266 SplitUVRow = SplitUVRow_AVX2; | |
| 267 } | |
| 268 } | |
| 269 #endif | |
| 270 #if defined(HAS_SPLITUVROW_NEON) | |
| 271 if (TestCpuFlag(kCpuHasNEON)) { | |
| 272 SplitUVRow = SplitUVRow_Any_NEON; | |
| 273 if (IS_ALIGNED(width, 16)) { | |
| 274 SplitUVRow = SplitUVRow_NEON; | |
| 275 } | |
| 276 } | |
| 277 #endif | |
| 278 #if defined(HAS_SPLITUVROW_DSPR2) | |
| 279 if (TestCpuFlag(kCpuHasDSPR2) && | |
| 280 IS_ALIGNED(dst_u, 4) && IS_ALIGNED(dst_stride_u, 4) && | |
| 281 IS_ALIGNED(dst_v, 4) && IS_ALIGNED(dst_stride_v, 4)) { | |
| 282 SplitUVRow = SplitUVRow_Any_DSPR2; | |
| 283 if (IS_ALIGNED(width, 16)) { | |
| 284 SplitUVRow = SplitUVRow_DSPR2; | |
| 285 } | |
| 286 } | |
| 287 #endif | |
| 288 | 255 |
| 289 for (y = 0; y < height; ++y) { | 256 for (int y = 0; y < height; ++y) { |
|
fbarchard1
2016/08/24 17:42:24
int y needs to be declared at top of function for
| |
| 290 // Copy a row of UV. | 257 // Copy a row of UV. |
| 291 SplitUVRow(src_uv, dst_u, dst_v, width); | 258 SplitUVRow(src_uv, dst_u, dst_v, width); |
| 292 dst_u += dst_stride_u; | 259 dst_u += dst_stride_u; |
| 293 dst_v += dst_stride_v; | 260 dst_v += dst_stride_v; |
| 294 src_uv += src_stride_uv; | 261 src_uv += src_stride_uv; |
| 295 } | 262 } |
| 263 return 0; | |
| 296 } | 264 } |
| 297 | 265 |
| 298 // Support converting from FOURCC_M420 | 266 // Support converting from FOURCC_M420 |
| 299 // Useful for bandwidth constrained transports like USB 1.0 and 2.0 and for | 267 // Useful for bandwidth constrained transports like USB 1.0 and 2.0 and for |
| 300 // easy conversion to I420. | 268 // easy conversion to I420. |
| 301 // M420 format description: | 269 // M420 format description: |
| 302 // M420 is row biplanar 420: 2 rows of Y and 1 row of UV. | 270 // M420 is row biplanar 420: 2 rows of Y and 1 row of UV. |
| 303 // Chroma is half width / half height. (420) | 271 // Chroma is half width / half height. (420) |
| 304 // src_stride_m420 is row planar. Normally this will be the width in pixels. | 272 // src_stride_m420 is row planar. Normally this will be the width in pixels. |
| 305 // The UV plane is half width, but 2 values, so src_stride_m420 applies to | 273 // The UV plane is half width, but 2 values, so src_stride_m420 applies to |
| (...skipping 1177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1483 dst_u += dst_stride_u; | 1451 dst_u += dst_stride_u; |
| 1484 dst_v += dst_stride_v; | 1452 dst_v += dst_stride_v; |
| 1485 } | 1453 } |
| 1486 return 0; | 1454 return 0; |
| 1487 } | 1455 } |
| 1488 | 1456 |
| 1489 #ifdef __cplusplus | 1457 #ifdef __cplusplus |
| 1490 } // extern "C" | 1458 } // extern "C" |
| 1491 } // namespace libyuv | 1459 } // namespace libyuv |
| 1492 #endif | 1460 #endif |
| OLD | NEW |