M4MCS_InternalFunctions.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    M4MCS_InternalFunctions.h
20 * @brief   This file contains all functions declarations internal
21 *          to the MCS.
22 *************************************************************************
23 */
24
25#ifndef __M4MCS_INTERNALFUNCTIONS_H__
26#define __M4MCS_INTERNALFUNCTIONS_H__
27
28#ifdef __cplusplus
29extern "C" {
30#endif
31
32#include "M4VPP_API.h"
33#include "M4ENCODER_common.h"
34
35/**
36 **************************************************************************
37 * M4OSA_ERR M4MCS_intApplyVPP( M4VPP_Context pContext,
38 *                              M4VIFI_ImagePlane* pPlaneIn,
39 *                              M4VIFI_ImagePlane* pPlaneOut)
40 * @brief   Do the video rendering and the resize (if needed)
41 * @note    It is called by the video encoder
42 * @param   pContext    (IN)     VPP context, which actually is the MCS
43 *                               internal context in our case
44 * @param   pPlaneIn    (IN)     Contains the image
45 * @param   pPlaneOut   (IN/OUT) Pointer to an array of 3 planes that will
46 *                               contain the output YUV420 image
47 * @return  M4NO_ERROR:                 No error
48 * @return  ERR_MCS_VIDEO_DECODE_ERROR: the video decoding failed
49 * @return  ERR_MCS_RESIZE_ERROR:       the resizing failed
50 * @return  Any error returned by an underlaying module
51 **************************************************************************
52 */
53M4OSA_ERR M4MCS_intApplyVPP(M4VPP_Context pContext, M4VIFI_ImagePlane* pPlaneIn,
54                            M4VIFI_ImagePlane* pPlaneOut);
55
56/**
57 **************************************************************************
58 * M4OSA_ERR M4MCS_SubscribeMediaAndCodec(M4MCS_Context pContext);
59 * @brief    This function registers the reader, decoders, writers and encoders
60 *           in the MCS.
61 * @note
62 * @param    pContext:    (IN) Execution context.
63 * @return   M4NO_ERROR:        there is no error
64 * @return   M4ERR_PARAMETER    pContext is NULL
65 **************************************************************************
66 */
67M4OSA_ERR M4MCS_subscribeMediaAndCodec(M4MCS_Context pContext);
68
69/**
70 **************************************************************************
71 * @brief    Clear encoders, decoders, reader and writers interfaces tables
72 * @param    pContext            (IN/OUT) MCS context.
73 * @return    M4NO_ERROR:            No error
74 * @return    M4ERR_PARAMETER:    The context is null
75 **************************************************************************
76 */
77M4OSA_ERR   M4MCS_clearInterfaceTables(M4MCS_Context pContext);
78
79/**
80 **************************************************************************
81 * M4OSA_ERR   M4MCS_registerWriter(M4MCS_Context pContext,
82 *                                  M4VIDEOEDITING_FileType MediaType,
83 *                                  M4WRITER_GlobalInterface *pWtrGlobalInterface,
84 *                                  M4WRITER_DataInterface *pWtrDataInterface)
85 * @brief   This function will register a specific file format writer.
86 * @note    According to the Mediatype, this function will store in the internal
87 *          context the writer context.
88 * @param   pContext:    (IN) Execution context.
89 * @return  M4NO_ERROR:         there is no error
90 * @return  M4ERR_PARAMETER     pContext,pWtrGlobalInterface or pWtrDataInterface
91 *                              is M4OSA_NULL (debug only), or invalid MediaType
92 **************************************************************************
93 */
94M4OSA_ERR   M4MCS_registerWriter(
95                        M4MCS_Context pContext,
96                        M4WRITER_OutputFileType MediaType,
97                        M4WRITER_GlobalInterface* pWtrGlobalInterface,
98                        M4WRITER_DataInterface* pWtrDataInterface);
99
100/**
101 ******************************************************************************
102 * M4OSA_ERR   M4MCS_registerEncoder(   M4MCS_Context pContext,
103 *                                      M4VIDEOEDITING_VideoFormat mediaType,
104 *                                      M4ENCODER_GlobalInterface *pEncGlobalInterface)
105 * @brief   This function will register a specific video encoder.
106 * @note    According to the Mediatype, this function will store in the internal
107 *          context the encoder context.
108 * @param   pContext:    (IN) Execution context.
109 * @return  M4NO_ERROR:         there is no error
110 * @return  M4ERR_PARAMETER     pContext or pEncGlobalInterface is
111 *                              M4OSA_NULL (debug only), or invalid MediaType
112 ******************************************************************************
113 */
114M4OSA_ERR   M4MCS_registerVideoEncoder(
115                        M4MCS_Context pContext,
116                        M4ENCODER_Format MediaType,
117                        M4ENCODER_GlobalInterface *pEncGlobalInterface);
118
119/**
120 ******************************************************************************
121 * M4OSA_ERR   M4MCS_registerAudioEncoder(  M4MCS_Context pContext,
122 *                                          M4ENCODER_AudioFormat mediaType,
123 *                                          M4ENCODER_AudioGlobalInterface *pEncGlobalInterface)
124 * @brief   This function will register a specific audio encoder.
125 * @note    According to the Mediatype, this function will store in the internal
126 *          context the encoder context.
127 * @param   pContext:               (IN)   Execution context.
128 * @param   mediaType:              (IN)   The media type.
129 * @param   pEncGlobalInterface:    (OUT)  The encoder interface functions.
130 * @return  M4NO_ERROR:       there is no error
131 * @return  M4ERR_PARAMETER:  pContext or pEncGlobalInterface is
132 *                              M4OSA_NULL (debug only)
133 ******************************************************************************
134 */
135M4OSA_ERR   M4MCS_registerAudioEncoder(
136                        M4MCS_Context pContext,
137                        M4ENCODER_AudioFormat MediaType,
138                        M4ENCODER_AudioGlobalInterface *pEncGlobalInterface);
139
140/**
141 **************************************************************************
142 * @brief    Register reader.
143 * @param    pContext            (IN/OUT) MCS context.
144 * @return    M4NO_ERROR:            No error
145 * @return    M4ERR_PARAMETER:    A parameter is null (in DEBUG only)
146 **************************************************************************
147 */
148M4OSA_ERR   M4MCS_registerReader(   M4MCS_Context pContext,
149                                    M4READER_MediaType mediaType,
150                                    M4READER_GlobalInterface *pRdrGlobalInterface,
151                                    M4READER_DataInterface *pRdrDataInterface);
152
153/**
154 **************************************************************************
155 * @brief   Register video decoder
156 * @param   pContext             (IN/OUT) MCS context.
157 * @param   decoderType          (IN) Decoder type
158 * @param   pDecoderInterface    (IN) Decoder interface.
159 * @return  M4NO_ERROR:            No error
160 * @return  M4ERR_PARAMETER:    A parameter is null (in DEBUG only),or the
161 *                              decoder type is invalid
162 **************************************************************************
163 */
164M4OSA_ERR   M4MCS_registerVideoDecoder( M4MCS_Context pContext,
165                                        M4DECODER_VideoType decoderType,
166                                        M4DECODER_VideoInterface *pDecoderInterface);
167
168/**
169 ************************************************************************
170 * @brief   Register audio decoder
171 * @note    This function is used internaly by the MCS to register Core audio decoders,
172 * @param   context            (IN/OUT) MCS context.
173 * @param   decoderType        (IN)     Audio decoder type
174 * @param   pDecoderInterface  (IN)     Audio decoder interface.
175 * @return  M4NO_ERROR:        No error
176 * @return  M4ERR_PARAMETER:   A parameter is null, or the decoder type is invalid(in DEBUG only)
177 ************************************************************************
178 */
179M4OSA_ERR   M4MCS_registerAudioDecoder(M4MCS_Context pContext, M4AD_Type decoderType,
180                                        M4AD_Interface *pDecoderInterface);
181
182/**
183 ************************************************************************
184 * @brief   Unregister writer
185 * @param   pContext            (IN/OUT) MCS context.
186 * @return  M4NO_ERROR:         No error
187 * @return  M4ERR_PARAMETER:    A parameter is null (in DEBUG only)
188 ************************************************************************
189 */
190M4OSA_ERR   M4MCS_unRegisterAllWriters(M4MCS_Context pContext);
191
192/**
193 ************************************************************************
194 * @brief   Unregister the encoders
195 * @param   pContext            (IN/OUT) MCS context.
196 * @return  M4NO_ERROR:         No error
197 * @return  M4ERR_PARAMETER:    A parameter is null (in DEBUG only)
198 ************************************************************************
199 */
200M4OSA_ERR   M4MCS_unRegisterAllEncoders(M4MCS_Context pContext);
201
202/**
203 ************************************************************************
204 * @brief   Unregister reader
205 * @param   pContext            (IN/OUT) MCS context.
206 * @return  M4NO_ERROR:         No error
207 * @return  M4ERR_PARAMETER:    A parameter is null (in DEBUG only)
208 ************************************************************************
209 */
210M4OSA_ERR   M4MCS_unRegisterAllReaders(M4MCS_Context pContext);
211
212/**
213 ************************************************************************
214 * @brief   Unregister the decoders
215 * @param   pContext            (IN/OUT) MCS context.
216 * @return  M4NO_ERROR:         No error
217 * @return  M4ERR_PARAMETER:    A parameter is null (in DEBUG only)
218 ************************************************************************
219 */
220M4OSA_ERR   M4MCS_unRegisterAllDecoders(M4MCS_Context pContext);
221
222/**
223 ************************************************************************
224 * @brief   Set current writer
225 * @param   pContext            (IN/OUT) MCS context.
226 * @param   mediaType           (IN) Media type.
227 * @return  M4NO_ERROR:         No error
228 * @return  M4ERR_PARAMETER:                    A parameter is null (in DEBUG only)
229 * @return  M4WAR_MCS_MEDIATYPE_NOT_SUPPORTED:  Media type not supported
230 ************************************************************************
231 */
232M4OSA_ERR   M4MCS_setCurrentWriter( M4MCS_Context pContext,
233                                    M4VIDEOEDITING_FileType mediaType);
234
235/**
236 ************************************************************************
237 * @brief    Set a video encoder
238 * @param    pContext            (IN/OUT) MCS context.
239 * @param    MediaType           (IN) Encoder type
240 * @return    M4NO_ERROR:            No error
241 * @return    M4ERR_PARAMETER:                    A parameter is null (in DEBUG only)
242 * @return    M4WAR_MCS_MEDIATYPE_NOT_SUPPORTED:    Media type not supported
243 ************************************************************************
244 */
245M4OSA_ERR   M4MCS_setCurrentVideoEncoder(   M4MCS_Context pContext,
246                                            M4VIDEOEDITING_VideoFormat mediaType);
247
248/**
249 ************************************************************************
250 * @brief    Set an audio encoder
251 * @param    context            (IN/OUT) MCS context.
252 * @param    MediaType        (IN) Encoder type
253 * @return    M4NO_ERROR:            No error
254 * @return    M4ERR_PARAMETER:    A parameter is null (in DEBUG only)
255 ************************************************************************
256 */
257M4OSA_ERR   M4MCS_setCurrentAudioEncoder(   M4MCS_Context pContext,
258                                            M4VIDEOEDITING_AudioFormat mediaType);
259
260/**
261 ************************************************************************
262 * @brief    Set current reader
263 * @param    pContext            (IN/OUT) MCS context.
264 * @param    mediaType           (IN) Media type.
265 * @return    M4NO_ERROR:        No error
266 * @return    M4ERR_PARAMETER:   A parameter is null (in DEBUG only)
267 * @return    M4WAR_MCS_MEDIATYPE_NOT_SUPPORTED:    Media type not supported
268 ************************************************************************
269 */
270M4OSA_ERR   M4MCS_setCurrentReader( M4MCS_Context pContext,
271                                    M4VIDEOEDITING_FileType mediaType);
272
273/**
274 ************************************************************************
275 * @brief    Set a video decoder
276 * @param    pContext           (IN/OUT) MCS context.
277 * @param    decoderType        (IN) Decoder type
278 * @return    M4NO_ERROR:            No error
279 * @return    M4ERR_PARAMETER:       A parameter is null (in DEBUG only)
280 * @return    M4WAR_MCS_MEDIATYPE_NOT_SUPPORTED:    Media type not supported
281 ************************************************************************
282 */
283M4OSA_ERR   M4MCS_setCurrentVideoDecoder(   M4MCS_Context pContext,
284                                            M4_StreamType mediaType);
285
286/**
287 ************************************************************************
288 * @brief    Set an audio decoder
289 * @param    context            (IN/OUT) MCS context.
290 * @param    decoderType        (IN) Decoder type
291 * @return    M4NO_ERROR:         No error
292 * @return    M4ERR_PARAMETER:    A parameter is null (in DEBUG only)
293 ************************************************************************
294 */
295M4OSA_ERR   M4MCS_setCurrentAudioDecoder(M4MCS_Context pContext, M4_StreamType mediaType);
296
297/**
298 ******************************************************************************
299 * M4OSA_ERR M4MCS_intCheckAudioEffects(M4MCS_InternalContext* pContext)
300 * @brief    Check if an effect has to be applied currently
301 * @note     It is called by the stepEncoding function
302 * @param    pContext    (IN)   MCS internal context
303 * @return   M4NO_ERROR:        No error
304 ******************************************************************************
305 */
306M4OSA_ERR M4MCS_intCheckAudioEffects(M4MCS_InternalContext* pC);
307
308/**
309 ******************************************************************************
310 * M4OSA_ERR M4MCS_editAudioEffectFct_FadeIn()
311 * @brief    Apply audio effect FadeIn to pPCMdata
312 * @param    pC           (IN/OUT) Internal edit context
313 * @param    pPCMdata     (IN/OUT) Input and Output PCM audio data
314 * @param    uiPCMsize    (IN)     Size of pPCMdata
315 * @param    pProgress    (IN)     Effect progress
316 * @return   M4NO_ERROR:           No error
317 ******************************************************************************
318 */
319M4OSA_ERR M4MCS_editAudioEffectFct_FadeIn(  M4OSA_Void *pFunctionContext,
320                                            M4OSA_Int16 *pPCMdata,
321                                            M4OSA_UInt32 uiPCMsize,
322                                            M4MCS_ExternalProgress *pProgress);
323
324/**
325 ******************************************************************************
326 * M4OSA_ERR M4MCS_editAudioEffectFct_FadeIn()
327 * @brief    Apply audio effect FadeIn to pPCMdata
328 * @param    pC           (IN/OUT) Internal edit context
329 * @param    pPCMdata     (IN/OUT) Input and Output PCM audio data
330 * @param    uiPCMsize    (IN)     Size of pPCMdata
331 * @param    pProgress    (IN)     Effect progress
332 * @return   M4NO_ERROR:           No error
333 ******************************************************************************
334 */
335M4OSA_ERR M4MCS_editAudioEffectFct_FadeOut( M4OSA_Void *pFunctionContext,
336                                            M4OSA_Int16 *pPCMdata,
337                                            M4OSA_UInt32 uiPCMsize,
338                                            M4MCS_ExternalProgress *pProgress);
339
340#ifdef TIMESCALE_BUG
341/**
342 ************************************************************************
343 * M4OSA_ERR M4MCS_intParseVideoDSI( )
344 * @brief :  This function parses video DSI and changes writer vop time increment resolution
345 * @note  :  It also calculates the number of bits on which the vop_time_increment is coded
346 *           in the input stream
347 * @param
348 * @return
349 ************************************************************************
350 */
351M4OSA_ERR M4MCS_intParseVideoDSI(M4MCS_InternalContext* pC);
352
353/**
354 ************************************************************************
355 * M4OSA_ERR M4MCS_intChangeAUVideoTimescale( )
356 * @brief
357 * @note
358 * @param    pC           (IN/OUT) Internal edit context
359 * @return
360 ************************************************************************
361 */
362M4OSA_ERR M4MCS_intChangeAUVideoTimescale(M4MCS_InternalContext* pC);
363#endif /* TIMESCALE_BUG */
364
365#ifdef __cplusplus
366}
367#endif
368
369#endif /* __M4MCS_INTERNALFUNCTIONS_H__ */
370
371