Thu, 22 Jan 2015 13:21:57 +0100
Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6
michael@0 | 1 | /* |
michael@0 | 2 | * Copyright 2012 The LibYuv Project Authors. All rights reserved. |
michael@0 | 3 | * |
michael@0 | 4 | * Use of this source code is governed by a BSD-style license |
michael@0 | 5 | * that can be found in the LICENSE file in the root of the source |
michael@0 | 6 | * tree. An additional intellectual property rights grant can be found |
michael@0 | 7 | * in the file PATENTS. All contributing project authors may |
michael@0 | 8 | * be found in the AUTHORS file in the root of the source tree. |
michael@0 | 9 | */ |
michael@0 | 10 | |
michael@0 | 11 | #include "libyuv/convert_from.h" |
michael@0 | 12 | |
michael@0 | 13 | #include "libyuv/basic_types.h" |
michael@0 | 14 | #include "libyuv/convert.h" // For I420Copy |
michael@0 | 15 | #include "libyuv/cpu_id.h" |
michael@0 | 16 | #include "libyuv/format_conversion.h" |
michael@0 | 17 | #include "libyuv/planar_functions.h" |
michael@0 | 18 | #include "libyuv/rotate.h" |
michael@0 | 19 | #include "libyuv/scale.h" // For ScalePlane() |
michael@0 | 20 | #include "libyuv/video_common.h" |
michael@0 | 21 | #include "libyuv/row.h" |
michael@0 | 22 | |
michael@0 | 23 | #ifdef __cplusplus |
michael@0 | 24 | namespace libyuv { |
michael@0 | 25 | extern "C" { |
michael@0 | 26 | #endif |
michael@0 | 27 | |
michael@0 | 28 | #define SUBSAMPLE(v, a, s) (v < 0) ? (-((-v + a) >> s)) : ((v + a) >> s) |
michael@0 | 29 | static __inline int Abs(int v) { |
michael@0 | 30 | return v >= 0 ? v : -v; |
michael@0 | 31 | } |
michael@0 | 32 | |
michael@0 | 33 | // I420 To any I4xx YUV format with mirroring. |
michael@0 | 34 | static int I420ToI4xx(const uint8* src_y, int src_stride_y, |
michael@0 | 35 | const uint8* src_u, int src_stride_u, |
michael@0 | 36 | const uint8* src_v, int src_stride_v, |
michael@0 | 37 | uint8* dst_y, int dst_stride_y, |
michael@0 | 38 | uint8* dst_u, int dst_stride_u, |
michael@0 | 39 | uint8* dst_v, int dst_stride_v, |
michael@0 | 40 | int src_y_width, int src_y_height, |
michael@0 | 41 | int dst_uv_width, int dst_uv_height) { |
michael@0 | 42 | if (src_y_width == 0 || src_y_height == 0 || |
michael@0 | 43 | dst_uv_width <= 0 || dst_uv_height <= 0) { |
michael@0 | 44 | return -1; |
michael@0 | 45 | } |
michael@0 | 46 | const int dst_y_width = Abs(src_y_width); |
michael@0 | 47 | const int dst_y_height = Abs(src_y_height); |
michael@0 | 48 | const int src_uv_width = SUBSAMPLE(src_y_width, 1, 1); |
michael@0 | 49 | const int src_uv_height = SUBSAMPLE(src_y_height, 1, 1); |
michael@0 | 50 | ScalePlane(src_y, src_stride_y, src_y_width, src_y_height, |
michael@0 | 51 | dst_y, dst_stride_y, dst_y_width, dst_y_height, |
michael@0 | 52 | kFilterBilinear); |
michael@0 | 53 | ScalePlane(src_u, src_stride_u, src_uv_width, src_uv_height, |
michael@0 | 54 | dst_u, dst_stride_u, dst_uv_width, dst_uv_height, |
michael@0 | 55 | kFilterBilinear); |
michael@0 | 56 | ScalePlane(src_v, src_stride_v, src_uv_width, src_uv_height, |
michael@0 | 57 | dst_v, dst_stride_v, dst_uv_width, dst_uv_height, |
michael@0 | 58 | kFilterBilinear); |
michael@0 | 59 | return 0; |
michael@0 | 60 | } |
michael@0 | 61 | |
michael@0 | 62 | // 420 chroma is 1/2 width, 1/2 height |
michael@0 | 63 | // 422 chroma is 1/2 width, 1x height |
michael@0 | 64 | LIBYUV_API |
michael@0 | 65 | int I420ToI422(const uint8* src_y, int src_stride_y, |
michael@0 | 66 | const uint8* src_u, int src_stride_u, |
michael@0 | 67 | const uint8* src_v, int src_stride_v, |
michael@0 | 68 | uint8* dst_y, int dst_stride_y, |
michael@0 | 69 | uint8* dst_u, int dst_stride_u, |
michael@0 | 70 | uint8* dst_v, int dst_stride_v, |
michael@0 | 71 | int width, int height) { |
michael@0 | 72 | const int dst_uv_width = (Abs(width) + 1) >> 1; |
michael@0 | 73 | const int dst_uv_height = Abs(height); |
michael@0 | 74 | return I420ToI4xx(src_y, src_stride_y, |
michael@0 | 75 | src_u, src_stride_u, |
michael@0 | 76 | src_v, src_stride_v, |
michael@0 | 77 | dst_y, dst_stride_y, |
michael@0 | 78 | dst_u, dst_stride_u, |
michael@0 | 79 | dst_v, dst_stride_v, |
michael@0 | 80 | width, height, |
michael@0 | 81 | dst_uv_width, dst_uv_height); |
michael@0 | 82 | } |
michael@0 | 83 | |
michael@0 | 84 | // 420 chroma is 1/2 width, 1/2 height |
michael@0 | 85 | // 444 chroma is 1x width, 1x height |
michael@0 | 86 | LIBYUV_API |
michael@0 | 87 | int I420ToI444(const uint8* src_y, int src_stride_y, |
michael@0 | 88 | const uint8* src_u, int src_stride_u, |
michael@0 | 89 | const uint8* src_v, int src_stride_v, |
michael@0 | 90 | uint8* dst_y, int dst_stride_y, |
michael@0 | 91 | uint8* dst_u, int dst_stride_u, |
michael@0 | 92 | uint8* dst_v, int dst_stride_v, |
michael@0 | 93 | int width, int height) { |
michael@0 | 94 | const int dst_uv_width = Abs(width); |
michael@0 | 95 | const int dst_uv_height = Abs(height); |
michael@0 | 96 | return I420ToI4xx(src_y, src_stride_y, |
michael@0 | 97 | src_u, src_stride_u, |
michael@0 | 98 | src_v, src_stride_v, |
michael@0 | 99 | dst_y, dst_stride_y, |
michael@0 | 100 | dst_u, dst_stride_u, |
michael@0 | 101 | dst_v, dst_stride_v, |
michael@0 | 102 | width, height, |
michael@0 | 103 | dst_uv_width, dst_uv_height); |
michael@0 | 104 | } |
michael@0 | 105 | |
michael@0 | 106 | // 420 chroma is 1/2 width, 1/2 height |
michael@0 | 107 | // 411 chroma is 1/4 width, 1x height |
michael@0 | 108 | LIBYUV_API |
michael@0 | 109 | int I420ToI411(const uint8* src_y, int src_stride_y, |
michael@0 | 110 | const uint8* src_u, int src_stride_u, |
michael@0 | 111 | const uint8* src_v, int src_stride_v, |
michael@0 | 112 | uint8* dst_y, int dst_stride_y, |
michael@0 | 113 | uint8* dst_u, int dst_stride_u, |
michael@0 | 114 | uint8* dst_v, int dst_stride_v, |
michael@0 | 115 | int width, int height) { |
michael@0 | 116 | const int dst_uv_width = (Abs(width) + 3) >> 2; |
michael@0 | 117 | const int dst_uv_height = Abs(height); |
michael@0 | 118 | return I420ToI4xx(src_y, src_stride_y, |
michael@0 | 119 | src_u, src_stride_u, |
michael@0 | 120 | src_v, src_stride_v, |
michael@0 | 121 | dst_y, dst_stride_y, |
michael@0 | 122 | dst_u, dst_stride_u, |
michael@0 | 123 | dst_v, dst_stride_v, |
michael@0 | 124 | width, height, |
michael@0 | 125 | dst_uv_width, dst_uv_height); |
michael@0 | 126 | } |
michael@0 | 127 | |
michael@0 | 128 | // Copy to I400. Source can be I420,422,444,400,NV12,NV21 |
michael@0 | 129 | LIBYUV_API |
michael@0 | 130 | int I400Copy(const uint8* src_y, int src_stride_y, |
michael@0 | 131 | uint8* dst_y, int dst_stride_y, |
michael@0 | 132 | int width, int height) { |
michael@0 | 133 | if (!src_y || !dst_y || |
michael@0 | 134 | width <= 0 || height == 0) { |
michael@0 | 135 | return -1; |
michael@0 | 136 | } |
michael@0 | 137 | // Negative height means invert the image. |
michael@0 | 138 | if (height < 0) { |
michael@0 | 139 | height = -height; |
michael@0 | 140 | src_y = src_y + (height - 1) * src_stride_y; |
michael@0 | 141 | src_stride_y = -src_stride_y; |
michael@0 | 142 | } |
michael@0 | 143 | CopyPlane(src_y, src_stride_y, dst_y, dst_stride_y, width, height); |
michael@0 | 144 | return 0; |
michael@0 | 145 | } |
michael@0 | 146 | |
michael@0 | 147 | LIBYUV_API |
michael@0 | 148 | int I422ToYUY2(const uint8* src_y, int src_stride_y, |
michael@0 | 149 | const uint8* src_u, int src_stride_u, |
michael@0 | 150 | const uint8* src_v, int src_stride_v, |
michael@0 | 151 | uint8* dst_yuy2, int dst_stride_yuy2, |
michael@0 | 152 | int width, int height) { |
michael@0 | 153 | if (!src_y || !src_u || !src_v || !dst_yuy2 || |
michael@0 | 154 | width <= 0 || height == 0) { |
michael@0 | 155 | return -1; |
michael@0 | 156 | } |
michael@0 | 157 | // Negative height means invert the image. |
michael@0 | 158 | if (height < 0) { |
michael@0 | 159 | height = -height; |
michael@0 | 160 | dst_yuy2 = dst_yuy2 + (height - 1) * dst_stride_yuy2; |
michael@0 | 161 | dst_stride_yuy2 = -dst_stride_yuy2; |
michael@0 | 162 | } |
michael@0 | 163 | // Coalesce rows. |
michael@0 | 164 | if (src_stride_y == width && |
michael@0 | 165 | src_stride_u * 2 == width && |
michael@0 | 166 | src_stride_v * 2 == width && |
michael@0 | 167 | dst_stride_yuy2 == width * 2) { |
michael@0 | 168 | width *= height; |
michael@0 | 169 | height = 1; |
michael@0 | 170 | src_stride_y = src_stride_u = src_stride_v = dst_stride_yuy2 = 0; |
michael@0 | 171 | } |
michael@0 | 172 | void (*I422ToYUY2Row)(const uint8* src_y, const uint8* src_u, |
michael@0 | 173 | const uint8* src_v, uint8* dst_yuy2, int width) = |
michael@0 | 174 | I422ToYUY2Row_C; |
michael@0 | 175 | #if defined(HAS_I422TOYUY2ROW_SSE2) |
michael@0 | 176 | if (TestCpuFlag(kCpuHasSSE2) && width >= 16) { |
michael@0 | 177 | I422ToYUY2Row = I422ToYUY2Row_Any_SSE2; |
michael@0 | 178 | if (IS_ALIGNED(width, 16)) { |
michael@0 | 179 | I422ToYUY2Row = I422ToYUY2Row_SSE2; |
michael@0 | 180 | } |
michael@0 | 181 | } |
michael@0 | 182 | #elif defined(HAS_I422TOYUY2ROW_NEON) |
michael@0 | 183 | if (TestCpuFlag(kCpuHasNEON) && width >= 16) { |
michael@0 | 184 | I422ToYUY2Row = I422ToYUY2Row_Any_NEON; |
michael@0 | 185 | if (IS_ALIGNED(width, 16)) { |
michael@0 | 186 | I422ToYUY2Row = I422ToYUY2Row_NEON; |
michael@0 | 187 | } |
michael@0 | 188 | } |
michael@0 | 189 | #endif |
michael@0 | 190 | |
michael@0 | 191 | for (int y = 0; y < height; ++y) { |
michael@0 | 192 | I422ToYUY2Row(src_y, src_u, src_v, dst_yuy2, width); |
michael@0 | 193 | src_y += src_stride_y; |
michael@0 | 194 | src_u += src_stride_u; |
michael@0 | 195 | src_v += src_stride_v; |
michael@0 | 196 | dst_yuy2 += dst_stride_yuy2; |
michael@0 | 197 | } |
michael@0 | 198 | return 0; |
michael@0 | 199 | } |
michael@0 | 200 | |
michael@0 | 201 | LIBYUV_API |
michael@0 | 202 | int I420ToYUY2(const uint8* src_y, int src_stride_y, |
michael@0 | 203 | const uint8* src_u, int src_stride_u, |
michael@0 | 204 | const uint8* src_v, int src_stride_v, |
michael@0 | 205 | uint8* dst_yuy2, int dst_stride_yuy2, |
michael@0 | 206 | int width, int height) { |
michael@0 | 207 | if (!src_y || !src_u || !src_v || !dst_yuy2 || |
michael@0 | 208 | width <= 0 || height == 0) { |
michael@0 | 209 | return -1; |
michael@0 | 210 | } |
michael@0 | 211 | // Negative height means invert the image. |
michael@0 | 212 | if (height < 0) { |
michael@0 | 213 | height = -height; |
michael@0 | 214 | dst_yuy2 = dst_yuy2 + (height - 1) * dst_stride_yuy2; |
michael@0 | 215 | dst_stride_yuy2 = -dst_stride_yuy2; |
michael@0 | 216 | } |
michael@0 | 217 | void (*I422ToYUY2Row)(const uint8* src_y, const uint8* src_u, |
michael@0 | 218 | const uint8* src_v, uint8* dst_yuy2, int width) = |
michael@0 | 219 | I422ToYUY2Row_C; |
michael@0 | 220 | #if defined(HAS_I422TOYUY2ROW_SSE2) |
michael@0 | 221 | if (TestCpuFlag(kCpuHasSSE2) && width >= 16) { |
michael@0 | 222 | I422ToYUY2Row = I422ToYUY2Row_Any_SSE2; |
michael@0 | 223 | if (IS_ALIGNED(width, 16)) { |
michael@0 | 224 | I422ToYUY2Row = I422ToYUY2Row_SSE2; |
michael@0 | 225 | } |
michael@0 | 226 | } |
michael@0 | 227 | #elif defined(HAS_I422TOYUY2ROW_NEON) |
michael@0 | 228 | if (TestCpuFlag(kCpuHasNEON) && width >= 16) { |
michael@0 | 229 | I422ToYUY2Row = I422ToYUY2Row_Any_NEON; |
michael@0 | 230 | if (IS_ALIGNED(width, 16)) { |
michael@0 | 231 | I422ToYUY2Row = I422ToYUY2Row_NEON; |
michael@0 | 232 | } |
michael@0 | 233 | } |
michael@0 | 234 | #endif |
michael@0 | 235 | |
michael@0 | 236 | for (int y = 0; y < height - 1; y += 2) { |
michael@0 | 237 | I422ToYUY2Row(src_y, src_u, src_v, dst_yuy2, width); |
michael@0 | 238 | I422ToYUY2Row(src_y + src_stride_y, src_u, src_v, |
michael@0 | 239 | dst_yuy2 + dst_stride_yuy2, width); |
michael@0 | 240 | src_y += src_stride_y * 2; |
michael@0 | 241 | src_u += src_stride_u; |
michael@0 | 242 | src_v += src_stride_v; |
michael@0 | 243 | dst_yuy2 += dst_stride_yuy2 * 2; |
michael@0 | 244 | } |
michael@0 | 245 | if (height & 1) { |
michael@0 | 246 | I422ToYUY2Row(src_y, src_u, src_v, dst_yuy2, width); |
michael@0 | 247 | } |
michael@0 | 248 | return 0; |
michael@0 | 249 | } |
michael@0 | 250 | |
michael@0 | 251 | LIBYUV_API |
michael@0 | 252 | int I422ToUYVY(const uint8* src_y, int src_stride_y, |
michael@0 | 253 | const uint8* src_u, int src_stride_u, |
michael@0 | 254 | const uint8* src_v, int src_stride_v, |
michael@0 | 255 | uint8* dst_uyvy, int dst_stride_uyvy, |
michael@0 | 256 | int width, int height) { |
michael@0 | 257 | if (!src_y || !src_u || !src_v || !dst_uyvy || |
michael@0 | 258 | width <= 0 || height == 0) { |
michael@0 | 259 | return -1; |
michael@0 | 260 | } |
michael@0 | 261 | // Negative height means invert the image. |
michael@0 | 262 | if (height < 0) { |
michael@0 | 263 | height = -height; |
michael@0 | 264 | dst_uyvy = dst_uyvy + (height - 1) * dst_stride_uyvy; |
michael@0 | 265 | dst_stride_uyvy = -dst_stride_uyvy; |
michael@0 | 266 | } |
michael@0 | 267 | // Coalesce rows. |
michael@0 | 268 | if (src_stride_y == width && |
michael@0 | 269 | src_stride_u * 2 == width && |
michael@0 | 270 | src_stride_v * 2 == width && |
michael@0 | 271 | dst_stride_uyvy == width * 2) { |
michael@0 | 272 | width *= height; |
michael@0 | 273 | height = 1; |
michael@0 | 274 | src_stride_y = src_stride_u = src_stride_v = dst_stride_uyvy = 0; |
michael@0 | 275 | } |
michael@0 | 276 | void (*I422ToUYVYRow)(const uint8* src_y, const uint8* src_u, |
michael@0 | 277 | const uint8* src_v, uint8* dst_uyvy, int width) = |
michael@0 | 278 | I422ToUYVYRow_C; |
michael@0 | 279 | #if defined(HAS_I422TOUYVYROW_SSE2) |
michael@0 | 280 | if (TestCpuFlag(kCpuHasSSE2) && width >= 16) { |
michael@0 | 281 | I422ToUYVYRow = I422ToUYVYRow_Any_SSE2; |
michael@0 | 282 | if (IS_ALIGNED(width, 16)) { |
michael@0 | 283 | I422ToUYVYRow = I422ToUYVYRow_SSE2; |
michael@0 | 284 | } |
michael@0 | 285 | } |
michael@0 | 286 | #elif defined(HAS_I422TOUYVYROW_NEON) |
michael@0 | 287 | if (TestCpuFlag(kCpuHasNEON) && width >= 16) { |
michael@0 | 288 | I422ToUYVYRow = I422ToUYVYRow_Any_NEON; |
michael@0 | 289 | if (IS_ALIGNED(width, 16)) { |
michael@0 | 290 | I422ToUYVYRow = I422ToUYVYRow_NEON; |
michael@0 | 291 | } |
michael@0 | 292 | } |
michael@0 | 293 | #endif |
michael@0 | 294 | |
michael@0 | 295 | for (int y = 0; y < height; ++y) { |
michael@0 | 296 | I422ToUYVYRow(src_y, src_u, src_v, dst_uyvy, width); |
michael@0 | 297 | src_y += src_stride_y; |
michael@0 | 298 | src_u += src_stride_u; |
michael@0 | 299 | src_v += src_stride_v; |
michael@0 | 300 | dst_uyvy += dst_stride_uyvy; |
michael@0 | 301 | } |
michael@0 | 302 | return 0; |
michael@0 | 303 | } |
michael@0 | 304 | |
michael@0 | 305 | LIBYUV_API |
michael@0 | 306 | int I420ToUYVY(const uint8* src_y, int src_stride_y, |
michael@0 | 307 | const uint8* src_u, int src_stride_u, |
michael@0 | 308 | const uint8* src_v, int src_stride_v, |
michael@0 | 309 | uint8* dst_uyvy, int dst_stride_uyvy, |
michael@0 | 310 | int width, int height) { |
michael@0 | 311 | if (!src_y || !src_u || !src_v || !dst_uyvy || |
michael@0 | 312 | width <= 0 || height == 0) { |
michael@0 | 313 | return -1; |
michael@0 | 314 | } |
michael@0 | 315 | // Negative height means invert the image. |
michael@0 | 316 | if (height < 0) { |
michael@0 | 317 | height = -height; |
michael@0 | 318 | dst_uyvy = dst_uyvy + (height - 1) * dst_stride_uyvy; |
michael@0 | 319 | dst_stride_uyvy = -dst_stride_uyvy; |
michael@0 | 320 | } |
michael@0 | 321 | void (*I422ToUYVYRow)(const uint8* src_y, const uint8* src_u, |
michael@0 | 322 | const uint8* src_v, uint8* dst_uyvy, int width) = |
michael@0 | 323 | I422ToUYVYRow_C; |
michael@0 | 324 | #if defined(HAS_I422TOUYVYROW_SSE2) |
michael@0 | 325 | if (TestCpuFlag(kCpuHasSSE2) && width >= 16) { |
michael@0 | 326 | I422ToUYVYRow = I422ToUYVYRow_Any_SSE2; |
michael@0 | 327 | if (IS_ALIGNED(width, 16)) { |
michael@0 | 328 | I422ToUYVYRow = I422ToUYVYRow_SSE2; |
michael@0 | 329 | } |
michael@0 | 330 | } |
michael@0 | 331 | #elif defined(HAS_I422TOUYVYROW_NEON) |
michael@0 | 332 | if (TestCpuFlag(kCpuHasNEON) && width >= 16) { |
michael@0 | 333 | I422ToUYVYRow = I422ToUYVYRow_Any_NEON; |
michael@0 | 334 | if (IS_ALIGNED(width, 16)) { |
michael@0 | 335 | I422ToUYVYRow = I422ToUYVYRow_NEON; |
michael@0 | 336 | } |
michael@0 | 337 | } |
michael@0 | 338 | #endif |
michael@0 | 339 | |
michael@0 | 340 | for (int y = 0; y < height - 1; y += 2) { |
michael@0 | 341 | I422ToUYVYRow(src_y, src_u, src_v, dst_uyvy, width); |
michael@0 | 342 | I422ToUYVYRow(src_y + src_stride_y, src_u, src_v, |
michael@0 | 343 | dst_uyvy + dst_stride_uyvy, width); |
michael@0 | 344 | src_y += src_stride_y * 2; |
michael@0 | 345 | src_u += src_stride_u; |
michael@0 | 346 | src_v += src_stride_v; |
michael@0 | 347 | dst_uyvy += dst_stride_uyvy * 2; |
michael@0 | 348 | } |
michael@0 | 349 | if (height & 1) { |
michael@0 | 350 | I422ToUYVYRow(src_y, src_u, src_v, dst_uyvy, width); |
michael@0 | 351 | } |
michael@0 | 352 | return 0; |
michael@0 | 353 | } |
michael@0 | 354 | |
michael@0 | 355 | LIBYUV_API |
michael@0 | 356 | int I420ToNV12(const uint8* src_y, int src_stride_y, |
michael@0 | 357 | const uint8* src_u, int src_stride_u, |
michael@0 | 358 | const uint8* src_v, int src_stride_v, |
michael@0 | 359 | uint8* dst_y, int dst_stride_y, |
michael@0 | 360 | uint8* dst_uv, int dst_stride_uv, |
michael@0 | 361 | int width, int height) { |
michael@0 | 362 | if (!src_y || !src_u || !src_v || !dst_y || !dst_uv || |
michael@0 | 363 | width <= 0 || height == 0) { |
michael@0 | 364 | return -1; |
michael@0 | 365 | } |
michael@0 | 366 | // Negative height means invert the image. |
michael@0 | 367 | if (height < 0) { |
michael@0 | 368 | height = -height; |
michael@0 | 369 | int halfheight = (height + 1) >> 1; |
michael@0 | 370 | dst_y = dst_y + (height - 1) * dst_stride_y; |
michael@0 | 371 | dst_uv = dst_uv + (halfheight - 1) * dst_stride_uv; |
michael@0 | 372 | dst_stride_y = -dst_stride_y; |
michael@0 | 373 | dst_stride_uv = -dst_stride_uv; |
michael@0 | 374 | } |
michael@0 | 375 | // Coalesce rows. |
michael@0 | 376 | int halfwidth = (width + 1) >> 1; |
michael@0 | 377 | int halfheight = (height + 1) >> 1; |
michael@0 | 378 | if (src_stride_y == width && |
michael@0 | 379 | dst_stride_y == width) { |
michael@0 | 380 | width *= height; |
michael@0 | 381 | height = 1; |
michael@0 | 382 | src_stride_y = dst_stride_y = 0; |
michael@0 | 383 | } |
michael@0 | 384 | // Coalesce rows. |
michael@0 | 385 | if (src_stride_u == halfwidth && |
michael@0 | 386 | src_stride_v == halfwidth && |
michael@0 | 387 | dst_stride_uv == halfwidth * 2) { |
michael@0 | 388 | halfwidth *= halfheight; |
michael@0 | 389 | halfheight = 1; |
michael@0 | 390 | src_stride_u = src_stride_v = dst_stride_uv = 0; |
michael@0 | 391 | } |
michael@0 | 392 | void (*MergeUVRow_)(const uint8* src_u, const uint8* src_v, uint8* dst_uv, |
michael@0 | 393 | int width) = MergeUVRow_C; |
michael@0 | 394 | #if defined(HAS_MERGEUVROW_SSE2) |
michael@0 | 395 | if (TestCpuFlag(kCpuHasSSE2) && halfwidth >= 16) { |
michael@0 | 396 | MergeUVRow_ = MergeUVRow_Any_SSE2; |
michael@0 | 397 | if (IS_ALIGNED(halfwidth, 16)) { |
michael@0 | 398 | MergeUVRow_ = MergeUVRow_Unaligned_SSE2; |
michael@0 | 399 | if (IS_ALIGNED(src_u, 16) && IS_ALIGNED(src_stride_u, 16) && |
michael@0 | 400 | IS_ALIGNED(src_v, 16) && IS_ALIGNED(src_stride_v, 16) && |
michael@0 | 401 | IS_ALIGNED(dst_uv, 16) && IS_ALIGNED(dst_stride_uv, 16)) { |
michael@0 | 402 | MergeUVRow_ = MergeUVRow_SSE2; |
michael@0 | 403 | } |
michael@0 | 404 | } |
michael@0 | 405 | } |
michael@0 | 406 | #endif |
michael@0 | 407 | #if defined(HAS_MERGEUVROW_AVX2) |
michael@0 | 408 | if (TestCpuFlag(kCpuHasAVX2) && halfwidth >= 32) { |
michael@0 | 409 | MergeUVRow_ = MergeUVRow_Any_AVX2; |
michael@0 | 410 | if (IS_ALIGNED(halfwidth, 32)) { |
michael@0 | 411 | MergeUVRow_ = MergeUVRow_AVX2; |
michael@0 | 412 | } |
michael@0 | 413 | } |
michael@0 | 414 | #endif |
michael@0 | 415 | #if defined(HAS_MERGEUVROW_NEON) |
michael@0 | 416 | if (TestCpuFlag(kCpuHasNEON) && halfwidth >= 16) { |
michael@0 | 417 | MergeUVRow_ = MergeUVRow_Any_NEON; |
michael@0 | 418 | if (IS_ALIGNED(halfwidth, 16)) { |
michael@0 | 419 | MergeUVRow_ = MergeUVRow_NEON; |
michael@0 | 420 | } |
michael@0 | 421 | } |
michael@0 | 422 | #endif |
michael@0 | 423 | |
michael@0 | 424 | CopyPlane(src_y, src_stride_y, dst_y, dst_stride_y, width, height); |
michael@0 | 425 | for (int y = 0; y < halfheight; ++y) { |
michael@0 | 426 | // Merge a row of U and V into a row of UV. |
michael@0 | 427 | MergeUVRow_(src_u, src_v, dst_uv, halfwidth); |
michael@0 | 428 | src_u += src_stride_u; |
michael@0 | 429 | src_v += src_stride_v; |
michael@0 | 430 | dst_uv += dst_stride_uv; |
michael@0 | 431 | } |
michael@0 | 432 | return 0; |
michael@0 | 433 | } |
michael@0 | 434 | |
michael@0 | 435 | LIBYUV_API |
michael@0 | 436 | int I420ToNV21(const uint8* src_y, int src_stride_y, |
michael@0 | 437 | const uint8* src_u, int src_stride_u, |
michael@0 | 438 | const uint8* src_v, int src_stride_v, |
michael@0 | 439 | uint8* dst_y, int dst_stride_y, |
michael@0 | 440 | uint8* dst_vu, int dst_stride_vu, |
michael@0 | 441 | int width, int height) { |
michael@0 | 442 | return I420ToNV12(src_y, src_stride_y, |
michael@0 | 443 | src_v, src_stride_v, |
michael@0 | 444 | src_u, src_stride_u, |
michael@0 | 445 | dst_y, src_stride_y, |
michael@0 | 446 | dst_vu, dst_stride_vu, |
michael@0 | 447 | width, height); |
michael@0 | 448 | } |
michael@0 | 449 | |
michael@0 | 450 | // Convert I420 to ARGB. |
michael@0 | 451 | LIBYUV_API |
michael@0 | 452 | int I420ToARGB(const uint8* src_y, int src_stride_y, |
michael@0 | 453 | const uint8* src_u, int src_stride_u, |
michael@0 | 454 | const uint8* src_v, int src_stride_v, |
michael@0 | 455 | uint8* dst_argb, int dst_stride_argb, |
michael@0 | 456 | int width, int height) { |
michael@0 | 457 | if (!src_y || !src_u || !src_v || !dst_argb || |
michael@0 | 458 | width <= 0 || height == 0) { |
michael@0 | 459 | return -1; |
michael@0 | 460 | } |
michael@0 | 461 | // Negative height means invert the image. |
michael@0 | 462 | if (height < 0) { |
michael@0 | 463 | height = -height; |
michael@0 | 464 | dst_argb = dst_argb + (height - 1) * dst_stride_argb; |
michael@0 | 465 | dst_stride_argb = -dst_stride_argb; |
michael@0 | 466 | } |
michael@0 | 467 | void (*I422ToARGBRow)(const uint8* y_buf, |
michael@0 | 468 | const uint8* u_buf, |
michael@0 | 469 | const uint8* v_buf, |
michael@0 | 470 | uint8* rgb_buf, |
michael@0 | 471 | int width) = I422ToARGBRow_C; |
michael@0 | 472 | #if defined(HAS_I422TOARGBROW_SSSE3) |
michael@0 | 473 | if (TestCpuFlag(kCpuHasSSSE3) && width >= 8) { |
michael@0 | 474 | I422ToARGBRow = I422ToARGBRow_Any_SSSE3; |
michael@0 | 475 | if (IS_ALIGNED(width, 8)) { |
michael@0 | 476 | I422ToARGBRow = I422ToARGBRow_Unaligned_SSSE3; |
michael@0 | 477 | if (IS_ALIGNED(dst_argb, 16) && IS_ALIGNED(dst_stride_argb, 16)) { |
michael@0 | 478 | I422ToARGBRow = I422ToARGBRow_SSSE3; |
michael@0 | 479 | } |
michael@0 | 480 | } |
michael@0 | 481 | } |
michael@0 | 482 | #endif |
michael@0 | 483 | #if defined(HAS_I422TOARGBROW_AVX2) |
michael@0 | 484 | if (TestCpuFlag(kCpuHasAVX2) && width >= 16) { |
michael@0 | 485 | I422ToARGBRow = I422ToARGBRow_Any_AVX2; |
michael@0 | 486 | if (IS_ALIGNED(width, 16)) { |
michael@0 | 487 | I422ToARGBRow = I422ToARGBRow_AVX2; |
michael@0 | 488 | } |
michael@0 | 489 | } |
michael@0 | 490 | #endif |
michael@0 | 491 | #if defined(HAS_I422TOARGBROW_NEON) |
michael@0 | 492 | if (TestCpuFlag(kCpuHasNEON) && width >= 8) { |
michael@0 | 493 | I422ToARGBRow = I422ToARGBRow_Any_NEON; |
michael@0 | 494 | if (IS_ALIGNED(width, 8)) { |
michael@0 | 495 | I422ToARGBRow = I422ToARGBRow_NEON; |
michael@0 | 496 | } |
michael@0 | 497 | } |
michael@0 | 498 | #endif |
michael@0 | 499 | #if defined(HAS_I422TOARGBROW_MIPS_DSPR2) |
michael@0 | 500 | if (TestCpuFlag(kCpuHasMIPS_DSPR2) && IS_ALIGNED(width, 4) && |
michael@0 | 501 | IS_ALIGNED(src_y, 4) && IS_ALIGNED(src_stride_y, 4) && |
michael@0 | 502 | IS_ALIGNED(src_u, 2) && IS_ALIGNED(src_stride_u, 2) && |
michael@0 | 503 | IS_ALIGNED(src_v, 2) && IS_ALIGNED(src_stride_v, 2) && |
michael@0 | 504 | IS_ALIGNED(dst_argb, 4) && IS_ALIGNED(dst_stride_argb, 4)) { |
michael@0 | 505 | I422ToARGBRow = I422ToARGBRow_MIPS_DSPR2; |
michael@0 | 506 | } |
michael@0 | 507 | #endif |
michael@0 | 508 | |
michael@0 | 509 | for (int y = 0; y < height; ++y) { |
michael@0 | 510 | I422ToARGBRow(src_y, src_u, src_v, dst_argb, width); |
michael@0 | 511 | dst_argb += dst_stride_argb; |
michael@0 | 512 | src_y += src_stride_y; |
michael@0 | 513 | if (y & 1) { |
michael@0 | 514 | src_u += src_stride_u; |
michael@0 | 515 | src_v += src_stride_v; |
michael@0 | 516 | } |
michael@0 | 517 | } |
michael@0 | 518 | return 0; |
michael@0 | 519 | } |
michael@0 | 520 | |
michael@0 | 521 | // Convert I420 to BGRA. |
michael@0 | 522 | LIBYUV_API |
michael@0 | 523 | int I420ToBGRA(const uint8* src_y, int src_stride_y, |
michael@0 | 524 | const uint8* src_u, int src_stride_u, |
michael@0 | 525 | const uint8* src_v, int src_stride_v, |
michael@0 | 526 | uint8* dst_bgra, int dst_stride_bgra, |
michael@0 | 527 | int width, int height) { |
michael@0 | 528 | if (!src_y || !src_u || !src_v || !dst_bgra || |
michael@0 | 529 | width <= 0 || height == 0) { |
michael@0 | 530 | return -1; |
michael@0 | 531 | } |
michael@0 | 532 | // Negative height means invert the image. |
michael@0 | 533 | if (height < 0) { |
michael@0 | 534 | height = -height; |
michael@0 | 535 | dst_bgra = dst_bgra + (height - 1) * dst_stride_bgra; |
michael@0 | 536 | dst_stride_bgra = -dst_stride_bgra; |
michael@0 | 537 | } |
michael@0 | 538 | void (*I422ToBGRARow)(const uint8* y_buf, |
michael@0 | 539 | const uint8* u_buf, |
michael@0 | 540 | const uint8* v_buf, |
michael@0 | 541 | uint8* rgb_buf, |
michael@0 | 542 | int width) = I422ToBGRARow_C; |
michael@0 | 543 | #if defined(HAS_I422TOBGRAROW_SSSE3) |
michael@0 | 544 | if (TestCpuFlag(kCpuHasSSSE3) && width >= 8) { |
michael@0 | 545 | I422ToBGRARow = I422ToBGRARow_Any_SSSE3; |
michael@0 | 546 | if (IS_ALIGNED(width, 8)) { |
michael@0 | 547 | I422ToBGRARow = I422ToBGRARow_Unaligned_SSSE3; |
michael@0 | 548 | if (IS_ALIGNED(dst_bgra, 16) && IS_ALIGNED(dst_stride_bgra, 16)) { |
michael@0 | 549 | I422ToBGRARow = I422ToBGRARow_SSSE3; |
michael@0 | 550 | } |
michael@0 | 551 | } |
michael@0 | 552 | } |
michael@0 | 553 | #elif defined(HAS_I422TOBGRAROW_NEON) |
michael@0 | 554 | if (TestCpuFlag(kCpuHasNEON) && width >= 8) { |
michael@0 | 555 | I422ToBGRARow = I422ToBGRARow_Any_NEON; |
michael@0 | 556 | if (IS_ALIGNED(width, 8)) { |
michael@0 | 557 | I422ToBGRARow = I422ToBGRARow_NEON; |
michael@0 | 558 | } |
michael@0 | 559 | } |
michael@0 | 560 | #elif defined(HAS_I422TOBGRAROW_MIPS_DSPR2) |
michael@0 | 561 | if (TestCpuFlag(kCpuHasMIPS_DSPR2) && IS_ALIGNED(width, 4) && |
michael@0 | 562 | IS_ALIGNED(src_y, 4) && IS_ALIGNED(src_stride_y, 4) && |
michael@0 | 563 | IS_ALIGNED(src_u, 2) && IS_ALIGNED(src_stride_u, 2) && |
michael@0 | 564 | IS_ALIGNED(src_v, 2) && IS_ALIGNED(src_stride_v, 2) && |
michael@0 | 565 | IS_ALIGNED(dst_bgra, 4) && IS_ALIGNED(dst_stride_bgra, 4)) { |
michael@0 | 566 | I422ToBGRARow = I422ToBGRARow_MIPS_DSPR2; |
michael@0 | 567 | } |
michael@0 | 568 | #endif |
michael@0 | 569 | |
michael@0 | 570 | for (int y = 0; y < height; ++y) { |
michael@0 | 571 | I422ToBGRARow(src_y, src_u, src_v, dst_bgra, width); |
michael@0 | 572 | dst_bgra += dst_stride_bgra; |
michael@0 | 573 | src_y += src_stride_y; |
michael@0 | 574 | if (y & 1) { |
michael@0 | 575 | src_u += src_stride_u; |
michael@0 | 576 | src_v += src_stride_v; |
michael@0 | 577 | } |
michael@0 | 578 | } |
michael@0 | 579 | return 0; |
michael@0 | 580 | } |
michael@0 | 581 | |
michael@0 | 582 | // Convert I420 to ABGR. |
michael@0 | 583 | LIBYUV_API |
michael@0 | 584 | int I420ToABGR(const uint8* src_y, int src_stride_y, |
michael@0 | 585 | const uint8* src_u, int src_stride_u, |
michael@0 | 586 | const uint8* src_v, int src_stride_v, |
michael@0 | 587 | uint8* dst_abgr, int dst_stride_abgr, |
michael@0 | 588 | int width, int height) { |
michael@0 | 589 | if (!src_y || !src_u || !src_v || !dst_abgr || |
michael@0 | 590 | width <= 0 || height == 0) { |
michael@0 | 591 | return -1; |
michael@0 | 592 | } |
michael@0 | 593 | // Negative height means invert the image. |
michael@0 | 594 | if (height < 0) { |
michael@0 | 595 | height = -height; |
michael@0 | 596 | dst_abgr = dst_abgr + (height - 1) * dst_stride_abgr; |
michael@0 | 597 | dst_stride_abgr = -dst_stride_abgr; |
michael@0 | 598 | } |
michael@0 | 599 | void (*I422ToABGRRow)(const uint8* y_buf, |
michael@0 | 600 | const uint8* u_buf, |
michael@0 | 601 | const uint8* v_buf, |
michael@0 | 602 | uint8* rgb_buf, |
michael@0 | 603 | int width) = I422ToABGRRow_C; |
michael@0 | 604 | #if defined(HAS_I422TOABGRROW_SSSE3) |
michael@0 | 605 | if (TestCpuFlag(kCpuHasSSSE3) && width >= 8) { |
michael@0 | 606 | I422ToABGRRow = I422ToABGRRow_Any_SSSE3; |
michael@0 | 607 | if (IS_ALIGNED(width, 8)) { |
michael@0 | 608 | I422ToABGRRow = I422ToABGRRow_Unaligned_SSSE3; |
michael@0 | 609 | if (IS_ALIGNED(dst_abgr, 16) && IS_ALIGNED(dst_stride_abgr, 16)) { |
michael@0 | 610 | I422ToABGRRow = I422ToABGRRow_SSSE3; |
michael@0 | 611 | } |
michael@0 | 612 | } |
michael@0 | 613 | } |
michael@0 | 614 | #elif defined(HAS_I422TOABGRROW_NEON) |
michael@0 | 615 | if (TestCpuFlag(kCpuHasNEON) && width >= 8) { |
michael@0 | 616 | I422ToABGRRow = I422ToABGRRow_Any_NEON; |
michael@0 | 617 | if (IS_ALIGNED(width, 8)) { |
michael@0 | 618 | I422ToABGRRow = I422ToABGRRow_NEON; |
michael@0 | 619 | } |
michael@0 | 620 | } |
michael@0 | 621 | #endif |
michael@0 | 622 | |
michael@0 | 623 | for (int y = 0; y < height; ++y) { |
michael@0 | 624 | I422ToABGRRow(src_y, src_u, src_v, dst_abgr, width); |
michael@0 | 625 | dst_abgr += dst_stride_abgr; |
michael@0 | 626 | src_y += src_stride_y; |
michael@0 | 627 | if (y & 1) { |
michael@0 | 628 | src_u += src_stride_u; |
michael@0 | 629 | src_v += src_stride_v; |
michael@0 | 630 | } |
michael@0 | 631 | } |
michael@0 | 632 | return 0; |
michael@0 | 633 | } |
michael@0 | 634 | |
michael@0 | 635 | // Convert I420 to RGBA. |
michael@0 | 636 | LIBYUV_API |
michael@0 | 637 | int I420ToRGBA(const uint8* src_y, int src_stride_y, |
michael@0 | 638 | const uint8* src_u, int src_stride_u, |
michael@0 | 639 | const uint8* src_v, int src_stride_v, |
michael@0 | 640 | uint8* dst_rgba, int dst_stride_rgba, |
michael@0 | 641 | int width, int height) { |
michael@0 | 642 | if (!src_y || !src_u || !src_v || !dst_rgba || |
michael@0 | 643 | width <= 0 || height == 0) { |
michael@0 | 644 | return -1; |
michael@0 | 645 | } |
michael@0 | 646 | // Negative height means invert the image. |
michael@0 | 647 | if (height < 0) { |
michael@0 | 648 | height = -height; |
michael@0 | 649 | dst_rgba = dst_rgba + (height - 1) * dst_stride_rgba; |
michael@0 | 650 | dst_stride_rgba = -dst_stride_rgba; |
michael@0 | 651 | } |
michael@0 | 652 | void (*I422ToRGBARow)(const uint8* y_buf, |
michael@0 | 653 | const uint8* u_buf, |
michael@0 | 654 | const uint8* v_buf, |
michael@0 | 655 | uint8* rgb_buf, |
michael@0 | 656 | int width) = I422ToRGBARow_C; |
michael@0 | 657 | #if defined(HAS_I422TORGBAROW_SSSE3) |
michael@0 | 658 | if (TestCpuFlag(kCpuHasSSSE3) && width >= 8) { |
michael@0 | 659 | I422ToRGBARow = I422ToRGBARow_Any_SSSE3; |
michael@0 | 660 | if (IS_ALIGNED(width, 8)) { |
michael@0 | 661 | I422ToRGBARow = I422ToRGBARow_Unaligned_SSSE3; |
michael@0 | 662 | if (IS_ALIGNED(dst_rgba, 16) && IS_ALIGNED(dst_stride_rgba, 16)) { |
michael@0 | 663 | I422ToRGBARow = I422ToRGBARow_SSSE3; |
michael@0 | 664 | } |
michael@0 | 665 | } |
michael@0 | 666 | } |
michael@0 | 667 | #elif defined(HAS_I422TORGBAROW_NEON) |
michael@0 | 668 | if (TestCpuFlag(kCpuHasNEON) && width >= 8) { |
michael@0 | 669 | I422ToRGBARow = I422ToRGBARow_Any_NEON; |
michael@0 | 670 | if (IS_ALIGNED(width, 8)) { |
michael@0 | 671 | I422ToRGBARow = I422ToRGBARow_NEON; |
michael@0 | 672 | } |
michael@0 | 673 | } |
michael@0 | 674 | #endif |
michael@0 | 675 | |
michael@0 | 676 | for (int y = 0; y < height; ++y) { |
michael@0 | 677 | I422ToRGBARow(src_y, src_u, src_v, dst_rgba, width); |
michael@0 | 678 | dst_rgba += dst_stride_rgba; |
michael@0 | 679 | src_y += src_stride_y; |
michael@0 | 680 | if (y & 1) { |
michael@0 | 681 | src_u += src_stride_u; |
michael@0 | 682 | src_v += src_stride_v; |
michael@0 | 683 | } |
michael@0 | 684 | } |
michael@0 | 685 | return 0; |
michael@0 | 686 | } |
michael@0 | 687 | |
michael@0 | 688 | // Convert I420 to RGB24. |
michael@0 | 689 | LIBYUV_API |
michael@0 | 690 | int I420ToRGB24(const uint8* src_y, int src_stride_y, |
michael@0 | 691 | const uint8* src_u, int src_stride_u, |
michael@0 | 692 | const uint8* src_v, int src_stride_v, |
michael@0 | 693 | uint8* dst_rgb24, int dst_stride_rgb24, |
michael@0 | 694 | int width, int height) { |
michael@0 | 695 | if (!src_y || !src_u || !src_v || !dst_rgb24 || |
michael@0 | 696 | width <= 0 || height == 0) { |
michael@0 | 697 | return -1; |
michael@0 | 698 | } |
michael@0 | 699 | // Negative height means invert the image. |
michael@0 | 700 | if (height < 0) { |
michael@0 | 701 | height = -height; |
michael@0 | 702 | dst_rgb24 = dst_rgb24 + (height - 1) * dst_stride_rgb24; |
michael@0 | 703 | dst_stride_rgb24 = -dst_stride_rgb24; |
michael@0 | 704 | } |
michael@0 | 705 | void (*I422ToRGB24Row)(const uint8* y_buf, |
michael@0 | 706 | const uint8* u_buf, |
michael@0 | 707 | const uint8* v_buf, |
michael@0 | 708 | uint8* rgb_buf, |
michael@0 | 709 | int width) = I422ToRGB24Row_C; |
michael@0 | 710 | #if defined(HAS_I422TORGB24ROW_SSSE3) |
michael@0 | 711 | if (TestCpuFlag(kCpuHasSSSE3) && width >= 8) { |
michael@0 | 712 | I422ToRGB24Row = I422ToRGB24Row_Any_SSSE3; |
michael@0 | 713 | if (IS_ALIGNED(width, 8)) { |
michael@0 | 714 | I422ToRGB24Row = I422ToRGB24Row_SSSE3; |
michael@0 | 715 | } |
michael@0 | 716 | } |
michael@0 | 717 | #elif defined(HAS_I422TORGB24ROW_NEON) |
michael@0 | 718 | if (TestCpuFlag(kCpuHasNEON) && width >= 8) { |
michael@0 | 719 | I422ToRGB24Row = I422ToRGB24Row_Any_NEON; |
michael@0 | 720 | if (IS_ALIGNED(width, 8)) { |
michael@0 | 721 | I422ToRGB24Row = I422ToRGB24Row_NEON; |
michael@0 | 722 | } |
michael@0 | 723 | } |
michael@0 | 724 | #endif |
michael@0 | 725 | |
michael@0 | 726 | for (int y = 0; y < height; ++y) { |
michael@0 | 727 | I422ToRGB24Row(src_y, src_u, src_v, dst_rgb24, width); |
michael@0 | 728 | dst_rgb24 += dst_stride_rgb24; |
michael@0 | 729 | src_y += src_stride_y; |
michael@0 | 730 | if (y & 1) { |
michael@0 | 731 | src_u += src_stride_u; |
michael@0 | 732 | src_v += src_stride_v; |
michael@0 | 733 | } |
michael@0 | 734 | } |
michael@0 | 735 | return 0; |
michael@0 | 736 | } |
michael@0 | 737 | |
michael@0 | 738 | // Convert I420 to RAW. |
michael@0 | 739 | LIBYUV_API |
michael@0 | 740 | int I420ToRAW(const uint8* src_y, int src_stride_y, |
michael@0 | 741 | const uint8* src_u, int src_stride_u, |
michael@0 | 742 | const uint8* src_v, int src_stride_v, |
michael@0 | 743 | uint8* dst_raw, int dst_stride_raw, |
michael@0 | 744 | int width, int height) { |
michael@0 | 745 | if (!src_y || !src_u || !src_v || !dst_raw || |
michael@0 | 746 | width <= 0 || height == 0) { |
michael@0 | 747 | return -1; |
michael@0 | 748 | } |
michael@0 | 749 | // Negative height means invert the image. |
michael@0 | 750 | if (height < 0) { |
michael@0 | 751 | height = -height; |
michael@0 | 752 | dst_raw = dst_raw + (height - 1) * dst_stride_raw; |
michael@0 | 753 | dst_stride_raw = -dst_stride_raw; |
michael@0 | 754 | } |
michael@0 | 755 | void (*I422ToRAWRow)(const uint8* y_buf, |
michael@0 | 756 | const uint8* u_buf, |
michael@0 | 757 | const uint8* v_buf, |
michael@0 | 758 | uint8* rgb_buf, |
michael@0 | 759 | int width) = I422ToRAWRow_C; |
michael@0 | 760 | #if defined(HAS_I422TORAWROW_SSSE3) |
michael@0 | 761 | if (TestCpuFlag(kCpuHasSSSE3) && width >= 8) { |
michael@0 | 762 | I422ToRAWRow = I422ToRAWRow_Any_SSSE3; |
michael@0 | 763 | if (IS_ALIGNED(width, 8)) { |
michael@0 | 764 | I422ToRAWRow = I422ToRAWRow_SSSE3; |
michael@0 | 765 | } |
michael@0 | 766 | } |
michael@0 | 767 | #elif defined(HAS_I422TORAWROW_NEON) |
michael@0 | 768 | if (TestCpuFlag(kCpuHasNEON) && width >= 8) { |
michael@0 | 769 | I422ToRAWRow = I422ToRAWRow_Any_NEON; |
michael@0 | 770 | if (IS_ALIGNED(width, 8)) { |
michael@0 | 771 | I422ToRAWRow = I422ToRAWRow_NEON; |
michael@0 | 772 | } |
michael@0 | 773 | } |
michael@0 | 774 | #endif |
michael@0 | 775 | |
michael@0 | 776 | for (int y = 0; y < height; ++y) { |
michael@0 | 777 | I422ToRAWRow(src_y, src_u, src_v, dst_raw, width); |
michael@0 | 778 | dst_raw += dst_stride_raw; |
michael@0 | 779 | src_y += src_stride_y; |
michael@0 | 780 | if (y & 1) { |
michael@0 | 781 | src_u += src_stride_u; |
michael@0 | 782 | src_v += src_stride_v; |
michael@0 | 783 | } |
michael@0 | 784 | } |
michael@0 | 785 | return 0; |
michael@0 | 786 | } |
michael@0 | 787 | |
michael@0 | 788 | // Convert I420 to ARGB1555. |
michael@0 | 789 | LIBYUV_API |
michael@0 | 790 | int I420ToARGB1555(const uint8* src_y, int src_stride_y, |
michael@0 | 791 | const uint8* src_u, int src_stride_u, |
michael@0 | 792 | const uint8* src_v, int src_stride_v, |
michael@0 | 793 | uint8* dst_argb1555, int dst_stride_argb1555, |
michael@0 | 794 | int width, int height) { |
michael@0 | 795 | if (!src_y || !src_u || !src_v || !dst_argb1555 || |
michael@0 | 796 | width <= 0 || height == 0) { |
michael@0 | 797 | return -1; |
michael@0 | 798 | } |
michael@0 | 799 | // Negative height means invert the image. |
michael@0 | 800 | if (height < 0) { |
michael@0 | 801 | height = -height; |
michael@0 | 802 | dst_argb1555 = dst_argb1555 + (height - 1) * dst_stride_argb1555; |
michael@0 | 803 | dst_stride_argb1555 = -dst_stride_argb1555; |
michael@0 | 804 | } |
michael@0 | 805 | void (*I422ToARGB1555Row)(const uint8* y_buf, |
michael@0 | 806 | const uint8* u_buf, |
michael@0 | 807 | const uint8* v_buf, |
michael@0 | 808 | uint8* rgb_buf, |
michael@0 | 809 | int width) = I422ToARGB1555Row_C; |
michael@0 | 810 | #if defined(HAS_I422TOARGB1555ROW_SSSE3) |
michael@0 | 811 | if (TestCpuFlag(kCpuHasSSSE3) && width >= 8) { |
michael@0 | 812 | I422ToARGB1555Row = I422ToARGB1555Row_Any_SSSE3; |
michael@0 | 813 | if (IS_ALIGNED(width, 8)) { |
michael@0 | 814 | I422ToARGB1555Row = I422ToARGB1555Row_SSSE3; |
michael@0 | 815 | } |
michael@0 | 816 | } |
michael@0 | 817 | #elif defined(HAS_I422TOARGB1555ROW_NEON) |
michael@0 | 818 | if (TestCpuFlag(kCpuHasNEON) && width >= 8) { |
michael@0 | 819 | I422ToARGB1555Row = I422ToARGB1555Row_Any_NEON; |
michael@0 | 820 | if (IS_ALIGNED(width, 8)) { |
michael@0 | 821 | I422ToARGB1555Row = I422ToARGB1555Row_NEON; |
michael@0 | 822 | } |
michael@0 | 823 | } |
michael@0 | 824 | #endif |
michael@0 | 825 | |
michael@0 | 826 | for (int y = 0; y < height; ++y) { |
michael@0 | 827 | I422ToARGB1555Row(src_y, src_u, src_v, dst_argb1555, width); |
michael@0 | 828 | dst_argb1555 += dst_stride_argb1555; |
michael@0 | 829 | src_y += src_stride_y; |
michael@0 | 830 | if (y & 1) { |
michael@0 | 831 | src_u += src_stride_u; |
michael@0 | 832 | src_v += src_stride_v; |
michael@0 | 833 | } |
michael@0 | 834 | } |
michael@0 | 835 | return 0; |
michael@0 | 836 | } |
michael@0 | 837 | |
michael@0 | 838 | |
michael@0 | 839 | // Convert I420 to ARGB4444. |
michael@0 | 840 | LIBYUV_API |
michael@0 | 841 | int I420ToARGB4444(const uint8* src_y, int src_stride_y, |
michael@0 | 842 | const uint8* src_u, int src_stride_u, |
michael@0 | 843 | const uint8* src_v, int src_stride_v, |
michael@0 | 844 | uint8* dst_argb4444, int dst_stride_argb4444, |
michael@0 | 845 | int width, int height) { |
michael@0 | 846 | if (!src_y || !src_u || !src_v || !dst_argb4444 || |
michael@0 | 847 | width <= 0 || height == 0) { |
michael@0 | 848 | return -1; |
michael@0 | 849 | } |
michael@0 | 850 | // Negative height means invert the image. |
michael@0 | 851 | if (height < 0) { |
michael@0 | 852 | height = -height; |
michael@0 | 853 | dst_argb4444 = dst_argb4444 + (height - 1) * dst_stride_argb4444; |
michael@0 | 854 | dst_stride_argb4444 = -dst_stride_argb4444; |
michael@0 | 855 | } |
michael@0 | 856 | void (*I422ToARGB4444Row)(const uint8* y_buf, |
michael@0 | 857 | const uint8* u_buf, |
michael@0 | 858 | const uint8* v_buf, |
michael@0 | 859 | uint8* rgb_buf, |
michael@0 | 860 | int width) = I422ToARGB4444Row_C; |
michael@0 | 861 | #if defined(HAS_I422TOARGB4444ROW_SSSE3) |
michael@0 | 862 | if (TestCpuFlag(kCpuHasSSSE3) && width >= 8) { |
michael@0 | 863 | I422ToARGB4444Row = I422ToARGB4444Row_Any_SSSE3; |
michael@0 | 864 | if (IS_ALIGNED(width, 8)) { |
michael@0 | 865 | I422ToARGB4444Row = I422ToARGB4444Row_SSSE3; |
michael@0 | 866 | } |
michael@0 | 867 | } |
michael@0 | 868 | #elif defined(HAS_I422TOARGB4444ROW_NEON) |
michael@0 | 869 | if (TestCpuFlag(kCpuHasNEON) && width >= 8) { |
michael@0 | 870 | I422ToARGB4444Row = I422ToARGB4444Row_Any_NEON; |
michael@0 | 871 | if (IS_ALIGNED(width, 8)) { |
michael@0 | 872 | I422ToARGB4444Row = I422ToARGB4444Row_NEON; |
michael@0 | 873 | } |
michael@0 | 874 | } |
michael@0 | 875 | #endif |
michael@0 | 876 | |
michael@0 | 877 | for (int y = 0; y < height; ++y) { |
michael@0 | 878 | I422ToARGB4444Row(src_y, src_u, src_v, dst_argb4444, width); |
michael@0 | 879 | dst_argb4444 += dst_stride_argb4444; |
michael@0 | 880 | src_y += src_stride_y; |
michael@0 | 881 | if (y & 1) { |
michael@0 | 882 | src_u += src_stride_u; |
michael@0 | 883 | src_v += src_stride_v; |
michael@0 | 884 | } |
michael@0 | 885 | } |
michael@0 | 886 | return 0; |
michael@0 | 887 | } |
michael@0 | 888 | |
michael@0 | 889 | // Convert I420 to RGB565. |
michael@0 | 890 | LIBYUV_API |
michael@0 | 891 | int I420ToRGB565(const uint8* src_y, int src_stride_y, |
michael@0 | 892 | const uint8* src_u, int src_stride_u, |
michael@0 | 893 | const uint8* src_v, int src_stride_v, |
michael@0 | 894 | uint8* dst_rgb565, int dst_stride_rgb565, |
michael@0 | 895 | int width, int height) { |
michael@0 | 896 | if (!src_y || !src_u || !src_v || !dst_rgb565 || |
michael@0 | 897 | width <= 0 || height == 0) { |
michael@0 | 898 | return -1; |
michael@0 | 899 | } |
michael@0 | 900 | // Negative height means invert the image. |
michael@0 | 901 | if (height < 0) { |
michael@0 | 902 | height = -height; |
michael@0 | 903 | dst_rgb565 = dst_rgb565 + (height - 1) * dst_stride_rgb565; |
michael@0 | 904 | dst_stride_rgb565 = -dst_stride_rgb565; |
michael@0 | 905 | } |
michael@0 | 906 | void (*I422ToRGB565Row)(const uint8* y_buf, |
michael@0 | 907 | const uint8* u_buf, |
michael@0 | 908 | const uint8* v_buf, |
michael@0 | 909 | uint8* rgb_buf, |
michael@0 | 910 | int width) = I422ToRGB565Row_C; |
michael@0 | 911 | #if defined(HAS_I422TORGB565ROW_SSSE3) |
michael@0 | 912 | if (TestCpuFlag(kCpuHasSSSE3) && width >= 8) { |
michael@0 | 913 | I422ToRGB565Row = I422ToRGB565Row_Any_SSSE3; |
michael@0 | 914 | if (IS_ALIGNED(width, 8)) { |
michael@0 | 915 | I422ToRGB565Row = I422ToRGB565Row_SSSE3; |
michael@0 | 916 | } |
michael@0 | 917 | } |
michael@0 | 918 | #elif defined(HAS_I422TORGB565ROW_NEON) |
michael@0 | 919 | if (TestCpuFlag(kCpuHasNEON) && width >= 8) { |
michael@0 | 920 | I422ToRGB565Row = I422ToRGB565Row_Any_NEON; |
michael@0 | 921 | if (IS_ALIGNED(width, 8)) { |
michael@0 | 922 | I422ToRGB565Row = I422ToRGB565Row_NEON; |
michael@0 | 923 | } |
michael@0 | 924 | } |
michael@0 | 925 | #endif |
michael@0 | 926 | |
michael@0 | 927 | for (int y = 0; y < height; ++y) { |
michael@0 | 928 | I422ToRGB565Row(src_y, src_u, src_v, dst_rgb565, width); |
michael@0 | 929 | dst_rgb565 += dst_stride_rgb565; |
michael@0 | 930 | src_y += src_stride_y; |
michael@0 | 931 | if (y & 1) { |
michael@0 | 932 | src_u += src_stride_u; |
michael@0 | 933 | src_v += src_stride_v; |
michael@0 | 934 | } |
michael@0 | 935 | } |
michael@0 | 936 | return 0; |
michael@0 | 937 | } |
michael@0 | 938 | |
michael@0 | 939 | // Convert I420 to specified format |
michael@0 | 940 | LIBYUV_API |
michael@0 | 941 | int ConvertFromI420(const uint8* y, int y_stride, |
michael@0 | 942 | const uint8* u, int u_stride, |
michael@0 | 943 | const uint8* v, int v_stride, |
michael@0 | 944 | uint8* dst_sample, int dst_sample_stride, |
michael@0 | 945 | int width, int height, |
michael@0 | 946 | uint32 fourcc) { |
michael@0 | 947 | uint32 format = CanonicalFourCC(fourcc); |
michael@0 | 948 | if (!y || !u|| !v || !dst_sample || |
michael@0 | 949 | width <= 0 || height == 0) { |
michael@0 | 950 | return -1; |
michael@0 | 951 | } |
michael@0 | 952 | int r = 0; |
michael@0 | 953 | switch (format) { |
michael@0 | 954 | // Single plane formats |
michael@0 | 955 | case FOURCC_YUY2: |
michael@0 | 956 | r = I420ToYUY2(y, y_stride, |
michael@0 | 957 | u, u_stride, |
michael@0 | 958 | v, v_stride, |
michael@0 | 959 | dst_sample, |
michael@0 | 960 | dst_sample_stride ? dst_sample_stride : width * 2, |
michael@0 | 961 | width, height); |
michael@0 | 962 | break; |
michael@0 | 963 | case FOURCC_UYVY: |
michael@0 | 964 | r = I420ToUYVY(y, y_stride, |
michael@0 | 965 | u, u_stride, |
michael@0 | 966 | v, v_stride, |
michael@0 | 967 | dst_sample, |
michael@0 | 968 | dst_sample_stride ? dst_sample_stride : width * 2, |
michael@0 | 969 | width, height); |
michael@0 | 970 | break; |
michael@0 | 971 | case FOURCC_RGBP: |
michael@0 | 972 | r = I420ToRGB565(y, y_stride, |
michael@0 | 973 | u, u_stride, |
michael@0 | 974 | v, v_stride, |
michael@0 | 975 | dst_sample, |
michael@0 | 976 | dst_sample_stride ? dst_sample_stride : width * 2, |
michael@0 | 977 | width, height); |
michael@0 | 978 | break; |
michael@0 | 979 | case FOURCC_RGBO: |
michael@0 | 980 | r = I420ToARGB1555(y, y_stride, |
michael@0 | 981 | u, u_stride, |
michael@0 | 982 | v, v_stride, |
michael@0 | 983 | dst_sample, |
michael@0 | 984 | dst_sample_stride ? dst_sample_stride : width * 2, |
michael@0 | 985 | width, height); |
michael@0 | 986 | break; |
michael@0 | 987 | case FOURCC_R444: |
michael@0 | 988 | r = I420ToARGB4444(y, y_stride, |
michael@0 | 989 | u, u_stride, |
michael@0 | 990 | v, v_stride, |
michael@0 | 991 | dst_sample, |
michael@0 | 992 | dst_sample_stride ? dst_sample_stride : width * 2, |
michael@0 | 993 | width, height); |
michael@0 | 994 | break; |
michael@0 | 995 | case FOURCC_24BG: |
michael@0 | 996 | r = I420ToRGB24(y, y_stride, |
michael@0 | 997 | u, u_stride, |
michael@0 | 998 | v, v_stride, |
michael@0 | 999 | dst_sample, |
michael@0 | 1000 | dst_sample_stride ? dst_sample_stride : width * 3, |
michael@0 | 1001 | width, height); |
michael@0 | 1002 | break; |
michael@0 | 1003 | case FOURCC_RAW: |
michael@0 | 1004 | r = I420ToRAW(y, y_stride, |
michael@0 | 1005 | u, u_stride, |
michael@0 | 1006 | v, v_stride, |
michael@0 | 1007 | dst_sample, |
michael@0 | 1008 | dst_sample_stride ? dst_sample_stride : width * 3, |
michael@0 | 1009 | width, height); |
michael@0 | 1010 | break; |
michael@0 | 1011 | case FOURCC_ARGB: |
michael@0 | 1012 | r = I420ToARGB(y, y_stride, |
michael@0 | 1013 | u, u_stride, |
michael@0 | 1014 | v, v_stride, |
michael@0 | 1015 | dst_sample, |
michael@0 | 1016 | dst_sample_stride ? dst_sample_stride : width * 4, |
michael@0 | 1017 | width, height); |
michael@0 | 1018 | break; |
michael@0 | 1019 | case FOURCC_BGRA: |
michael@0 | 1020 | r = I420ToBGRA(y, y_stride, |
michael@0 | 1021 | u, u_stride, |
michael@0 | 1022 | v, v_stride, |
michael@0 | 1023 | dst_sample, |
michael@0 | 1024 | dst_sample_stride ? dst_sample_stride : width * 4, |
michael@0 | 1025 | width, height); |
michael@0 | 1026 | break; |
michael@0 | 1027 | case FOURCC_ABGR: |
michael@0 | 1028 | r = I420ToABGR(y, y_stride, |
michael@0 | 1029 | u, u_stride, |
michael@0 | 1030 | v, v_stride, |
michael@0 | 1031 | dst_sample, |
michael@0 | 1032 | dst_sample_stride ? dst_sample_stride : width * 4, |
michael@0 | 1033 | width, height); |
michael@0 | 1034 | break; |
michael@0 | 1035 | case FOURCC_RGBA: |
michael@0 | 1036 | r = I420ToRGBA(y, y_stride, |
michael@0 | 1037 | u, u_stride, |
michael@0 | 1038 | v, v_stride, |
michael@0 | 1039 | dst_sample, |
michael@0 | 1040 | dst_sample_stride ? dst_sample_stride : width * 4, |
michael@0 | 1041 | width, height); |
michael@0 | 1042 | break; |
michael@0 | 1043 | case FOURCC_BGGR: |
michael@0 | 1044 | r = I420ToBayerBGGR(y, y_stride, |
michael@0 | 1045 | u, u_stride, |
michael@0 | 1046 | v, v_stride, |
michael@0 | 1047 | dst_sample, |
michael@0 | 1048 | dst_sample_stride ? dst_sample_stride : width, |
michael@0 | 1049 | width, height); |
michael@0 | 1050 | break; |
michael@0 | 1051 | case FOURCC_GBRG: |
michael@0 | 1052 | r = I420ToBayerGBRG(y, y_stride, |
michael@0 | 1053 | u, u_stride, |
michael@0 | 1054 | v, v_stride, |
michael@0 | 1055 | dst_sample, |
michael@0 | 1056 | dst_sample_stride ? dst_sample_stride : width, |
michael@0 | 1057 | width, height); |
michael@0 | 1058 | break; |
michael@0 | 1059 | case FOURCC_GRBG: |
michael@0 | 1060 | r = I420ToBayerGRBG(y, y_stride, |
michael@0 | 1061 | u, u_stride, |
michael@0 | 1062 | v, v_stride, |
michael@0 | 1063 | dst_sample, |
michael@0 | 1064 | dst_sample_stride ? dst_sample_stride : width, |
michael@0 | 1065 | width, height); |
michael@0 | 1066 | break; |
michael@0 | 1067 | case FOURCC_RGGB: |
michael@0 | 1068 | r = I420ToBayerRGGB(y, y_stride, |
michael@0 | 1069 | u, u_stride, |
michael@0 | 1070 | v, v_stride, |
michael@0 | 1071 | dst_sample, |
michael@0 | 1072 | dst_sample_stride ? dst_sample_stride : width, |
michael@0 | 1073 | width, height); |
michael@0 | 1074 | break; |
michael@0 | 1075 | case FOURCC_I400: |
michael@0 | 1076 | r = I400Copy(y, y_stride, |
michael@0 | 1077 | dst_sample, |
michael@0 | 1078 | dst_sample_stride ? dst_sample_stride : width, |
michael@0 | 1079 | width, height); |
michael@0 | 1080 | break; |
michael@0 | 1081 | case FOURCC_NV12: { |
michael@0 | 1082 | uint8* dst_uv = dst_sample + width * height; |
michael@0 | 1083 | r = I420ToNV12(y, y_stride, |
michael@0 | 1084 | u, u_stride, |
michael@0 | 1085 | v, v_stride, |
michael@0 | 1086 | dst_sample, |
michael@0 | 1087 | dst_sample_stride ? dst_sample_stride : width, |
michael@0 | 1088 | dst_uv, |
michael@0 | 1089 | dst_sample_stride ? dst_sample_stride : width, |
michael@0 | 1090 | width, height); |
michael@0 | 1091 | break; |
michael@0 | 1092 | } |
michael@0 | 1093 | case FOURCC_NV21: { |
michael@0 | 1094 | uint8* dst_vu = dst_sample + width * height; |
michael@0 | 1095 | r = I420ToNV21(y, y_stride, |
michael@0 | 1096 | u, u_stride, |
michael@0 | 1097 | v, v_stride, |
michael@0 | 1098 | dst_sample, |
michael@0 | 1099 | dst_sample_stride ? dst_sample_stride : width, |
michael@0 | 1100 | dst_vu, |
michael@0 | 1101 | dst_sample_stride ? dst_sample_stride : width, |
michael@0 | 1102 | width, height); |
michael@0 | 1103 | break; |
michael@0 | 1104 | } |
michael@0 | 1105 | // TODO(fbarchard): Add M420 and Q420. |
michael@0 | 1106 | // Triplanar formats |
michael@0 | 1107 | // TODO(fbarchard): halfstride instead of halfwidth |
michael@0 | 1108 | case FOURCC_I420: |
michael@0 | 1109 | case FOURCC_YU12: |
michael@0 | 1110 | case FOURCC_YV12: { |
michael@0 | 1111 | int halfwidth = (width + 1) / 2; |
michael@0 | 1112 | int halfheight = (height + 1) / 2; |
michael@0 | 1113 | uint8* dst_u; |
michael@0 | 1114 | uint8* dst_v; |
michael@0 | 1115 | if (format == FOURCC_YV12) { |
michael@0 | 1116 | dst_v = dst_sample + width * height; |
michael@0 | 1117 | dst_u = dst_v + halfwidth * halfheight; |
michael@0 | 1118 | } else { |
michael@0 | 1119 | dst_u = dst_sample + width * height; |
michael@0 | 1120 | dst_v = dst_u + halfwidth * halfheight; |
michael@0 | 1121 | } |
michael@0 | 1122 | r = I420Copy(y, y_stride, |
michael@0 | 1123 | u, u_stride, |
michael@0 | 1124 | v, v_stride, |
michael@0 | 1125 | dst_sample, width, |
michael@0 | 1126 | dst_u, halfwidth, |
michael@0 | 1127 | dst_v, halfwidth, |
michael@0 | 1128 | width, height); |
michael@0 | 1129 | break; |
michael@0 | 1130 | } |
michael@0 | 1131 | case FOURCC_I422: |
michael@0 | 1132 | case FOURCC_YV16: { |
michael@0 | 1133 | int halfwidth = (width + 1) / 2; |
michael@0 | 1134 | uint8* dst_u; |
michael@0 | 1135 | uint8* dst_v; |
michael@0 | 1136 | if (format == FOURCC_YV16) { |
michael@0 | 1137 | dst_v = dst_sample + width * height; |
michael@0 | 1138 | dst_u = dst_v + halfwidth * height; |
michael@0 | 1139 | } else { |
michael@0 | 1140 | dst_u = dst_sample + width * height; |
michael@0 | 1141 | dst_v = dst_u + halfwidth * height; |
michael@0 | 1142 | } |
michael@0 | 1143 | r = I420ToI422(y, y_stride, |
michael@0 | 1144 | u, u_stride, |
michael@0 | 1145 | v, v_stride, |
michael@0 | 1146 | dst_sample, width, |
michael@0 | 1147 | dst_u, halfwidth, |
michael@0 | 1148 | dst_v, halfwidth, |
michael@0 | 1149 | width, height); |
michael@0 | 1150 | break; |
michael@0 | 1151 | } |
michael@0 | 1152 | case FOURCC_I444: |
michael@0 | 1153 | case FOURCC_YV24: { |
michael@0 | 1154 | uint8* dst_u; |
michael@0 | 1155 | uint8* dst_v; |
michael@0 | 1156 | if (format == FOURCC_YV24) { |
michael@0 | 1157 | dst_v = dst_sample + width * height; |
michael@0 | 1158 | dst_u = dst_v + width * height; |
michael@0 | 1159 | } else { |
michael@0 | 1160 | dst_u = dst_sample + width * height; |
michael@0 | 1161 | dst_v = dst_u + width * height; |
michael@0 | 1162 | } |
michael@0 | 1163 | r = I420ToI444(y, y_stride, |
michael@0 | 1164 | u, u_stride, |
michael@0 | 1165 | v, v_stride, |
michael@0 | 1166 | dst_sample, width, |
michael@0 | 1167 | dst_u, width, |
michael@0 | 1168 | dst_v, width, |
michael@0 | 1169 | width, height); |
michael@0 | 1170 | break; |
michael@0 | 1171 | } |
michael@0 | 1172 | case FOURCC_I411: { |
michael@0 | 1173 | int quarterwidth = (width + 3) / 4; |
michael@0 | 1174 | uint8* dst_u = dst_sample + width * height; |
michael@0 | 1175 | uint8* dst_v = dst_u + quarterwidth * height; |
michael@0 | 1176 | r = I420ToI411(y, y_stride, |
michael@0 | 1177 | u, u_stride, |
michael@0 | 1178 | v, v_stride, |
michael@0 | 1179 | dst_sample, width, |
michael@0 | 1180 | dst_u, quarterwidth, |
michael@0 | 1181 | dst_v, quarterwidth, |
michael@0 | 1182 | width, height); |
michael@0 | 1183 | break; |
michael@0 | 1184 | } |
michael@0 | 1185 | |
michael@0 | 1186 | // Formats not supported - MJPG, biplanar, some rgb formats. |
michael@0 | 1187 | default: |
michael@0 | 1188 | return -1; // unknown fourcc - return failure code. |
michael@0 | 1189 | } |
michael@0 | 1190 | return r; |
michael@0 | 1191 | } |
michael@0 | 1192 | |
michael@0 | 1193 | #ifdef __cplusplus |
michael@0 | 1194 | } // extern "C" |
michael@0 | 1195 | } // namespace libyuv |
michael@0 | 1196 | #endif |