exynos5: libcsc: add simple helper library for hal<->omx format conversions

Change-Id: Ie687a485ab3538dc8cb60fdc5bf57a5d7be5c297
Signed-off-by: Dima Zavin <dima@android.com>
diff --git a/libcsc/csc_helper.c b/libcsc/csc_helper.c
new file mode 100644
index 0000000..0dcd33d
--- /dev/null
+++ b/libcsc/csc_helper.c
@@ -0,0 +1,72 @@
+/*
+ *
+ * Copyright 2012 Samsung Electronics S.LSI Co. LTD
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#define LOG_TAG "libcsc_helper"
+#include <cutils/log.h>
+
+#include "Exynos_OMX_Def.h"
+
+#include "csc.h"
+#include "exynos_format.h"
+
+OMX_COLOR_FORMATTYPE hal_2_omx_pixel_format(
+    unsigned int hal_format)
+{
+    OMX_COLOR_FORMATTYPE omx_format;
+    switch (hal_format) {
+    case HAL_PIXEL_FORMAT_YCbCr_420_P:
+        omx_format = OMX_COLOR_FormatYUV420Planar;
+        break;
+    case HAL_PIXEL_FORMAT_YCbCr_420_SP:
+        omx_format = OMX_COLOR_FormatYUV420SemiPlanar;
+        break;
+    case HAL_PIXEL_FORMAT_YCbCr_420_SP_TILED:
+        omx_format = OMX_SEC_COLOR_FormatNV12Tiled;
+        break;
+    case HAL_PIXEL_FORMAT_ARGB888:
+        omx_format = OMX_COLOR_Format32bitARGB8888;
+        break;
+    default:
+        omx_format = OMX_COLOR_FormatYUV420Planar;
+        break;
+    }
+    return omx_format;
+}
+
+unsigned int omx_2_hal_pixel_format(
+    OMX_COLOR_FORMATTYPE omx_format)
+{
+    unsigned int hal_format;
+    switch (omx_format) {
+    case OMX_COLOR_FormatYUV420Planar:
+        hal_format = HAL_PIXEL_FORMAT_YCbCr_420_P;
+        break;
+    case OMX_COLOR_FormatYUV420SemiPlanar:
+        hal_format = HAL_PIXEL_FORMAT_YCbCr_420_SP;
+        break;
+    case OMX_SEC_COLOR_FormatNV12Tiled:
+        hal_format = HAL_PIXEL_FORMAT_YCbCr_420_SP_TILED;
+        break;
+    case OMX_COLOR_Format32bitARGB8888:
+        hal_format = HAL_PIXEL_FORMAT_ARGB888;
+        break;
+    default:
+        hal_format = HAL_PIXEL_FORMAT_YCbCr_420_P;
+        break;
+    }
+    return hal_format;
+}