aboutsummaryrefslogtreecommitdiff
path: root/files/source/video_common.cc
diff options
context:
space:
mode:
authorShri Borde <shri@google.com>2011-11-02 13:20:24 -0700
committerShri Borde <shri@google.com>2011-11-02 13:20:24 -0700
commit7cd8149e2cbad8b1ff6d481c37a4775d3c8cf2fa (patch)
treeb33940212e8eae6d9df454f5461279da919629cf /files/source/video_common.cc
parent2398a6ec900d592b1433dc24eeeecf442794eb10 (diff)
downloadlibyuv-7cd8149e2cbad8b1ff6d481c37a4775d3c8cf2fa.tar.gz
Initial population of libyuv
Change-Id: I46a6a1525aebaba979b0f2ca5b58be2004901410
Diffstat (limited to 'files/source/video_common.cc')
-rw-r--r--files/source/video_common.cc48
1 files changed, 48 insertions, 0 deletions
diff --git a/files/source/video_common.cc b/files/source/video_common.cc
new file mode 100644
index 00000000..8b8ee622
--- /dev/null
+++ b/files/source/video_common.cc
@@ -0,0 +1,48 @@
+/*
+ * Copyright (c) 2011 The LibYuv project authors. All Rights Reserved.
+ *
+ * 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.
+ */
+
+
+#include "video_common.h"
+
+#include <sstream>
+
+namespace libyuv {
+
+#define ARRAY_SIZE(x) (static_cast<int>((sizeof(x)/sizeof(x[0]))))
+
+struct FourCCAliasEntry {
+ uint32 alias;
+ uint32 canonical;
+};
+
+static const FourCCAliasEntry kFourCCAliases[] = {
+ {FOURCC_IYUV, FOURCC_I420},
+ {FOURCC_YU12, FOURCC_I420},
+ {FOURCC_YUYV, FOURCC_YUY2},
+ {FOURCC_YUVS, FOURCC_YUY2},
+ {FOURCC_HDYC, FOURCC_UYVY},
+ {FOURCC_2VUY, FOURCC_UYVY},
+ {FOURCC_BA81, FOURCC_BGGR},
+ {FOURCC_JPEG, FOURCC_MJPG}, // Note: JPEG has DHT while MJPG does not.
+ {FOURCC_RGB3, FOURCC_RAW},
+ {FOURCC_BGR3, FOURCC_24BG},
+};
+
+uint32 CanonicalFourCC(uint32 fourcc) {
+ for (int i = 0; i < ARRAY_SIZE(kFourCCAliases); ++i) {
+ if (kFourCCAliases[i].alias == fourcc) {
+ return kFourCCAliases[i].canonical;
+ }
+ }
+ // Not an alias, so return it as-is.
+ return fourcc;
+}
+
+} // namespace libyuv