2
0

video_common.cc 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. /*
  2. * Copyright 2011 The LibYuv Project Authors. All rights reserved.
  3. *
  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
  6. * tree. An additional intellectual property rights grant can be found
  7. * in the file PATENTS. All contributing project authors may
  8. * be found in the AUTHORS file in the root of the source tree.
  9. */
  10. #include "libyuv/video_common.h"
  11. #ifdef __cplusplus
  12. namespace libyuv {
  13. extern "C" {
  14. #endif
  15. struct FourCCAliasEntry {
  16. uint32_t alias;
  17. uint32_t canonical;
  18. };
  19. #define NUM_ALIASES 18
  20. static const struct FourCCAliasEntry kFourCCAliases[NUM_ALIASES] = {
  21. {FOURCC_IYUV, FOURCC_I420},
  22. {FOURCC_YU12, FOURCC_I420},
  23. {FOURCC_YU16, FOURCC_I422},
  24. {FOURCC_YU24, FOURCC_I444},
  25. {FOURCC_YUYV, FOURCC_YUY2},
  26. {FOURCC_YUVS, FOURCC_YUY2}, // kCMPixelFormat_422YpCbCr8_yuvs
  27. {FOURCC_HDYC, FOURCC_UYVY},
  28. {FOURCC_2VUY, FOURCC_UYVY}, // kCMPixelFormat_422YpCbCr8
  29. {FOURCC_JPEG, FOURCC_MJPG}, // Note: JPEG has DHT while MJPG does not.
  30. {FOURCC_DMB1, FOURCC_MJPG},
  31. {FOURCC_BA81, FOURCC_BGGR}, // deprecated.
  32. {FOURCC_RGB3, FOURCC_RAW},
  33. {FOURCC_BGR3, FOURCC_24BG},
  34. {FOURCC_CM32, FOURCC_BGRA}, // kCMPixelFormat_32ARGB
  35. {FOURCC_CM24, FOURCC_RAW}, // kCMPixelFormat_24RGB
  36. {FOURCC_L555, FOURCC_RGBO}, // kCMPixelFormat_16LE555
  37. {FOURCC_L565, FOURCC_RGBP}, // kCMPixelFormat_16LE565
  38. {FOURCC_5551, FOURCC_RGBO}, // kCMPixelFormat_16LE5551
  39. };
  40. // TODO(fbarchard): Consider mapping kCMPixelFormat_32BGRA to FOURCC_ARGB.
  41. // {FOURCC_BGRA, FOURCC_ARGB}, // kCMPixelFormat_32BGRA
  42. LIBYUV_API
  43. uint32_t CanonicalFourCC(uint32_t fourcc) {
  44. int i;
  45. for (i = 0; i < NUM_ALIASES; ++i) {
  46. if (kFourCCAliases[i].alias == fourcc) {
  47. return kFourCCAliases[i].canonical;
  48. }
  49. }
  50. // Not an alias, so return it as-is.
  51. return fourcc;
  52. }
  53. #ifdef __cplusplus
  54. } // extern "C"
  55. } // namespace libyuv
  56. #endif