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 26 matching lines...) Expand all Loading... | |
| 37 int src_y_width, int src_y_height, | 37 int src_y_width, int src_y_height, |
| 38 int src_uv_width, int src_uv_height) { | 38 int src_uv_width, int src_uv_height) { |
| 39 const int dst_y_width = Abs(src_y_width); | 39 const int dst_y_width = Abs(src_y_width); |
| 40 const int dst_y_height = Abs(src_y_height); | 40 const int dst_y_height = Abs(src_y_height); |
| 41 const int dst_uv_width = SUBSAMPLE(dst_y_width, 1, 1); | 41 const int dst_uv_width = SUBSAMPLE(dst_y_width, 1, 1); |
| 42 const int dst_uv_height = SUBSAMPLE(dst_y_height, 1, 1); | 42 const int dst_uv_height = SUBSAMPLE(dst_y_height, 1, 1); |
| 43 if (src_y_width == 0 || src_y_height == 0 || | 43 if (src_y_width == 0 || src_y_height == 0 || |
| 44 src_uv_width == 0 || src_uv_height == 0) { | 44 src_uv_width == 0 || src_uv_height == 0) { |
| 45 return -1; | 45 return -1; |
| 46 } | 46 } |
| 47 // TODO(fbarchard): support NULL for dst_y | 47 // TODO(fbarchard): support NULL for dst_y |
|
fbarchard1
2016/08/24 23:04:11
check dst_y
| |
| 48 ScalePlane(src_y, src_stride_y, src_y_width, src_y_height, | 48 ScalePlane(src_y, src_stride_y, src_y_width, src_y_height, |
| 49 dst_y, dst_stride_y, dst_y_width, dst_y_height, | 49 dst_y, dst_stride_y, dst_y_width, dst_y_height, |
| 50 kFilterBilinear); | 50 kFilterBilinear); |
| 51 ScalePlane(src_u, src_stride_u, src_uv_width, src_uv_height, | 51 ScalePlane(src_u, src_stride_u, src_uv_width, src_uv_height, |
| 52 dst_u, dst_stride_u, dst_uv_width, dst_uv_height, | 52 dst_u, dst_stride_u, dst_uv_width, dst_uv_height, |
| 53 kFilterBilinear); | 53 kFilterBilinear); |
| 54 ScalePlane(src_v, src_stride_v, src_uv_width, src_uv_height, | 54 ScalePlane(src_v, src_stride_v, src_uv_width, src_uv_height, |
| 55 dst_v, dst_stride_v, dst_uv_width, dst_uv_height, | 55 dst_v, dst_stride_v, dst_uv_width, dst_uv_height, |
| 56 kFilterBilinear); | 56 kFilterBilinear); |
| 57 return 0; | 57 return 0; |
| (...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 222 CopyRow(src, dst, width); | 222 CopyRow(src, dst, width); |
| 223 CopyRow(src + src_stride_0, dst + dst_stride, width); | 223 CopyRow(src + src_stride_0, dst + dst_stride, width); |
| 224 src += src_stride_0 + src_stride_1; | 224 src += src_stride_0 + src_stride_1; |
| 225 dst += dst_stride * 2; | 225 dst += dst_stride * 2; |
| 226 } | 226 } |
| 227 if (height & 1) { | 227 if (height & 1) { |
| 228 CopyRow(src, dst, width); | 228 CopyRow(src, dst, width); |
| 229 } | 229 } |
| 230 } | 230 } |
| 231 | 231 |
| 232 // Support function for NV12 etc UV channels. | |
| 233 // Width and height are plane sizes (typically half pixel width). | |
| 234 static void SplitUVPlane(const uint8* src_uv, int src_stride_uv, | |
| 235 uint8* dst_u, int dst_stride_u, | |
| 236 uint8* dst_v, int dst_stride_v, | |
| 237 int width, int height) { | |
| 238 int y; | |
| 239 void (*SplitUVRow)(const uint8* src_uv, uint8* dst_u, uint8* dst_v, | |
| 240 int width) = SplitUVRow_C; | |
| 241 // Negative height means invert the image. | |
| 242 if (height < 0) { | |
| 243 height = -height; | |
| 244 dst_u = dst_u + (height - 1) * dst_stride_u; | |
| 245 dst_v = dst_v + (height - 1) * dst_stride_v; | |
| 246 dst_stride_u = -dst_stride_u; | |
| 247 dst_stride_v = -dst_stride_v; | |
| 248 } | |
| 249 // Coalesce rows. | |
| 250 if (src_stride_uv == width * 2 && | |
| 251 dst_stride_u == width && | |
| 252 dst_stride_v == width) { | |
| 253 width *= height; | |
| 254 height = 1; | |
| 255 src_stride_uv = dst_stride_u = dst_stride_v = 0; | |
| 256 } | |
| 257 #if defined(HAS_SPLITUVROW_SSE2) | |
| 258 if (TestCpuFlag(kCpuHasSSE2)) { | |
| 259 SplitUVRow = SplitUVRow_Any_SSE2; | |
| 260 if (IS_ALIGNED(width, 16)) { | |
| 261 SplitUVRow = SplitUVRow_SSE2; | |
| 262 } | |
| 263 } | |
| 264 #endif | |
| 265 #if defined(HAS_SPLITUVROW_AVX2) | |
| 266 if (TestCpuFlag(kCpuHasAVX2)) { | |
| 267 SplitUVRow = SplitUVRow_Any_AVX2; | |
| 268 if (IS_ALIGNED(width, 32)) { | |
| 269 SplitUVRow = SplitUVRow_AVX2; | |
| 270 } | |
| 271 } | |
| 272 #endif | |
| 273 #if defined(HAS_SPLITUVROW_NEON) | |
| 274 if (TestCpuFlag(kCpuHasNEON)) { | |
| 275 SplitUVRow = SplitUVRow_Any_NEON; | |
| 276 if (IS_ALIGNED(width, 16)) { | |
| 277 SplitUVRow = SplitUVRow_NEON; | |
| 278 } | |
| 279 } | |
| 280 #endif | |
| 281 #if defined(HAS_SPLITUVROW_DSPR2) | |
| 282 if (TestCpuFlag(kCpuHasDSPR2) && | |
| 283 IS_ALIGNED(dst_u, 4) && IS_ALIGNED(dst_stride_u, 4) && | |
| 284 IS_ALIGNED(dst_v, 4) && IS_ALIGNED(dst_stride_v, 4)) { | |
| 285 SplitUVRow = SplitUVRow_Any_DSPR2; | |
| 286 if (IS_ALIGNED(width, 16)) { | |
| 287 SplitUVRow = SplitUVRow_DSPR2; | |
| 288 } | |
| 289 } | |
| 290 #endif | |
| 291 | |
| 292 for (y = 0; y < height; ++y) { | |
| 293 // Copy a row of UV. | |
| 294 SplitUVRow(src_uv, dst_u, dst_v, width); | |
| 295 dst_u += dst_stride_u; | |
| 296 dst_v += dst_stride_v; | |
| 297 src_uv += src_stride_uv; | |
| 298 } | |
| 299 } | |
| 300 | |
| 301 // Support converting from FOURCC_M420 | 232 // Support converting from FOURCC_M420 |
| 302 // Useful for bandwidth constrained transports like USB 1.0 and 2.0 and for | 233 // Useful for bandwidth constrained transports like USB 1.0 and 2.0 and for |
| 303 // easy conversion to I420. | 234 // easy conversion to I420. |
| 304 // M420 format description: | 235 // M420 format description: |
| 305 // M420 is row biplanar 420: 2 rows of Y and 1 row of UV. | 236 // M420 is row biplanar 420: 2 rows of Y and 1 row of UV. |
| 306 // Chroma is half width / half height. (420) | 237 // Chroma is half width / half height. (420) |
| 307 // src_stride_m420 is row planar. Normally this will be the width in pixels. | 238 // src_stride_m420 is row planar. Normally this will be the width in pixels. |
| 308 // The UV plane is half width, but 2 values, so src_stride_m420 applies to | 239 // The UV plane is half width, but 2 values, so src_stride_m420 applies to |
| 309 // this as well as the two Y planes. | 240 // this as well as the two Y planes. |
| 310 static int X420ToI420(const uint8* src_y, | 241 static int X420ToI420(const uint8* src_y, |
| (...skipping 1174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1485 dst_u += dst_stride_u; | 1416 dst_u += dst_stride_u; |
| 1486 dst_v += dst_stride_v; | 1417 dst_v += dst_stride_v; |
| 1487 } | 1418 } |
| 1488 return 0; | 1419 return 0; |
| 1489 } | 1420 } |
| 1490 | 1421 |
| 1491 #ifdef __cplusplus | 1422 #ifdef __cplusplus |
| 1492 } // extern "C" | 1423 } // extern "C" |
| 1493 } // namespace libyuv | 1424 } // namespace libyuv |
| 1494 #endif | 1425 #endif |
| OLD | NEW |