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