format_conversion.cc 18.4 KB
Newer Older
mikhal@webrtc.org's avatar
mikhal@webrtc.org committed
1
/*
2
 *  Copyright 2011 The LibYuv Project Authors. All rights reserved.
mikhal@webrtc.org's avatar
mikhal@webrtc.org committed
3 4 5 6 7 8 9 10
 *
 *  Use of this source code is governed by a BSD-style license
 *  that can be found in the LICENSE file in the root of the source
 *  tree. An additional intellectual property rights grant can be found
 *  in the file PATENTS.  All contributing project authors may
 *  be found in the AUTHORS file in the root of the source tree.
 */

11 12
#include "libyuv/format_conversion.h"

frkoenig@google.com's avatar
frkoenig@google.com committed
13
#include "libyuv/basic_types.h"
14
#include "libyuv/cpu_id.h"
15
#include "libyuv/video_common.h"
16
#include "libyuv/row.h"
mikhal@webrtc.org's avatar
mikhal@webrtc.org committed
17

18
#ifdef __cplusplus
mikhal@webrtc.org's avatar
mikhal@webrtc.org committed
19
namespace libyuv {
20 21
extern "C" {
#endif
mikhal@webrtc.org's avatar
mikhal@webrtc.org committed
22 23 24 25 26 27 28 29 30

// generate a selector mask useful for pshufb
static uint32 GenerateSelector(int select0, int select1) {
  return static_cast<uint32>(select0) |
         static_cast<uint32>((select1 + 4) << 8) |
         static_cast<uint32>((select0 + 8) << 16) |
         static_cast<uint32>((select1 + 12) << 24);
}

31 32 33 34 35
static int MakeSelectors(const int blue_index,
                         const int green_index,
                         const int red_index,
                         uint32 dst_fourcc_bayer,
                         uint32 *index_map) {
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54
  // Now build a lookup table containing the indices for the four pixels in each
  // 2x2 Bayer grid.
  switch (dst_fourcc_bayer) {
    case FOURCC_BGGR:
      index_map[0] = GenerateSelector(blue_index, green_index);
      index_map[1] = GenerateSelector(green_index, red_index);
      break;
    case FOURCC_GBRG:
      index_map[0] = GenerateSelector(green_index, blue_index);
      index_map[1] = GenerateSelector(red_index, green_index);
      break;
    case FOURCC_RGGB:
      index_map[0] = GenerateSelector(red_index, green_index);
      index_map[1] = GenerateSelector(green_index, blue_index);
      break;
    case FOURCC_GRBG:
      index_map[0] = GenerateSelector(green_index, red_index);
      index_map[1] = GenerateSelector(blue_index, green_index);
      break;
55
    default:
56
      return -1;  // Bad FourCC
57
  }
58
  return 0;
59 60 61
}

// Converts 32 bit ARGB to Bayer RGB formats.
62
LIBYUV_API
63 64 65 66
int ARGBToBayer(const uint8* src_argb, int src_stride_argb,
                uint8* dst_bayer, int dst_stride_bayer,
                int width, int height,
                uint32 dst_fourcc_bayer) {
67 68
  if (height < 0) {
    height = -height;
69 70
    src_argb = src_argb + (height - 1) * src_stride_argb;
    src_stride_argb = -src_stride_argb;
71
  }
72 73
  void (*ARGBToBayerRow)(const uint8* src_argb, uint8* dst_bayer,
                         uint32 selector, int pix) = ARGBToBayerRow_C;
mikhal@webrtc.org's avatar
mikhal@webrtc.org committed
74
#if defined(HAS_ARGBTOBAYERROW_SSSE3)
75
  if (TestCpuFlag(kCpuHasSSSE3) && width >= 4 &&
76
      IS_ALIGNED(src_argb, 16) && IS_ALIGNED(src_stride_argb, 16)) {
77 78 79 80
    ARGBToBayerRow = ARGBToBayerRow_Any_SSSE3;
    if (IS_ALIGNED(width, 4)) {
      ARGBToBayerRow = ARGBToBayerRow_SSSE3;
    }
mikhal@webrtc.org's avatar
mikhal@webrtc.org committed
81
  }
82
#elif defined(HAS_ARGBTOBAYERROW_NEON)
83 84 85 86 87
  if (TestCpuFlag(kCpuHasNEON) && width >= 4) {
    ARGBToBayerRow = ARGBToBayerRow_Any_NEON;
    if (IS_ALIGNED(width, 4)) {
      ARGBToBayerRow = ARGBToBayerRow_NEON;
    }
88
  }
89
#endif
90 91 92
  const int blue_index = 0;  // Offsets for ARGB format
  const int green_index = 1;
  const int red_index = 2;
mikhal@webrtc.org's avatar
mikhal@webrtc.org committed
93
  uint32 index_map[2];
94 95
  if (MakeSelectors(blue_index, green_index, red_index,
                    dst_fourcc_bayer, index_map)) {
96
    return -1;  // Bad FourCC
97
  }
mikhal@webrtc.org's avatar
mikhal@webrtc.org committed
98 99

  for (int y = 0; y < height; ++y) {
100 101
    ARGBToBayerRow(src_argb, dst_bayer, index_map[y & 1], width);
    src_argb += src_stride_argb;
102
    dst_bayer += dst_stride_bayer;
mikhal@webrtc.org's avatar
mikhal@webrtc.org committed
103
  }
104
  return 0;
mikhal@webrtc.org's avatar
mikhal@webrtc.org committed
105 106
}

107
#define AVG(a, b) (((a) + (b)) >> 1)
108 109

static void BayerRowBG(const uint8* src_bayer0, int src_stride_bayer,
110
                       uint8* dst_argb, int pix) {
111 112 113
  const uint8* src_bayer1 = src_bayer0 + src_stride_bayer;
  uint8 g = src_bayer0[1];
  uint8 r = src_bayer1[1];
114
  for (int x = 0; x < pix - 2; x += 2) {
115 116 117 118 119 120 121 122
    dst_argb[0] = src_bayer0[0];
    dst_argb[1] = AVG(g, src_bayer0[1]);
    dst_argb[2] = AVG(r, src_bayer1[1]);
    dst_argb[3] = 255U;
    dst_argb[4] = AVG(src_bayer0[0], src_bayer0[2]);
    dst_argb[5] = src_bayer0[1];
    dst_argb[6] = src_bayer1[1];
    dst_argb[7] = 255U;
123 124 125 126
    g = src_bayer0[1];
    r = src_bayer1[1];
    src_bayer0 += 2;
    src_bayer1 += 2;
127
    dst_argb += 8;
128
  }
129 130 131 132
  dst_argb[0] = src_bayer0[0];
  dst_argb[1] = AVG(g, src_bayer0[1]);
  dst_argb[2] = AVG(r, src_bayer1[1]);
  dst_argb[3] = 255U;
133
  if (!(pix & 1)) {
134 135 136 137
    dst_argb[4] = src_bayer0[0];
    dst_argb[5] = src_bayer0[1];
    dst_argb[6] = src_bayer1[1];
    dst_argb[7] = 255U;
138
  }
139 140 141
}

static void BayerRowRG(const uint8* src_bayer0, int src_stride_bayer,
142
                       uint8* dst_argb, int pix) {
143 144 145
  const uint8* src_bayer1 = src_bayer0 + src_stride_bayer;
  uint8 g = src_bayer0[1];
  uint8 b = src_bayer1[1];
146
  for (int x = 0; x < pix - 2; x += 2) {
147 148 149 150 151 152 153 154
    dst_argb[0] = AVG(b, src_bayer1[1]);
    dst_argb[1] = AVG(g, src_bayer0[1]);
    dst_argb[2] = src_bayer0[0];
    dst_argb[3] = 255U;
    dst_argb[4] = src_bayer1[1];
    dst_argb[5] = src_bayer0[1];
    dst_argb[6] = AVG(src_bayer0[0], src_bayer0[2]);
    dst_argb[7] = 255U;
155 156 157 158
    g = src_bayer0[1];
    b = src_bayer1[1];
    src_bayer0 += 2;
    src_bayer1 += 2;
159
    dst_argb += 8;
160
  }
161 162 163 164
  dst_argb[0] = AVG(b, src_bayer1[1]);
  dst_argb[1] = AVG(g, src_bayer0[1]);
  dst_argb[2] = src_bayer0[0];
  dst_argb[3] = 255U;
165
  if (!(pix & 1)) {
166 167 168 169
    dst_argb[4] = src_bayer1[1];
    dst_argb[5] = src_bayer0[1];
    dst_argb[6] = src_bayer0[0];
    dst_argb[7] = 255U;
170
  }
171 172 173
}

static void BayerRowGB(const uint8* src_bayer0, int src_stride_bayer,
174
                       uint8* dst_argb, int pix) {
175 176
  const uint8* src_bayer1 = src_bayer0 + src_stride_bayer;
  uint8 b = src_bayer0[1];
177
  for (int x = 0; x < pix - 2; x += 2) {
178 179 180 181 182 183 184 185
    dst_argb[0] = AVG(b, src_bayer0[1]);
    dst_argb[1] = src_bayer0[0];
    dst_argb[2] = src_bayer1[0];
    dst_argb[3] = 255U;
    dst_argb[4] = src_bayer0[1];
    dst_argb[5] = AVG(src_bayer0[0], src_bayer0[2]);
    dst_argb[6] = AVG(src_bayer1[0], src_bayer1[2]);
    dst_argb[7] = 255U;
186 187 188
    b = src_bayer0[1];
    src_bayer0 += 2;
    src_bayer1 += 2;
189
    dst_argb += 8;
190
  }
191 192 193 194
  dst_argb[0] = AVG(b, src_bayer0[1]);
  dst_argb[1] = src_bayer0[0];
  dst_argb[2] = src_bayer1[0];
  dst_argb[3] = 255U;
195
  if (!(pix & 1)) {
196 197 198 199
    dst_argb[4] = src_bayer0[1];
    dst_argb[5] = src_bayer0[0];
    dst_argb[6] = src_bayer1[0];
    dst_argb[7] = 255U;
200
  }
201 202 203
}

static void BayerRowGR(const uint8* src_bayer0, int src_stride_bayer,
204
                       uint8* dst_argb, int pix) {
205 206
  const uint8* src_bayer1 = src_bayer0 + src_stride_bayer;
  uint8 r = src_bayer0[1];
207
  for (int x = 0; x < pix - 2; x += 2) {
208 209 210 211 212 213 214 215
    dst_argb[0] = src_bayer1[0];
    dst_argb[1] = src_bayer0[0];
    dst_argb[2] = AVG(r, src_bayer0[1]);
    dst_argb[3] = 255U;
    dst_argb[4] = AVG(src_bayer1[0], src_bayer1[2]);
    dst_argb[5] = AVG(src_bayer0[0], src_bayer0[2]);
    dst_argb[6] = src_bayer0[1];
    dst_argb[7] = 255U;
216 217 218
    r = src_bayer0[1];
    src_bayer0 += 2;
    src_bayer1 += 2;
219
    dst_argb += 8;
220
  }
221 222 223 224
  dst_argb[0] = src_bayer1[0];
  dst_argb[1] = src_bayer0[0];
  dst_argb[2] = AVG(r, src_bayer0[1]);
  dst_argb[3] = 255U;
225
  if (!(pix & 1)) {
226 227 228 229
    dst_argb[4] = src_bayer1[0];
    dst_argb[5] = src_bayer0[0];
    dst_argb[6] = src_bayer0[1];
    dst_argb[7] = 255U;
230
  }
231 232 233
}

// Converts any Bayer RGB format to ARGB.
234
LIBYUV_API
235 236 237 238
int BayerToARGB(const uint8* src_bayer, int src_stride_bayer,
                uint8* dst_argb, int dst_stride_argb,
                int width, int height,
                uint32 src_fourcc_bayer) {
239 240
  if (height < 0) {
    height = -height;
241 242
    dst_argb = dst_argb + (height - 1) * dst_stride_argb;
    dst_stride_argb = -dst_stride_argb;
243 244
  }
  void (*BayerRow0)(const uint8* src_bayer, int src_stride_bayer,
245
                    uint8* dst_argb, int pix);
246
  void (*BayerRow1)(const uint8* src_bayer, int src_stride_bayer,
247
                    uint8* dst_argb, int pix);
248 249 250 251 252
  switch (src_fourcc_bayer) {
    case FOURCC_BGGR:
      BayerRow0 = BayerRowBG;
      BayerRow1 = BayerRowGR;
      break;
253 254 255 256
    case FOURCC_GBRG:
      BayerRow0 = BayerRowGB;
      BayerRow1 = BayerRowRG;
      break;
257 258 259 260
    case FOURCC_GRBG:
      BayerRow0 = BayerRowGR;
      BayerRow1 = BayerRowBG;
      break;
261 262 263
    case FOURCC_RGGB:
      BayerRow0 = BayerRowRG;
      BayerRow1 = BayerRowGB;
264
      break;
265 266
    default:
      return -1;    // Bad FourCC
267 268
  }

269
  for (int y = 0; y < height - 1; y += 2) {
270
    BayerRow0(src_bayer, src_stride_bayer, dst_argb, width);
271
    BayerRow1(src_bayer + src_stride_bayer, -src_stride_bayer,
272
              dst_argb + dst_stride_argb, width);
273
    src_bayer += src_stride_bayer * 2;
274
    dst_argb += dst_stride_argb * 2;
275 276
  }
  if (height & 1) {
277
    BayerRow0(src_bayer, src_stride_bayer, dst_argb, width);
278 279 280 281 282
  }
  return 0;
}

// Converts any Bayer RGB format to ARGB.
283
LIBYUV_API
284 285 286 287 288 289
int BayerToI420(const uint8* src_bayer, int src_stride_bayer,
                uint8* dst_y, int dst_stride_y,
                uint8* dst_u, int dst_stride_u,
                uint8* dst_v, int dst_stride_v,
                int width, int height,
                uint32 src_fourcc_bayer) {
290
  if (width * 4 > kMaxStride) {
291
    return -1;  // Size too large for row buffer
292
  }
293 294 295 296 297 298 299 300 301 302 303 304
  // Negative height means invert the image.
  if (height < 0) {
    height = -height;
    int halfheight = (height + 1) >> 1;
    dst_y = dst_y + (height - 1) * dst_stride_y;
    dst_u = dst_u + (halfheight - 1) * dst_stride_u;
    dst_v = dst_v + (halfheight - 1) * dst_stride_v;
    dst_stride_y = -dst_stride_y;
    dst_stride_u = -dst_stride_u;
    dst_stride_v = -dst_stride_v;
  }
  void (*BayerRow0)(const uint8* src_bayer, int src_stride_bayer,
305
                    uint8* dst_argb, int pix);
306
  void (*BayerRow1)(const uint8* src_bayer, int src_stride_bayer,
307
                    uint8* dst_argb, int pix);
308

309
  void (*ARGBToUVRow)(const uint8* src_argb0, int src_stride_argb,
310
                      uint8* dst_u, uint8* dst_v, int width) = ARGBToUVRow_C;
311 312
  void (*ARGBToYRow)(const uint8* src_argb, uint8* dst_y, int pix) =
      ARGBToYRow_C;
313
#if defined(HAS_ARGBTOYROW_SSSE3)
314 315 316
  if (TestCpuFlag(kCpuHasSSSE3) && width >= 16) {
    ARGBToUVRow = ARGBToUVRow_Any_SSSE3;
    ARGBToYRow = ARGBToYRow_Any_SSSE3;
317 318
    if (IS_ALIGNED(width, 16)) {
      ARGBToYRow = ARGBToYRow_Unaligned_SSSE3;
319
      ARGBToUVRow = ARGBToUVRow_SSSE3;
320 321 322 323
      if (IS_ALIGNED(dst_y, 16) && IS_ALIGNED(dst_stride_y, 16)) {
        ARGBToYRow = ARGBToYRow_SSSE3;
      }
    }
324
  }
325
#elif defined(HAS_ARGBTOYROW_NEON)
326 327
  if (TestCpuFlag(kCpuHasNEON) && width >= 8) {
    ARGBToYRow = ARGBToYRow_Any_NEON;
328 329
    if (IS_ALIGNED(width, 8)) {
      ARGBToYRow = ARGBToYRow_NEON;
330 331 332
    }
    if (width >= 16) {
      ARGBToUVRow = ARGBToUVRow_Any_NEON;
fbarchard@google.com's avatar
fbarchard@google.com committed
333 334 335
      if (IS_ALIGNED(width, 16)) {
        ARGBToUVRow = ARGBToUVRow_NEON;
      }
336
    }
337
  }
338
#endif
339 340 341 342 343 344

  switch (src_fourcc_bayer) {
    case FOURCC_BGGR:
      BayerRow0 = BayerRowBG;
      BayerRow1 = BayerRowGR;
      break;
345 346 347 348
    case FOURCC_GBRG:
      BayerRow0 = BayerRowGB;
      BayerRow1 = BayerRowRG;
      break;
349 350 351 352
    case FOURCC_GRBG:
      BayerRow0 = BayerRowGR;
      BayerRow1 = BayerRowBG;
      break;
353 354 355
    case FOURCC_RGGB:
      BayerRow0 = BayerRowRG;
      BayerRow1 = BayerRowGB;
356
      break;
357
    default:
358
      return -1;  // Bad FourCC
359 360
  }

361
  SIMD_ALIGNED(uint8 row[kMaxStride * 2]);
362
  for (int y = 0; y < height - 1; y += 2) {
363 364 365
    BayerRow0(src_bayer, src_stride_bayer, row, width);
    BayerRow1(src_bayer + src_stride_bayer, -src_stride_bayer,
              row + kMaxStride, width);
366
    ARGBToUVRow(row, kMaxStride, dst_u, dst_v, width);
367 368
    ARGBToYRow(row, dst_y, width);
    ARGBToYRow(row + kMaxStride, dst_y + dst_stride_y, width);
369 370 371 372 373 374 375
    src_bayer += src_stride_bayer * 2;
    dst_y += dst_stride_y * 2;
    dst_u += dst_stride_u;
    dst_v += dst_stride_v;
  }
  if (height & 1) {
    BayerRow0(src_bayer, src_stride_bayer, row, width);
376
    ARGBToUVRow(row, 0, dst_u, dst_v, width);
377
    ARGBToYRow(row, dst_y, width);
378 379 380 381
  }
  return 0;
}

382
// Convert I420 to Bayer.
383
LIBYUV_API
384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400
int I420ToBayer(const uint8* src_y, int src_stride_y,
                const uint8* src_u, int src_stride_u,
                const uint8* src_v, int src_stride_v,
                uint8* dst_bayer, int dst_stride_bayer,
                int width, int height,
                uint32 dst_fourcc_bayer) {
  // Negative height means invert the image.
  if (height < 0) {
    height = -height;
    int halfheight = (height + 1) >> 1;
    src_y = src_y + (height - 1) * src_stride_y;
    src_u = src_u + (halfheight - 1) * src_stride_u;
    src_v = src_v + (halfheight - 1) * src_stride_v;
    src_stride_y = -src_stride_y;
    src_stride_u = -src_stride_u;
    src_stride_v = -src_stride_v;
  }
401
  void (*I422ToARGBRow)(const uint8* y_buf,
402 403 404
                        const uint8* u_buf,
                        const uint8* v_buf,
                        uint8* rgb_buf,
405
                        int width) = I422ToARGBRow_C;
406 407 408 409
#if defined(HAS_I422TOARGBROW_SSSE3)
  if (TestCpuFlag(kCpuHasSSSE3) && width >= 8) {
    I422ToARGBRow = I422ToARGBRow_Any_SSSE3;
    if (IS_ALIGNED(width, 8)) {
410
      I422ToARGBRow = I422ToARGBRow_SSSE3;
411 412 413 414 415 416 417 418
    }
  }
#elif defined(HAS_I422TOARGBROW_NEON)
  if (TestCpuFlag(kCpuHasNEON) && width >= 8) {
    I422ToARGBRow = I422ToARGBRow_Any_NEON;
    if (IS_ALIGNED(width, 8)) {
      I422ToARGBRow = I422ToARGBRow_NEON;
    }
419
  }
420 421 422 423 424 425 426
#elif defined(HAS_I422TOARGBROW_MIPS_DSPR2)
  if (TestCpuFlag(kCpuHasMIPS_DSPR2) && IS_ALIGNED(width, 4) &&
      IS_ALIGNED(src_y, 4) && IS_ALIGNED(src_stride_y, 4) &&
      IS_ALIGNED(src_u, 2) && IS_ALIGNED(src_stride_u, 2) &&
      IS_ALIGNED(src_v, 2) && IS_ALIGNED(src_stride_v, 2)) {
    I422ToARGBRow = I422ToARGBRow_MIPS_DSPR2;
  }
427
#endif
428

429
  SIMD_ALIGNED(uint8 row[kMaxStride]);
430 431
  void (*ARGBToBayerRow)(const uint8* src_argb, uint8* dst_bayer,
                         uint32 selector, int pix) = ARGBToBayerRow_C;
432
#if defined(HAS_ARGBTOBAYERROW_SSSE3)
433 434 435 436 437
  if (TestCpuFlag(kCpuHasSSSE3) && width >= 4) {
    ARGBToBayerRow = ARGBToBayerRow_Any_SSSE3;
    if (IS_ALIGNED(width, 4)) {
      ARGBToBayerRow = ARGBToBayerRow_SSSE3;
    }
438
  }
439
#elif defined(HAS_ARGBTOBAYERROW_NEON)
440 441 442 443 444
  if (TestCpuFlag(kCpuHasNEON) && width >= 4) {
    ARGBToBayerRow = ARGBToBayerRow_Any_NEON;
    if (IS_ALIGNED(width, 4)) {
      ARGBToBayerRow = ARGBToBayerRow_NEON;
    }
445
  }
446
#endif
447

448 449 450 451
  const int blue_index = 0;  // Offsets for ARGB format
  const int green_index = 1;
  const int red_index = 2;
  uint32 index_map[2];
452 453 454 455
  if (MakeSelectors(blue_index, green_index, red_index,
                    dst_fourcc_bayer, index_map)) {
    return -1;  // Bad FourCC
  }
456 457

  for (int y = 0; y < height; ++y) {
458
    I422ToARGBRow(src_y, src_u, src_v, row, width);
459 460 461 462 463 464 465 466 467 468 469 470
    ARGBToBayerRow(row, dst_bayer, index_map[y & 1], width);
    dst_bayer += dst_stride_bayer;
    src_y += src_stride_y;
    if (y & 1) {
      src_u += src_stride_u;
      src_v += src_stride_v;
    }
  }
  return 0;
}

#define MAKEBAYERFOURCC(BAYER)                                                 \
471
LIBYUV_API                                                                     \
472 473 474 475 476 477 478 479 480 481 482 483 484
int Bayer##BAYER##ToI420(const uint8* src_bayer, int src_stride_bayer,         \
                         uint8* dst_y, int dst_stride_y,                       \
                         uint8* dst_u, int dst_stride_u,                       \
                         uint8* dst_v, int dst_stride_v,                       \
                         int width, int height) {                              \
  return BayerToI420(src_bayer, src_stride_bayer,                              \
                     dst_y, dst_stride_y,                                      \
                     dst_u, dst_stride_u,                                      \
                     dst_v, dst_stride_v,                                      \
                     width, height,                                            \
                     FOURCC_##BAYER);                                          \
}                                                                              \
                                                                               \
485
LIBYUV_API                                                                     \
486 487 488 489 490 491 492 493 494 495 496 497 498
int I420ToBayer##BAYER(const uint8* src_y, int src_stride_y,                   \
                       const uint8* src_u, int src_stride_u,                   \
                       const uint8* src_v, int src_stride_v,                   \
                       uint8* dst_bayer, int dst_stride_bayer,                 \
                       int width, int height) {                                \
  return I420ToBayer(src_y, src_stride_y,                                      \
                     src_u, src_stride_u,                                      \
                     src_v, src_stride_v,                                      \
                     dst_bayer, dst_stride_bayer,                              \
                     width, height,                                            \
                     FOURCC_##BAYER);                                          \
}                                                                              \
                                                                               \
499
LIBYUV_API                                                                     \
500 501 502 503 504 505 506 507 508
int ARGBToBayer##BAYER(const uint8* src_argb, int src_stride_argb,             \
                       uint8* dst_bayer, int dst_stride_bayer,                 \
                       int width, int height) {                                \
  return ARGBToBayer(src_argb, src_stride_argb,                                \
                     dst_bayer, dst_stride_bayer,                              \
                     width, height,                                            \
                     FOURCC_##BAYER);                                          \
}                                                                              \
                                                                               \
509
LIBYUV_API                                                                     \
510 511 512 513 514 515 516 517 518 519 520 521 522 523
int Bayer##BAYER##ToARGB(const uint8* src_bayer, int src_stride_bayer,         \
                         uint8* dst_argb, int dst_stride_argb,                 \
                         int width, int height) {                              \
  return BayerToARGB(src_bayer, src_stride_bayer,                              \
                     dst_argb, dst_stride_argb,                                \
                     width, height,                                            \
                     FOURCC_##BAYER);                                          \
}

MAKEBAYERFOURCC(BGGR)
MAKEBAYERFOURCC(GBRG)
MAKEBAYERFOURCC(GRBG)
MAKEBAYERFOURCC(RGGB)

524 525
#ifdef __cplusplus
}  // extern "C"
mikhal@webrtc.org's avatar
mikhal@webrtc.org committed
526
}  // namespace libyuv
527
#endif