Home | History | Annotate | Download | only in libcsc
      1 /*
      2  *
      3  * Copyright 2012 Samsung Electronics S.LSI Co. LTD
      4  *
      5  * Licensed under the Apache License, Version 2.0 (the "License");
      6  * you may not use this file except in compliance with the License.
      7  * You may obtain a copy of the License at
      8  *
      9  *      http://www.apache.org/licenses/LICENSE-2.0
     10  *
     11  * Unless required by applicable law or agreed to in writing, software
     12  * distributed under the License is distributed on an "AS IS" BASIS,
     13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     14  * See the License for the specific language governing permissions and
     15  * limitations under the License.
     16  */
     17 
     18 #define LOG_TAG "libcsc_helper"
     19 #include <cutils/log.h>
     20 
     21 #include <system/graphics.h>
     22 
     23 #include "Exynos_OMX_Def.h"
     24 
     25 #include "csc.h"
     26 #include "exynos_format.h"
     27 
     28 OMX_COLOR_FORMATTYPE hal_2_omx_pixel_format(
     29     unsigned int hal_format)
     30 {
     31     OMX_COLOR_FORMATTYPE omx_format;
     32     switch (hal_format) {
     33     case HAL_PIXEL_FORMAT_YCbCr_422_I:
     34         omx_format = OMX_COLOR_FormatYCbYCr;
     35         break;
     36     case HAL_PIXEL_FORMAT_YCbCr_420_P:
     37         omx_format = OMX_COLOR_FormatYUV420Planar;
     38         break;
     39     case HAL_PIXEL_FORMAT_YCbCr_420_SP:
     40         omx_format = OMX_COLOR_FormatYUV420SemiPlanar;
     41         break;
     42     case HAL_PIXEL_FORMAT_CUSTOM_YCbCr_420_SP_TILED:
     43         omx_format = OMX_SEC_COLOR_FormatNV12TPhysicalAddress;
     44         break;
     45     case HAL_PIXEL_FORMAT_YCbCr_420_SP_TILED:
     46         omx_format = OMX_SEC_COLOR_FormatNV12Tiled;
     47         break;
     48     case HAL_PIXEL_FORMAT_ARGB888:
     49         omx_format = OMX_COLOR_Format32bitARGB8888;
     50         break;
     51     default:
     52         omx_format = OMX_COLOR_FormatYUV420Planar;
     53         break;
     54     }
     55     return omx_format;
     56 }
     57 
     58 unsigned int omx_2_hal_pixel_format(
     59     OMX_COLOR_FORMATTYPE omx_format)
     60 {
     61     unsigned int hal_format;
     62     switch (omx_format) {
     63     case OMX_COLOR_FormatYCbYCr:
     64         hal_format = HAL_PIXEL_FORMAT_YCbCr_422_I;
     65         break;
     66     case OMX_COLOR_FormatYUV420Planar:
     67         hal_format = HAL_PIXEL_FORMAT_YCbCr_420_P;
     68         break;
     69     case OMX_COLOR_FormatYUV420SemiPlanar:
     70         hal_format = HAL_PIXEL_FORMAT_YCbCr_420_SP;
     71         break;
     72     case OMX_SEC_COLOR_FormatNV12TPhysicalAddress:
     73         hal_format = HAL_PIXEL_FORMAT_CUSTOM_YCbCr_420_SP_TILED;
     74         break;
     75     case OMX_SEC_COLOR_FormatNV12Tiled:
     76         hal_format = HAL_PIXEL_FORMAT_YCbCr_420_SP_TILED;
     77         break;
     78     case OMX_COLOR_Format32bitARGB8888:
     79         hal_format = HAL_PIXEL_FORMAT_ARGB888;
     80         break;
     81     default:
     82         hal_format = HAL_PIXEL_FORMAT_YCbCr_420_P;
     83         break;
     84     }
     85     return hal_format;
     86 }
     87