xref: /utopia/UTPA2-700.0.x/mxlib/include/apiVOIPMFE.h (revision 53ee8cc121a030b8d368113ac3e966b4705770ef)
1 //<MStar Software>
2 //******************************************************************************
3 // MStar Software
4 // Copyright (c) 2010 - 2012 MStar Semiconductor, Inc. All rights reserved.
5 // All software, firmware and related documentation herein ("MStar Software") are
6 // intellectual property of MStar Semiconductor, Inc. ("MStar") and protected by
7 // law, including, but not limited to, copyright law and international treaties.
8 // Any use, modification, reproduction, retransmission, or republication of all
9 // or part of MStar Software is expressly prohibited, unless prior written
10 // permission has been granted by MStar.
11 //
12 // By accessing, browsing and/or using MStar Software, you acknowledge that you
13 // have read, understood, and agree, to be bound by below terms ("Terms") and to
14 // comply with all applicable laws and regulations:
15 //
16 // 1. MStar shall retain any and all right, ownership and interest to MStar
17 //    Software and any modification/derivatives thereof.
18 //    No right, ownership, or interest to MStar Software and any
19 //    modification/derivatives thereof is transferred to you under Terms.
20 //
21 // 2. You understand that MStar Software might include, incorporate or be
22 //    supplied together with third party`s software and the use of MStar
23 //    Software may require additional licenses from third parties.
24 //    Therefore, you hereby agree it is your sole responsibility to separately
25 //    obtain any and all third party right and license necessary for your use of
26 //    such third party`s software.
27 //
28 // 3. MStar Software and any modification/derivatives thereof shall be deemed as
29 //    MStar`s confidential information and you agree to keep MStar`s
30 //    confidential information in strictest confidence and not disclose to any
31 //    third party.
32 //
33 // 4. MStar Software is provided on an "AS IS" basis without warranties of any
34 //    kind. Any warranties are hereby expressly disclaimed by MStar, including
35 //    without limitation, any warranties of merchantability, non-infringement of
36 //    intellectual property rights, fitness for a particular purpose, error free
37 //    and in conformity with any international standard.  You agree to waive any
38 //    claim against MStar for any loss, damage, cost or expense that you may
39 //    incur related to your use of MStar Software.
40 //    In no event shall MStar be liable for any direct, indirect, incidental or
41 //    consequential damages, including without limitation, lost of profit or
42 //    revenues, lost or damage of data, and unauthorized system use.
43 //    You agree that this Section 4 shall still apply without being affected
44 //    even if MStar Software has been modified by MStar in accordance with your
45 //    request or instruction for your use, except otherwise agreed by both
46 //    parties in writing.
47 //
48 // 5. If requested, MStar may from time to time provide technical supports or
49 //    services in relation with MStar Software to you for your use of
50 //    MStar Software in conjunction with your or your customer`s product
51 //    ("Services").
52 //    You understand and agree that, except otherwise agreed by both parties in
53 //    writing, Services are provided on an "AS IS" basis and the warranty
54 //    disclaimer set forth in Section 4 above shall apply.
55 //
56 // 6. Nothing contained herein shall be construed as by implication, estoppels
57 //    or otherwise:
58 //    (a) conferring any license or right to use MStar name, trademark, service
59 //        mark, symbol or any other identification;
60 //    (b) obligating MStar or any of its affiliates to furnish any person,
61 //        including without limitation, you and your customers, any assistance
62 //        of any kind whatsoever, or any information; or
63 //    (c) conferring any license or right under any intellectual property right.
64 //
65 // 7. These terms shall be governed by and construed in accordance with the laws
66 //    of Taiwan, R.O.C., excluding its conflict of law rules.
67 //    Any and all dispute arising out hereof or related hereto shall be finally
68 //    settled by arbitration referred to the Chinese Arbitration Association,
69 //    Taipei in accordance with the ROC Arbitration Law and the Arbitration
70 //    Rules of the Association by three (3) arbitrators appointed in accordance
71 //    with the said Rules.
72 //    The place of arbitration shall be in Taipei, Taiwan and the language shall
73 //    be English.
74 //    The arbitration award shall be final and binding to both parties.
75 //
76 //******************************************************************************
77 //<MStar Software>
78 ////////////////////////////////////////////////////////////////////////////////
79 //
80 // Copyright (c) 2009-2010 MStar Semiconductor, Inc.
81 // All rights reserved.
82 //
83 // Unless otherwise stipulated in writing, any and all information contained
84 // herein regardless in any format shall remain the sole proprietary of
85 // MStar Semiconductor Inc. and be kept in strict confidence
86 // ("MStar Confidential Information") by the recipient.
87 // Any unauthorized act including without limitation unauthorized disclosure,
88 // copying, use, reproduction, sale, distribution, modification, disassembling,
89 // reverse engineering and compiling of the contents of MStar Confidential
90 // Information is unlawful and strictly prohibited. MStar hereby reserves the
91 // rights to any and all damages, losses, costs and expenses resulting therefrom.
92 //
93 ////////////////////////////////////////////////////////////////////////////////
94 
95 ///////////////////////////////////////////////////////////////////////////////////////////////////
96 ///
97 /// @file   apiVOIPMFE.h
98 /// @brief  MStar Multi Format Video Encoder driver
99 /// @author MStar Semiconductor Inc.
100 /// @version 1.0
101 ///////////////////////////////////////////////////////////////////////////////////////////////////
102 
103 /*! \defgroup VDEC VDEC modules
104 
105     *! \defgroup VENC VENC(video encoder) interface.
106      *  \ingroup VDEC
107     This is the MStar Multi Format Video Encoder driver
108 
109     <b>Calling sequences</b>
110 
111    -# MApi_MFE_Initialize
112    -# MApi_MFE_Encode
113    -# MApi_MFE_CompressOnePicture     //loop
114    -# (optional) MApi_MFE_GetVOL
115    -# (optional) MApi_MFE_SetConfig
116    -# (optional) MApi_MFE_GetConfig
117    -# MApi_MFE_DeInitialize
118 
119  *! \defgroup MFE Multi Format Video Encoder driver
120  *  \ingroup VENC
121 
122  * *! \defgroup MFE_BASIC MFE driver basic.
123  *  \ingroup MFE
124 
125  *! \defgroup MFE_CONFIG MFE driver set/get configure.
126  *  \ingroup MFE
127 
128  *! \defgroup MFE_OPERATION MFE driver operation.
129  *  \ingroup MFE
130 
131  *! \defgroup MFE_toBeRemove MFE driver API to be removed.
132  *  \ingroup MFE
133  */
134 
135 #ifndef _API_VOIP_MFE_H_
136 #define _API_VOIP_MFE_H_
137 
138 #ifdef __cplusplus
139 extern "C"
140 {
141 #endif
142 
143 // below function is used for T8/T12/Janus2 VOIP project
144 
145 /* vop coding modes */
146 // type: I_VOP, P_VOP, or B_VOP
147 #define I_VOP        0UL
148 #define P_VOP        1UL
149 #define B_VOP        2UL
150 
151 
152 // OBSOLETE
153  typedef enum {
154     PQ_LOW,
155     PQ_NORMAL,
156     PQ_HIGH
157  } PQ_LEVEL;
158 
159 // OBSOLETE
160  typedef enum {
161     VOIP_MPEG4,
162     VOIP_H263,
163     VOIP_H264,
164     VOIP_JPEG
165  } VOIP_CODEC_TYPE;
166 
167 // Codec type
168 typedef enum {
169     MPEG4_ENC = 0,  // OBSOLETE
170     H263_ENC = 1,   // OBSOLETE
171     H264_ENC = 2,   // H.264 encoder
172     JPEG_ENC = 3,   // OBSOLETE
173     UNKNOWN_TYPE = 0xFF
174 } MFE_CODEC_TYPE;
175 
176 
177 /*
178 typedef enum {
179     MFE_RET_OK                      = 1,
180     MFE_RET_FAIL                    = -1000,
181     MFE_RET_CLOSE_FAIL              = -1002,
182 
183     MFE_RET_DEC_INIT_FAIL           = -2000,
184 
185     MFE_RET_INVALID_PARAM           = -4000
186 } MFE_ERROR_CODE;
187 */
188 
189 //-------------------------------------------------------------------------------------------------
190 /// Configuration type for MApi_MFE_SetConfig and MApi_MFE_GetConfig
191 ///
192 ///     MFE_ENC_SETCONF_FRAME_TYPE
193 ///         (MS_S32*) value: frame type
194 ///         If frame type is I_VOP, force compress I frame.
195 ///
196 ///     MFE_ENC_SETCONF_CHANGE_FRAME_RATE
197 ///         (MS_S32*) value: frame rate x 100
198 ///         Sets frame rate.
199 ///
200 ///     MFE_ENC_SETCONF_CHANGE_BIT_RATE
201 ///         (MS_S32*) value: bit rate (bits per second)
202 ///         Sets bit rate.
203 ///
204 ///     MFE_ENC_SETCONF_OUT_BSP_BUFFER
205 ///         (MEMMAP_t*) value: output buffer descriptor
206 ///         Sets output buffer.
207 ///
208 ///     MFE_ENC_SETCONF_FRAME_TAG
209 ///         (MS_S32*) value: frame type
210 ///         Sets a tag associated the next frame.
211 ///         This value can be retrieved with MFE_ENC_GETCONF_FRAME_TAG.
212 ///
213 ///     MFE_ENC_SETCONF_CHANGE_BIT_RATE_AND_FRAME_RATE
214 ///         (PVR_Info*) value: encode info
215 ///         Sets frame rate and bit rate using PVR_Info's nBitrate and FrameRatex100 fields.
216 ///
217 ///     MFE_ENC_SETCONF_RESET_SPSPPS
218 ///         (void*) value: not used
219 ///         Resets SPS and PPS header content with current configuration.
220 ///
221 ///     MFE_ENC_SETCONF_SET_COLORFORMAT
222 ///         (MS_S32*) value: input data format (MFE_COLOR_FORMAT_INFO)
223 ///         Sets input data format with values from MFE_COLOR_FORMAT_INFO.
224 ///
225 ///     MFE_ENC_GETCONF_FRAME_TAG
226 ///         (MS_U32*) value: frame tag
227 ///         Gets frame tag previously set by MFE_ENC_SETCONF_FRAME_TAG.
228 ///
229 ///     MFE_ENC_GETCONF_OUT_BSP_BUFFER
230 ///         (MEMMAP_t*) value: output buffer descriptor
231 ///         Gets descriptor of output buffer.
232 ///
233 ///     MFE_ENC_GETCONF_CONFIG
234 ///         (PVR_Info*) value: encode info
235 ///         Gets a copy of encode info used during initialization.
236 ///
237 //-------------------------------------------------------------------------------------------------
238 typedef enum {
239     MFE_ENC_SETCONF_FRAME_TYPE = 100,
240     MFE_ENC_SETCONF_CHANGE_FRAME_RATE,
241     MFE_ENC_SETCONF_CHANGE_BIT_RATE,
242     MFE_ENC_SETCONF_OUT_BSP_BUFFER,
243     MFE_ENC_SETCONF_FRAME_TAG,
244     MFE_ENC_SETCONF_JPE_QUALITY,                        // OBSOLETE
245     MFE_ENC_SETCONF_CHANGE_BIT_RATE_AND_FRAME_RATE,
246     MFE_ENC_SETCONF_RESET_SPSPPS,
247     MFE_ENC_SETCONF_SET_COLORFORMAT,
248 
249     MFE_ENC_GETCONF_FRAME_TAG = 300,
250     MFE_ENC_GETCONF_OUT_BSP_BUFFER,
251     MFE_ENC_GETCONF_JPE_QUALITY,                        // OBSOLETE
252     MFE_ENC_GETCONF_DROP,                               // OBSOLETE
253     MFE_ENC_GETCONF_CONFIG,
254 } MFE_ENC_CONF;
255 
256 // <<< Calling sequences >>>
257 //
258 //      MApi_MFE_Initialize
259 //      MApi_MFE_Encode
260 //      MApi_MFE_CompressOnePicture     //loop
261 //      (optional) MApi_MFE_GetVOL
262 //      (optional) MApi_MFE_SetConfig
263 //      (optional) MApi_MFE_GetConfig
264 //      MApi_MFE_DeInitialize
265 
266 
267 //-------------------------------------------------------------------------------------------------
268 /// Notify driver to start encoder.
269 /// @ingroup MFE_toBeRemove
270 /// @return TRUE : succeed
271 /// @return FALSE : fail
272 //-------------------------------------------------------------------------------------------------
273 MS_BOOL MApi_MFE_Encode(void);
274 
275 //-------------------------------------------------------------------------------------------------
276 /// Encode one frame.
277 /// @ingroup MFE_BASIC
278 /// @param  YUVPlane               \b IN: DRAM location of input frame data.
279 /// @param  bForceIframe           \b IN: If TRUE, force this frame to be I-frame.
280 /// @return TRUE : succeed
281 /// @return FALSE : fail
282 //-------------------------------------------------------------------------------------------------
283 MS_BOOL MApi_MFE_CompressOnePicture_ex(MEMMAP_CUR_t YUVPlane, MS_BOOL bForceIframe);
284 
285 //-------------------------------------------------------------------------------------------------
286 /// Get bitstream header.
287 /// @ingroup MFE_BASIC
288 /// @param  header_info              \b OUT: return header size and length.
289 /// @return TRUE : succeed
290 /// @return FALSE : fail
291 //-------------------------------------------------------------------------------------------------
292 MS_BOOL MApi_MFE_GetVOL_ex(void *header_info);
293 
294 //-------------------------------------------------------------------------------------------------
295 /// De-initialize MFE driver
296 /// @ingroup MFE_BASIC
297 /// @return TRUE : succeed
298 /// @return FALSE : fail
299 //-------------------------------------------------------------------------------------------------
300 MS_BOOL MApi_MFE_DeInitialize(void);
301 
302 //-------------------------------------------------------------------------------------------------
303 /// Get MFE driver state.
304 /// @ingroup MFE_operation
305 /// @return MFE driver state
306 //-------------------------------------------------------------------------------------------------
307 MFE_STATE MApi_MFE_GetState(void);
308 
309 
310 //-------------------------------------------------------------------------------------------------
311 /// Initializes MFE driver.
312 /// @ingroup MFE_CONFIG
313 /// @param  in_Info                \b IN: encoding paramemters
314 /// @param  out_cb                 \b IN: callback function invoked after frame is encoded
315 /// @param  mfe_CleanBufStatus     \b IN: callback function invoked to signal input buffer status
316 /// @param  ctx                    \b IN: custom context to be associated with encode task
317 /// @return TRUE : succeed
318 /// @return FALSE : fail
319 //-------------------------------------------------------------------------------------------------
320 MS_BOOL MApi_MFE_Initialize_ex(PVR_Info* in_Info,
321 StreamCallback out_cb,CleanCallback mfe_CleanBufStatus, void *ctx);
322 
323 //-------------------------------------------------------------------------------------------------
324 /// Set config to MFE driver.
325 /// @ingroup MFE_CONFIG
326 /// @param  conf_type              \b IN: set config type.
327 /// @param  value                  \b IN: set config value.
328 /// @return TRUE : succeed
329 /// @return FALSE : fail
330 //-------------------------------------------------------------------------------------------------
331 MS_BOOL MApi_MFE_SetConfig(MFE_ENC_CONF conf_type, void *value);
332 
333 //-------------------------------------------------------------------------------------------------
334 /// Get config from MFE driver.
335 /// @ingroup MFE_CONFIG
336 /// @param  conf_type              \b IN: get config type.
337 /// @param  value                  \b OUT: return config value.
338 /// @return TRUE : succeed
339 /// @return FALSE : fail
340 //-------------------------------------------------------------------------------------------------
341 MS_BOOL MApi_MFE_GetConfig(MFE_ENC_CONF conf_type, void *value);
342 
343 //-------------------------------------------------------------------------------------------------
344 /// Get MFE HW capability.
345 /// @ingroup MFE_CONFIG
346 /// @param  pDrv                 \b OUT: Get HW capability.
347 /// @param  len                  \b OUT: Get HW capability length of struct.
348 /// @return TRUE : succeed
349 /// @return FALSE : fail
350 //-------------------------------------------------------------------------------------------------
351 MS_BOOL MApi_MFE_GetHWCap(MFE_HwCapV0 *pDrv, MS_U32 *len);
352 #ifdef __cplusplus
353 }
354 #endif
355 
356 #endif
357 
358