Home | History | Annotate | Download | only in inc
      1 /*
      2  * Copyright (C) 2011 The Android Open Source Project
      3  *
      4  * Licensed under the Apache License, Version 2.0 (the "License");
      5  * you may not use this file except in compliance with the License.
      6  * You may obtain a copy of the License at
      7  *
      8  *      http://www.apache.org/licenses/LICENSE-2.0
      9  *
     10  * Unless required by applicable law or agreed to in writing, software
     11  * distributed under the License is distributed on an "AS IS" BASIS,
     12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     13  * See the License for the specific language governing permissions and
     14  * limitations under the License.
     15  */
     16 /**
     17 *************************************************************************
     18  * @file   M4AIR_API.h
     19  * @brief  Area of Interest Resizer  API
     20  * @note
     21 *************************************************************************
     22 */
     23 #ifndef M4AIR_API_H
     24 #define M4AIR_API_H
     25 
     26 /******************************* INCLUDES *******************************/
     27 #include "M4OSA_Types.h"
     28 #include "M4OSA_Error.h"
     29 #include "M4OSA_CoreID.h"
     30 #include "M4OSA_Mutex.h"
     31 #include "M4OSA_Memory.h"
     32 #include "M4VIFI_FiltersAPI.h"
     33 #include "M4Common_types.h"
     34 
     35 /************************ M4AIR TYPES DEFINITIONS ***********************/
     36 
     37 /**
     38  ******************************************************************************
     39  * enum        M4AIR_InputFormatType
     40  * @brief     The following enumeration lists the different accepted format for the AIR.
     41  * To be available, the associated compilation flag must be defined, else,
     42  * the AIR will return an error (compilation flag : M4AIR_XXXXXX_FORMAT_SUPPORTED).
     43  ******************************************************************************
     44 */
     45 typedef enum
     46 {
     47     M4AIR_kYUV420P,
     48     M4AIR_kYUV420AP,
     49     M4AIR_kJPG
     50 }M4AIR_InputFormatType ;
     51 
     52 
     53 /**
     54  ******************************************************************************
     55  * struct         M4AIR_Coordinates
     56  * @brief     The following structure is used to retrieve X and Y coordinates in a given picture.
     57  ******************************************************************************
     58 */
     59 typedef struct
     60 {
     61     M4OSA_UInt32    m_x;    /**< X coordinate */
     62     M4OSA_UInt32    m_y;    /**< Y coordinate */
     63 }M4AIR_Coordinates;
     64 
     65 
     66 /**
     67  ******************************************************************************
     68  * struct         M4AIR_Size
     69  * @brief     The following structure is used to retrieve the dimension of a given picture area.
     70  ******************************************************************************
     71 */
     72 typedef struct
     73 {
     74     M4OSA_UInt32    m_width;    /**< Width */
     75     M4OSA_UInt32    m_height;    /**< Height */
     76 }M4AIR_Size;
     77 
     78 
     79 /**
     80  ******************************************************************************
     81  * struct         M4AIR_Params
     82  * @brief     The following structure is used to retrieve the parameters needed to get a resized ROI (Region of interest).
     83  ******************************************************************************
     84 */
     85 typedef struct
     86 {
     87     M4AIR_Coordinates        m_inputCoord;            /**< X and Y positionning in the input of the first interesting pixel (top-left) */
     88     M4AIR_Size                m_inputSize;            /**< Size of the interesting area inside input (width and height)*/
     89     M4AIR_Size                m_outputSize;            /**< Size of the output */
     90     M4OSA_Bool                m_bOutputStripe;            /**< Flag to know if we will have to provide output per stripe or not */
     91     M4COMMON_Orientation        m_outputOrientation;    /**< Desired orientation of the AIR output */
     92 }M4AIR_Params;
     93 
     94 
     95 
     96 
     97 /*********************** M4AIR ERRORS DEFINITIONS **********************/
     98 
     99 /* This error means that the requested video format is not supported. */
    100 #define M4ERR_AIR_FORMAT_NOT_SUPPORTED    M4OSA_ERR_CREATE(M4_ERR,M4AIR,0x000001)
    101 
    102 /* This error means that the input or output size is incorrect */
    103 #define M4ERR_AIR_ILLEGAL_FRAME_SIZE    M4OSA_ERR_CREATE(M4_ERR,M4AIR,0x000002)
    104 
    105 
    106 
    107 /********************** M4AIR PUBLIC API DEFINITIONS ********************/
    108 /**
    109  ******************************************************************************
    110  * M4OSA_ERR M4AIR_create(M4OSA_Context* pContext,M4AIR_InputFormatType inputFormat);
    111  * @brief        This function initialize an instance of the AIR.
    112  * @param    pContext:    (IN/OUT) Address of the context to create
    113  * @param    inputFormat:    (IN) input format type.
    114  * @return    M4NO_ERROR: there is no error
    115  * @return    M4ERR_PARAMETER: pContext is M4OSA_NULL (debug only). Invalid formatType
    116  * @return    M4ERR_ALLOC: No more memory is available
    117  ******************************************************************************
    118 */
    119 M4OSA_ERR M4AIR_create(M4OSA_Context* pContext,M4AIR_InputFormatType inputFormat);
    120 
    121 
    122 /**
    123  ******************************************************************************
    124  * M4OSA_ERR M4AIR_cleanUp(M4OSA_Context pContext)
    125  * @brief        This function destroys an instance of the AIR component
    126  * @param    pContext:    (IN) Context identifying the instance to destroy
    127  * @return    M4NO_ERROR: there is no error
    128  * @return    M4ERR_PARAMETER: pContext is M4OSA_NULL (debug only).
    129  * @return    M4ERR_STATE: Internal state is incompatible with this function call.
    130  ******************************************************************************
    131 */
    132 M4OSA_ERR M4AIR_cleanUp(M4OSA_Context pContext);
    133 
    134 
    135 /**
    136  ******************************************************************************
    137  * M4OSA_ERR M4AIR_configure(M4OSA_Context pContext, M4AIR_Params* pParams)
    138  * @brief    This function will configure the AIR.
    139  * @note    It will set the input and output coordinates and sizes,
    140  *            and indicates if we will proceed in stripe or not.
    141  *            In case a M4AIR_get in stripe mode was on going, it will cancel this previous
    142  *            processing and reset the get process.
    143  * @param    pContext:                (IN) Context identifying the instance
    144  * @param    pParams->m_bOutputStripe:(IN) Stripe mode.
    145  * @param    pParams->m_inputCoord:    (IN) X,Y coordinates of the first valid pixel in input.
    146  * @param    pParams->m_inputSize:    (IN) input ROI size.
    147  * @param    pParams->m_outputSize:    (IN) output size.
    148  * @return    M4NO_ERROR: there is no error
    149  * @return    M4ERR_ALLOC: No more memory space to add a new effect.
    150  * @return    M4ERR_PARAMETER: pContext is M4OSA_NULL (debug only).
    151  * @return    M4ERR_AIR_FORMAT_NOT_SUPPORTED: the requested input format is not supported.
    152  ******************************************************************************
    153 */
    154 M4OSA_ERR M4AIR_configure(M4OSA_Context pContext, M4AIR_Params* pParams);
    155 
    156 
    157 /**
    158  ******************************************************************************
    159  * M4OSA_ERR M4AIR_get(M4OSA_Context pContext, M4VIFI_ImagePlane* pIn, M4VIFI_ImagePlane* pOut)
    160  * @brief    This function will provide the requested resized area of interest according to
    161  *            settings provided in M4AIR_configure.
    162  * @note    In case the input format type is JPEG, input plane(s)
    163  *            in pIn is not used. In normal mode, dimension specified in output plane(s) structure
    164  *            must be the same than the one specified in M4AIR_configure. In stripe mode, only
    165  *            the width will be the same, height will be taken as the stripe height (typically 16).
    166  *            In normal mode, this function is call once to get the full output picture. In stripe
    167  *            mode, it is called for each stripe till the whole picture has been retrieved,and
    168  *            the position of the output stripe in the output picture is internally incremented
    169  *            at each step.
    170  *            Any call to M4AIR_configure during stripe process will reset this one to the
    171  *              beginning of the output picture.
    172  * @param    pContext:    (IN) Context identifying the instance
    173  * @param    pIn:            (IN) Plane structure containing input Plane(s).
    174  * @param    pOut:        (IN/OUT)  Plane structure containing output Plane(s).
    175  * @return    M4NO_ERROR: there is no error
    176  * @return    M4ERR_ALLOC: No more memory space to add a new effect.
    177  * @return    M4ERR_PARAMETER: pContext is M4OSA_NULL (debug only).
    178  ******************************************************************************
    179 */
    180 M4OSA_ERR M4AIR_get(M4OSA_Context pContext, M4VIFI_ImagePlane* pIn, M4VIFI_ImagePlane* pOut);
    181 
    182 
    183 
    184 #endif /* M4AIR_API_H */
    185