M4VSS3GPP_InternalTypes.h revision 6e779fda8a4f6258f9b910290b2f296d18fb2585
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 ******************************************************************************
19 * @file    M4VSS3GPP_InternalTypes.h
20 * @brief    This file contains all enum and types not visible to the external world.
21 * @note
22 ******************************************************************************
23*/
24
25
26#ifndef __M4VSS3GPP_INTERNALTYPES_H__
27#define __M4VSS3GPP_INTERNALTYPES_H__
28
29#define M4VSS_VERSION_MAJOR        3
30#define M4VSS_VERSION_MINOR        2
31#define M4VSS_VERSION_REVISION    5
32
33#include "NXPSW_CompilerSwitches.h"
34
35/**
36 *    VSS public API and types */
37#include "M4VSS3GPP_API.h"
38
39/**
40 *    Internally used modules */
41#include "M4READER_Common.h"        /**< Reader common interface */
42#include "M4WRITER_common.h"        /**< Writer common interface */
43#include "M4DECODER_Common.h"        /**< Decoder common interface */
44#include "M4ENCODER_common.h"        /**< Encoder common interface */
45#include "M4VIFI_FiltersAPI.h"        /**< Image planes definition */
46#include "M4READER_3gpCom.h"        /**< Read 3GPP file     */
47#include "M4AD_Common.h"            /**< Decoder audio   */
48#include "M4ENCODER_AudioCommon.h"  /**< Encode audio    */
49
50
51#include "SSRC.h"                    /**< SSRC             */
52#include "From2iToMono_16.h"        /**< Stereo to Mono     */
53#include "MonoTo2I_16.h"            /**< Mono to Stereo     */
54
55#ifdef __cplusplus
56extern "C" {
57#endif
58
59#define WINDOW_SIZE 10
60/**
61 ******************************************************************************
62 * enum            M4VSS3GPP_EditState
63 * @brief        Main state machine of the VSS 3GPP edit operation.
64 ******************************************************************************
65*/
66
67typedef enum
68{
69    M4VSS3GPP_kEditState_CREATED    = 0,    /**< M4VSS3GPP_editInit has been called */
70    M4VSS3GPP_kEditState_VIDEO        = 1,    /**< Processing video track */
71    M4VSS3GPP_kEditState_AUDIO        = 2,    /**< Processing audio track */
72    M4VSS3GPP_kEditState_MP3        = 3,    /**< Processing MP3 audio track */
73    M4VSS3GPP_kEditState_MP3_JUMP   = 4,        /**< Processing a jump in a MP3 audio track */
74    M4VSS3GPP_kEditState_FINISHED    = 5,    /**< Processing done, VSS 3GPP can be closed */
75    M4VSS3GPP_kEditState_CLOSED        = 6        /**< Output file has been closed,
76                                                     VSS 3GPP can be destroyed */
77}
78M4VSS3GPP_EditState;
79
80typedef enum
81{
82    /**< Doing Read/Write operation. This operation will have no processing
83     * on input frames. Only time stamp manipulations in output file. */
84    M4VSS3GPP_kEditVideoState_READ_WRITE    = 10,
85    /**< Decode encode to create an I frame. This is done for a single frame
86     * to create a new reference frame. */
87    M4VSS3GPP_kEditVideoState_BEGIN_CUT     = 11,
88    /**< Doing Read->Decode->Filter->Encode->Write operation on the input file
89     * to create the output file. */
90    M4VSS3GPP_kEditVideoState_DECODE_ENCODE = 12,
91    /**< Applied when Transition is active and blending of two videos is
92     * required. */
93    M4VSS3GPP_kEditVideoState_TRANSITION    = 13,
94    /**< Special Read/Write mode used after BEGIN_CUT state. The frame
95     * is already coded as I frame in BEGIN_CUT state; so skip it. */
96    M4VSS3GPP_kEditVideoState_AFTER_CUT     = 14
97}
98M4VSS3GPP_EditVideoState;
99
100typedef enum
101{
102    M4VSS3GPP_kEditAudioState_READ_WRITE    = 20,    /**< Doing Read/Write operation
103                                                        (no decoding/encoding) */
104    M4VSS3GPP_kEditAudioState_DECODE_ENCODE = 21,    /**< Doing Read-Decode/Filter/
105                                                            Encode-Write operation */
106    M4VSS3GPP_kEditAudioState_TRANSITION    = 22    /**< Transition; blending of two audio */
107}
108M4VSS3GPP_EditAudioState;
109
110
111/**
112 ******************************************************************************
113 * enum            M4VSS3GPP_ClipStatus
114 * @brief        Status of the clip.
115 ******************************************************************************
116*/
117typedef enum
118{
119    M4VSS3GPP_kClipStatus_READ            = 0,    /**< The clip is currently ready for reading */
120    M4VSS3GPP_kClipStatus_DECODE        = 1,    /**< The clip is currently ready for decoding */
121    M4VSS3GPP_kClipStatus_DECODE_UP_TO    = 2        /**< The clip is currently in splitted
122                                                         decodeUpTo() processing */
123}
124M4VSS3GPP_ClipStatus;
125
126
127/**
128 ******************************************************************************
129 * enum            M4VSS3GPP_ClipCurrentEffect
130 * @brief        Current effect applied to the clip.
131 ******************************************************************************
132*/
133typedef enum
134{
135    M4VSS3GPP_kClipCurrentEffect_NONE    = 0,    /**< None */
136    M4VSS3GPP_kClipCurrentEffect_BEGIN    = 1,    /**< Begin effect currently applied */
137    M4VSS3GPP_kClipCurrentEffect_END    = 2        /**< End effect currently applied */
138}
139M4VSS3GPP_ClipCurrentEffect;
140
141
142/**
143 ******************************************************************************
144 * enum            M4VSS3GPP_AudioMixingState
145 * @brief        Main state machine of the VSS audio mixing operation.
146 ******************************************************************************
147*/
148typedef enum
149{
150    M4VSS3GPP_kAudioMixingState_VIDEO = 0,            /**< Video is being processed */
151    M4VSS3GPP_kAudioMixingState_AUDIO_FIRST_SEGMENT,  /**< Audio is being processed */
152    M4VSS3GPP_kAudioMixingState_AUDIO_SECOND_SEGMENT, /**< Audio is being processed */
153    M4VSS3GPP_kAudioMixingState_AUDIO_THIRD_SEGMENT,  /**< Audio is being processed */
154    M4VSS3GPP_kAudioMixingState_FINISHED              /**< Processing finished, user must now
155                                                            call M4VSS3GPP_audioMixingCleanUp*/
156}
157M4VSS3GPP_AudioMixingState;
158
159
160/**
161 ******************************************************************************
162 * enum            M4VSS3GPP_ExtractPictureState
163 * @brief        Main state machine of the VSS picture extraction.
164 ******************************************************************************
165*/
166typedef enum
167{
168    M4VSS3GPP_kExtractPictureState_OPENED   = 0,  /**< Video clip is opened and ready to be read
169                                                     until the RAP before the picture to extract */
170    M4VSS3GPP_kExtractPictureState_PROCESS    = 1,  /**< Video is decoded from the previous RAP
171                                                        to the picture to extract */
172    M4VSS3GPP_kExtractPictureState_EXTRACTED= 2   /**< Video AU has been  decoded, user must now
173                                                        call M4VSS3GPP_extractPictureCleanUp */
174}
175M4VSS3GPP_ExtractPictureState;
176
177
178/**
179 ******************************************************************************
180 * @brief        Codecs registration same as in VPS and VES, so less mapping
181 *              is required toward VSS api types
182 ******************************************************************************
183*/
184typedef struct
185{
186    M4WRITER_GlobalInterface*    pGlobalFcts;    /**< open, close, setoption,etc... functions */
187    M4WRITER_DataInterface*        pDataFcts;        /**< data manipulation functions */
188} M4VSS3GPP_WriterInterface;
189/**
190 ******************************************************************************
191 * struct AAC_DEC_STREAM_PROPS
192 * @brief AAC Stream properties
193 * @Note aNoChan and aSampFreq are used for parsing even the user parameters
194 *        are different.  User parameters will be input for the output behaviour
195 *        of the decoder whereas for parsing bitstream properties are used.
196 ******************************************************************************
197 */
198typedef struct {
199  M4OSA_Int32 aAudioObjectType;     /**< Audio object type of the stream - in fact
200                                         the type found in the Access Unit parsed */
201  M4OSA_Int32 aNumChan;             /**< number of channels (=1(mono) or =2(stereo))
202                                         as indicated by input bitstream*/
203  M4OSA_Int32 aSampFreq;            /**< sampling frequency in Hz */
204  M4OSA_Int32 aExtensionSampFreq;   /**< extended sampling frequency in Hz, = 0 is
205                                         no extended frequency */
206  M4OSA_Int32 aSBRPresent;          /**< presence=1/absence=0 of SBR */
207  M4OSA_Int32 aPSPresent;           /**< presence=1/absence=0 of PS */
208  M4OSA_Int32 aMaxPCMSamplesPerCh;  /**< max number of PCM samples per channel */
209} AAC_DEC_STREAM_PROPS;
210
211
212/**
213 ******************************************************************************
214 * enum            M4VSS3GPP_MediaAndCodecCtxt
215 * @brief        Filesystem and codec registration function pointers
216 ******************************************************************************
217*/
218typedef struct {
219    /**
220      * Media and Codec registration */
221    /**< Table of M4VES_WriterInterface structures for avalaible Writers list */
222    M4VSS3GPP_WriterInterface    WriterInterface[M4WRITER_kType_NB];
223    /**< open, close, setoption,etc... functions of the used writer*/
224    M4WRITER_GlobalInterface*    pWriterGlobalFcts;
225    /**< data manipulation functions of the used writer */
226    M4WRITER_DataInterface*        pWriterDataFcts;
227
228    /**< Table of M4ENCODER_GlobalInterface structures for avalaible encoders list */
229    M4ENCODER_GlobalInterface*    pVideoEncoderInterface[M4ENCODER_kVideo_NB];
230    /**< Functions of the used encoder */
231    M4ENCODER_GlobalInterface*    pVideoEncoderGlobalFcts;
232
233    M4OSA_Void*                    pVideoEncoderExternalAPITable[M4ENCODER_kVideo_NB];
234    M4OSA_Void*                    pCurrentVideoEncoderExternalAPI;
235    M4OSA_Void*                    pVideoEncoderUserDataTable[M4ENCODER_kVideo_NB];
236    M4OSA_Void*                    pCurrentVideoEncoderUserData;
237
238    /**< Table of M4ENCODER_AudioGlobalInterface structures for avalaible encoders list */
239    M4ENCODER_AudioGlobalInterface*    pAudioEncoderInterface[M4ENCODER_kAudio_NB];
240    /**< Table of internal/external flags for avalaible encoders list */
241    M4OSA_Bool                      pAudioEncoderFlag[M4ENCODER_kAudio_NB];
242    /**< Functions of the used encoder */
243    M4ENCODER_AudioGlobalInterface*    pAudioEncoderGlobalFcts;
244
245    M4READER_GlobalInterface*   m_pReaderGlobalItTable[M4READER_kMediaType_NB];
246    M4READER_DataInterface*     m_pReaderDataItTable[M4READER_kMediaType_NB];
247    M4READER_GlobalInterface*   m_pReader;
248    M4READER_DataInterface*     m_pReaderDataIt;
249    M4OSA_UInt8                 m_uiNbRegisteredReaders;
250
251    M4DECODER_VideoInterface*   m_pVideoDecoder;
252    M4DECODER_VideoInterface*   m_pVideoDecoderItTable[M4DECODER_kVideoType_NB];
253    M4OSA_UInt8                 m_uiNbRegisteredVideoDec;
254#ifdef M4VSS_ENABLE_EXTERNAL_DECODERS
255    M4OSA_Void*                    m_pCurrentVideoDecoderUserData;
256    M4OSA_Void*                    m_pVideoDecoderUserDataTable[M4DECODER_kVideoType_NB];
257#endif
258
259    M4AD_Interface*             m_pAudioDecoder;
260    M4AD_Interface*                m_pAudioDecoderItTable[M4AD_kType_NB];
261    /**< store indices of external decoders */
262    M4OSA_Bool                    m_pAudioDecoderFlagTable[M4AD_kType_NB];
263
264    M4OSA_Void*                pAudioEncoderUserDataTable[M4ENCODER_kAudio_NB];
265    M4OSA_Void*                pCurrentAudioEncoderUserData;
266
267    M4OSA_Void*                pAudioDecoderUserDataTable[M4AD_kType_NB];
268    M4OSA_Void*                pCurrentAudioDecoderUserData;
269
270#ifdef M4VSS_SUPPORT_OMX_CODECS
271    /* boolean to tell whether registered external OMX codecs should be freed during cleanup
272     or new codec registration*/
273    M4OSA_Bool    bAllowFreeingOMXCodecInterface;
274#endif
275
276
277} M4VSS3GPP_MediaAndCodecCtxt;
278
279
280/**
281 ******************************************************************************
282 * structure    M4VSS3GPP_ClipContext
283 * @brief        This structure contains informations related to one 3GPP clip (private)
284 * @note        This structure is used to store the context related to one clip
285 ******************************************************************************
286*/
287typedef struct
288{
289    M4VSS3GPP_ClipSettings*        pSettings;            /**< Pointer to the clip settings
290                                                            (not possessed) */
291
292    M4VSS3GPP_ClipStatus        Vstatus;            /**< Video status of the clip reading */
293    M4VSS3GPP_ClipStatus        Astatus;            /**< Audio status of the clip reading */
294
295    M4OSA_Int32                    iVoffset;            /**< [Milliseconds] Offset between the
296                                                            clip and the output video stream
297                                                            (begin cut taken into account) */
298    M4OSA_Int32                    iAoffset;           /**< [Timescale] Offset between the clip
299                                                            and the output audio stream (begin
300                                                            cut taken into account) */
301
302    /**
303     * 3GPP reader Stuff */
304    M4OSA_FileReadPointer*        pFileReadPtrFct;
305    M4OSA_Context                pReaderContext;         /**< Context of the 3GPP reader module */
306    M4_VideoStreamHandler*        pVideoStream;        /**< Description of the read video stream */
307    M4_AudioStreamHandler*        pAudioStream;        /**< Description of the read audio stream */
308    M4_AccessUnit                VideoAU;            /**< Read video access unit (we do not use a
309                                                            pointer to allocate later, because
310                                                            most of the time we will need it) */
311    M4_AccessUnit                AudioAU;            /**< Read audio access unit (we do not use a
312                                                         pointer to allocate later, because most
313                                                         of the time we will need it) */
314    M4OSA_Bool                    bVideoAuAvailable;    /**< Tell if a video AU is available
315                                                            (previously read) */
316    /**< Boolean only used to fix the BZZ bug... */
317    M4OSA_Bool                    bFirstAuWritten;
318
319    /**
320     * Video decoder stuff */
321    M4OSA_Context                pViDecCtxt;            /**< Video decoder context */
322    M4OSA_Int32                 iVideoDecCts;       /**< [Milliseconds] For video decodeUpTo(),
323                                                             the actual reached cts */
324    M4OSA_Int32                    iVideoRenderCts;    /**< [Milliseconds] For video render(),
325                                                             the actual reached cts */
326    M4OSA_Bool                    isRenderDup;        /**< To handle duplicate frame rendering in
327                                                             case of external decoding */
328    M4VIFI_ImagePlane*            lastDecodedPlane;    /**< Last decoded plane */
329
330    /**
331     * MPEG4 time info stuff at clip level */
332    M4OSA_Bool             bMpeg4GovState;            /**< Namely, update or initialization */
333    M4OSA_UInt32           uiMpeg4PrevGovValueGet;    /**< Previous Gov value read (in second) */
334    M4OSA_UInt32           uiMpeg4PrevGovValueSet;    /**< Previous Gov value write (in second) */
335
336    /**
337     * Time-line stuff */
338     /**< [Milliseconds] CTS at which the video clip actually starts */
339    M4OSA_Int32                    iActualVideoBeginCut;
340    /**< [Milliseconds] CTS at which the audio clip actually starts */
341    M4OSA_Int32                    iActualAudioBeginCut;
342    /**< [Milliseconds] Time at which the clip must end */
343    M4OSA_Int32                    iEndTime;
344
345    /**
346     * Audio decoder stuff */
347    M4OSA_Context                pAudioDecCtxt;        /**< Context of the AMR decoder */
348    M4AD_Buffer                 AudioDecBufferIn;    /**< Input structure for the audio decoder */
349    M4AD_Buffer                    AudioDecBufferOut;    /**< Buffer for the decoded PCM data */
350    AAC_DEC_STREAM_PROPS        AacProperties;      /**< Structure for new api to get AAC
351                                                            properties */
352
353    /**
354     * Audio AU to Frame split stuff */
355    M4OSA_Bool                bAudioFrameAvailable;  /**< True if an audio frame is available */
356    M4OSA_MemAddr8            pAudioFramePtr;        /**< Pointer to the Audio frame */
357    M4OSA_UInt32              uiAudioFrameSize;        /**< Size of the audio frame available */
358    M4OSA_Int32               iAudioFrameCts;       /**< [Timescale] CTS of the audio frame
359                                                            available */
360
361    /**
362     * Silence frame stuff */
363     /**< Size to reserve to store a pcm full of zeros compatible with master clip stream type */
364    M4OSA_UInt32                uiSilencePcmSize;
365    /**< Pointer to silence frame data compatible with master clip stream type */
366    M4OSA_UInt8*                pSilenceFrameData;
367    /**< Size of silence frame data compatible with master clip stream type */
368    M4OSA_UInt32                uiSilenceFrameSize;
369    /**< [Timescale] Duration of silence frame data compatible with master clip stream type */
370    M4OSA_Int32                 iSilenceFrameDuration;
371    M4OSA_Double                scale_audio;            /**< frequency / 1000.0 */
372
373    /**
374     * Interfaces of the used modules */
375     /**< Filesystem and shell reader, decoder functions */
376    M4VSS3GPP_MediaAndCodecCtxt ShellAPI;
377    M4VIFI_ImagePlane           *pPlaneYuv;  /* YUV420 image plane, converted from ARGB888 */
378    M4VIFI_ImagePlane*          m_pPreResizeFrame;  /* The decoded image before resize
379                                                   (allocated only if resize needed)*/
380    M4VIFI_ImagePlane           *pPlaneYuvWithEffect; /* YUV420 image plane, with color effect */
381    M4OSA_Bool                  bGetYuvDataFromDecoder;  /* Boolean used to get YUV data from dummy video decoder only for first time */
382} M4VSS3GPP_ClipContext;
383
384
385/**
386 ******************************************************************************
387 * enum            anonymous enum
388 * @brief        enum to keep track of the encoder state
389 ******************************************************************************
390*/
391enum
392{
393    M4VSS3GPP_kNoEncoder,
394    M4VSS3GPP_kEncoderClosed,
395    M4VSS3GPP_kEncoderStopped,
396    M4VSS3GPP_kEncoderRunning
397};
398
399/**
400 ******************************************************************************
401 * structure    M4VSS3GPP_AudioVideoContext
402 * @brief        This structure defines the audio video context (private)
403 * @note        This structure is used for all audio/video, encoding/writing operations.
404 ******************************************************************************
405*/
406typedef struct
407{
408    /**
409     * Timing Stuff */
410    // Decorrelate input and output encoding timestamp to handle encoder prefetch
411    /**< [Milliseconds] Duration of the output file, used for progress computation */
412    M4OSA_Double                dInputVidCts;
413    /**< [Milliseconds] Current CTS of the video output stream */
414    M4OSA_Double                dOutputVidCts;
415/**< [Milliseconds] Current CTS of the audio output stream */
416    M4OSA_Double                dATo;
417     /**< [Milliseconds] Duration of the output file, used for progress computation */
418    M4OSA_Int32                    iOutputDuration;
419
420    /**
421     * Output Video Stream Stuff */
422    M4SYS_StreamType            VideoStreamType;        /**< Output video codec */
423    M4OSA_UInt32                uiVideoBitrate;     /**< Average video bitrate of the output file,
424                                                         computed from input bitrates, durations,
425                                                          transitions and cuts */
426    M4OSA_UInt32                uiVideoWidth;            /**< Output image width */
427    M4OSA_UInt32                uiVideoHeight;            /**< Output image height */
428    M4OSA_UInt32                uiVideoTimeScale;        /**< Time scale to use for the encoding
429                                                            of the transition (if MPEG-4) */
430    M4OSA_Bool                    bVideoDataPartitioning;    /**< Data partitioning to use for the
431                                                                 encoding of the transition
432                                                                 (if MPEG-4) */
433    M4OSA_MemAddr8                pVideoOutputDsi;        /**< Decoder Specific Info of the output
434                                                                 MPEG-4 track */
435    M4OSA_UInt16                uiVideoOutputDsiSize;    /**< Size of the Decoder Specific Info
436                                                                of the output MPEG-4 track */
437    M4OSA_Bool                  bActivateEmp;           /**< Encode in Mpeg4 format with
438                                                            limitations for EMP */
439
440    /**
441     * Output Audio Stream Stuff */
442    M4SYS_StreamType            AudioStreamType;        /**< Type of the output audio stream */
443    M4OSA_UInt32                uiNbChannels;           /**< Number of channels in the output
444                                                            stream (1=mono, 2=stereo) */
445    M4OSA_UInt32                uiAudioBitrate;         /**< Audio average bitrate (in bps) */
446    M4OSA_UInt32                uiSamplingFrequency;    /**< Sampling audio frequency (8000 for
447                                                                amr, 16000 or more for aac) */
448    M4OSA_MemAddr8                pAudioOutputDsi;        /**< Decoder Specific Info of the
449                                                                output audio track */
450    M4OSA_UInt16                uiAudioOutputDsiSize;    /**< Size of the Decoder Specific Info
451                                                                of the output audio track */
452
453    /**
454     * Audio Encoder stuff */
455    M4OSA_Context                   pAudioEncCtxt;        /**< Context of the audio encoder */
456    M4ENCODER_AudioDecSpecificInfo  pAudioEncDSI;       /**< Decoder specific info built by the
457                                                                encoder */
458    M4ENCODER_AudioParams           AudioEncParams;     /**< Config of the audio encoder */
459
460    /**
461     * Silence frame stuff */
462    M4OSA_UInt32                uiSilencePcmSize;       /**< Size to reserve to store a pcm full
463                                                             of zeros compatible with master clip
464                                                             stream type */
465    M4OSA_UInt8*                pSilenceFrameData;      /**< Pointer to silence frame data
466                                                                compatible with master clip
467                                                                stream type */
468    M4OSA_UInt32                uiSilenceFrameSize;     /**< Size of silence frame data compatible
469                                                             with master clip stream type */
470    M4OSA_Int32                 iSilenceFrameDuration;  /**< [Timescale] Duration of silence frame
471                                                                 data compatible with master clip
472                                                                 stream type */
473    M4OSA_Double                scale_audio;            /**< frequency / 1000.0 */
474
475    /**
476     * Video Encoder stuff */
477    M4ENCODER_Context            pEncContext;            /**< Context of the encoder */
478    M4WRITER_DataInterface        OurWriterDataInterface;    /**< Our own implementation of the
479                                                                    writer interface, to give to
480                                                                    the encoder shell */
481    M4OSA_MemAddr32                pDummyAuBuffer;            /**< Buffer given to the encoder for
482                                                                   it to write AUs we don't want
483                                                                    in the output */
484    M4OSA_Int32                    iMpeg4GovOffset;        /**< Clip GOV offset in ms between
485                                                                 video and system time */
486    M4OSA_ERR                    VppError;                /**< Error for VPP are masked by Video
487                                                               Encoder, so we must remember it */
488    M4OSA_UInt32                encoderState;
489
490    /**
491     * Writer stuff */
492    M4WRITER_Context            p3gpWriterContext;        /**< Context of the 3GPP writer module */
493    M4SYS_StreamDescription        WriterVideoStream;        /**< Description of the written
494                                                                    video stream */
495    M4SYS_StreamDescription        WriterAudioStream;        /**< Description of the written
496                                                                    audio stream */
497    M4WRITER_StreamVideoInfos    WriterVideoStreamInfo;    /**< Video properties of the written
498                                                                     video stream */
499    M4WRITER_StreamAudioInfos    WriterAudioStreamInfo;    /**< Audio properties of the written
500                                                                    audio stream */
501    M4SYS_AccessUnit            WriterVideoAU;            /**< Written video access unit */
502    M4SYS_AccessUnit            WriterAudioAU;            /**< Written audio access unit */
503    M4OSA_UInt32                uiVideoMaxAuSize;        /**< Max AU size set to the writer
504                                                                for the video */
505    M4OSA_UInt32                uiAudioMaxAuSize;        /**< Max AU size set to the writer
506                                                                for the audio */
507    M4OSA_UInt32                uiOutputAverageVideoBitrate; /**< Average video bitrate of the
508                                                                    output file, computed from
509                                                                    input bitrates, durations,
510                                                                    transitions and cuts */
511
512} M4VSS3GPP_EncodeWriteContext;
513
514
515/**
516 ******************************************************************************
517 * structure    M4VSS3GPP_InternalEditContext
518 * @brief        This structure defines the edit VSS context (private)
519 * @note        This structure is used for all VSS edit operations to store the context
520 ******************************************************************************
521*/
522typedef struct
523{
524    /**
525     * VSS 3GPP main variables */
526    M4VSS3GPP_EditState         State;                    /**< VSS internal state */
527    M4VSS3GPP_EditVideoState    Vstate;
528    M4VSS3GPP_EditAudioState    Astate;
529
530    /**
531     * User Settings (copied, thus owned by VSS3GPP) */
532    M4OSA_UInt8                        uiClipNumber;        /**< Number of element of the clip
533                                                                 list pClipList. */
534    M4VSS3GPP_ClipSettings           *pClipList;            /**< List of the input clips settings
535                                                            Array of uiClipNumber clip settings */
536    M4VSS3GPP_TransitionSettings   *pTransitionList;    /**< List of the transition settings.
537                                                    Array of uiClipNumber-1 transition settings */
538    M4VSS3GPP_EffectSettings       *pEffectsList;        /**< List of the effects settings.
539                                                             Array of nbEffects RC */
540    M4OSA_UInt8                       *pActiveEffectsList;    /**< List of the active effects
541                                                                settings. Array of nbEffects RC */
542    M4OSA_UInt8                        nbEffects;            /**< Numbers of effects RC */
543    M4OSA_UInt8                        nbActiveEffects;    /**< Numbers of active effects RC */
544
545    /**
546     * Input Stuff */
547    M4OSA_UInt8                        uiCurrentClip;        /**< Index of the current clip 1 in
548                                                                    the input clip list */
549    M4VSS3GPP_ClipContext*            pC1;                /**< Context of the current clip 1 */
550    M4VSS3GPP_ClipContext*            pC2;                /**< Context of the current clip 2 */
551
552    /**
553     * Decoder stuff */
554    M4OSA_Double                dOutputFrameDuration;    /**< [Milliseconds] directly related to
555                                                                 output frame rate */
556    M4VIFI_ImagePlane            yuv1[3];            /**< First temporary YUV420 image plane */
557    M4VIFI_ImagePlane            yuv2[3];            /**< Second temporary YUV420 image plane */
558    M4VIFI_ImagePlane            yuv3[3];            /**< Third temporary YUV420 image plane RC */
559    M4VIFI_ImagePlane            yuv4[3];            /**< Fourth temporary YUV420 image plane RC */
560
561    /**
562     * Effect stuff */
563    M4OSA_Bool                    bClip1AtBeginCut;        /**< [Milliseconds] The clip1 is at
564                                                                its begin cut */
565    M4OSA_Int8                    iClip1ActiveEffect;        /**< The index of the active effect
566                                                                    on Clip1 (<0 means none)
567                                                                    (used for video and audio but
568                                                                     not simultaneously) */
569    M4OSA_Int8                    iClip2ActiveEffect;        /**< The index of the active effect
570                                                                 on Clip2 (<0 means none)
571                                                                 (used for video and audio but
572                                                                 not simultaneously) */
573    M4OSA_Bool                    bTransitionEffect;        /**< True if the transition effect
574                                                                 must be applied at the current
575                                                                 time */
576
577    /**
578     * Encoding and Writing operations */
579    M4OSA_Bool                      bSupportSilence;    /**< Flag to know if the output stream can
580                                                             support silence (even if not editable,
581                                                              for example AAC+, but not EVRC) */
582    M4VSS3GPP_EncodeWriteContext    ewc;                /**< Audio and video encode/write stuff */
583    M4OSA_Bool                        bIsMMS;                /**< Boolean used to know if we are
584                                                                processing a file with an output
585                                                                size constraint */
586    M4OSA_UInt32                    uiMMSVideoBitrate;    /**< If in MMS mode,
587                                                                 targeted video bitrate */
588    M4VIDEOEDITING_VideoFramerate    MMSvideoFramerate;    /**< If in MMS mode,
589                                                                 targeted video framerate */
590
591    /**
592     * Filesystem functions */
593    M4OSA_FileReadPointer*        pOsaFileReadPtr;     /**< OSAL file read functions,
594                                                             to be provided by user */
595    M4OSA_FileWriterPointer*    pOsaFileWritPtr;     /**< OSAL file write functions,
596                                                             to be provided by user */
597
598    /**
599     * Interfaces of the used modules */
600    M4VSS3GPP_MediaAndCodecCtxt         ShellAPI;           /**< Filesystem and shell reader,
601                                                                 decoder functions */
602    M4OSA_Bool               bIssecondClip;
603    M4OSA_UInt8              *pActiveEffectsList1;  /**< List of the active effects settings. Array of nbEffects RC */
604    M4OSA_UInt8              nbActiveEffects1;  /**< Numbers of active effects RC */
605    M4OSA_Bool               m_bClipExternalHasStarted;  /**< Flag to indicate that an
606                                                              external effect is active */
607    M4OSA_Int32              iInOutTimeOffset;
608    M4OSA_Bool               bEncodeTillEoF;
609    M4xVSS_EditSettings      xVSS;
610    M4OSA_Context            m_air_context;
611} M4VSS3GPP_InternalEditContext;
612
613
614/**
615 ******************************************************************************
616 * structure    M4VSS3GPP_InternalAudioMixingContext
617 * @brief        This structure defines the audio mixing VSS 3GPP context (private)
618 * @note        This structure is used for all VSS 3GPP audio mixing operations to store
619 *                the context
620 ******************************************************************************
621*/
622typedef struct
623{
624    /**
625     *    VSS main variables */
626    M4VSS3GPP_AudioMixingState State;                    /**< VSS audio mixing internal state */
627
628    /**
629     * Internal copy of the input settings */
630    M4OSA_Int32                iAddCts;                 /**< [Milliseconds] Time, in milliseconds,
631                                                             at which the added audio track is
632                                                              inserted */
633    M4OSA_UInt32               uiBeginLoop;                /**< Describes in milli-second the
634                                                                start time of the loop */
635    M4OSA_UInt32               uiEndLoop;                /**< Describes in milli-second the end
636                                                            time of the loop (0 means no loop) */
637    M4OSA_Bool                 bRemoveOriginal;            /**< If true, the original audio track
638                                                                is not taken into account */
639
640    /**
641     * Input audio/video file */
642    M4VSS3GPP_ClipSettings        InputClipSettings;        /**< Structure internally used to
643                                                                 manage the input 3GPP settings */
644    M4VSS3GPP_ClipContext*        pInputClipCtxt;           /**< Context of the input 3GPP clip */
645
646    /**
647     * Added audio file stuff */
648    M4VSS3GPP_ClipSettings        AddedClipSettings;        /**< Structure internally used to
649                                                                    manage the added settings */
650    M4VSS3GPP_ClipContext*        pAddedClipCtxt;           /**< Context of the added 3GPP clip */
651
652    /**
653     * Audio stuff */
654    M4OSA_Float                    fOrigFactor;            /**< Factor to apply to the original
655                                                                audio track for the mixing */
656    M4OSA_Float                    fAddedFactor;            /**< Factor to apply to the added
657                                                                    audio track for the mixing */
658    M4OSA_Bool                  bSupportSilence;        /**< Flag to know if the output stream can
659                                                             support silence (even if not editable,
660                                                              for example AAC+, but not EVRC) */
661    M4OSA_Bool                  bHasAudio;              /**< Flag to know if we have to delete
662                                                            audio track */
663    M4OSA_Bool                  bAudioMixingIsNeeded;  /**< Flag to know if we have to do mixing */
664
665    /**
666     * Encoding and Writing operations */
667    M4VSS3GPP_EncodeWriteContext    ewc;                /**< Audio and video encode/write stuff */
668
669    /**
670     * Filesystem functions */
671    M4OSA_FileReadPointer*        pOsaFileReadPtr;     /**< OSAL file read functions,
672                                                             to be provided by user */
673    M4OSA_FileWriterPointer*    pOsaFileWritPtr;     /**< OSAL file write functions,
674                                                            to be provided by user */
675
676    /**
677     * Interfaces of the used modules */
678    M4VSS3GPP_MediaAndCodecCtxt ShellAPI;               /**< Filesystem and shell reader,
679                                                                 decoder functions */
680
681    /**
682     * Sample Rate Convertor (SSRC) stuff (needed in case of mixing with != ASF/nb of channels) */
683    M4OSA_Bool                  b_SSRCneeded;        /**< If true, SSRC is needed
684                                                            (!= ASF or nb of channels) */
685    M4OSA_UInt8                 ChannelConversion;    /**< 1=Conversion from Mono to Stereo
686                                                             2=Stereo to Mono, 0=no conversion */
687    SSRC_Instance_t             SsrcInstance;        /**< Context of the Ssrc */
688    SSRC_Scratch_t*             SsrcScratch;        /**< Working memory of the Ssrc */
689    short                       iSsrcNbSamplIn;    /**< Number of sample the Ssrc needs as input */
690    short                       iSsrcNbSamplOut;    /**< Number of sample the Ssrc outputs */
691    M4OSA_MemAddr8              pSsrcBufferIn;        /**< Input of the SSRC */
692    M4OSA_MemAddr8              pSsrcBufferOut;        /**< Output of the SSRC */
693    M4OSA_MemAddr8              pPosInSsrcBufferIn;    /**< Position into the SSRC in buffer */
694    M4OSA_MemAddr8              pPosInSsrcBufferOut;/**< Position into the SSRC out buffer */
695    M4OSA_MemAddr8              pTempBuffer;        /**< Temporary buffer */
696    M4OSA_MemAddr8              pPosInTempBuffer;    /**< Position in temporary buffer */
697    M4OSA_UInt32                minimumBufferIn;    /**< Minimum amount of decoded data to be
698                                                            processed by SSRC and channel
699                                                             convertor */
700    M4OSA_Bool                  b_DuckingNeedeed;
701    M4OSA_Int32                 InDucking_threshold;  /**< Threshold value at which background
702                                                                 music shall duck */
703    M4OSA_Float                 InDucking_lowVolume;  /**< lower the background track to this
704                                                                factor and increase the primary
705                                                                track to inverse of this factor */
706    M4OSA_Float                 lowVolume;
707    M4OSA_Int32                 audioVolumeArray[WINDOW_SIZE]; // store peak audio vol. level
708                                                                  // for duration for WINDOW_SIZE
709    M4OSA_Int32                 audVolArrIndex;
710    M4OSA_Float                 duckingFactor ;     /**< multiply by this factor to bring
711                                                             FADE IN/FADE OUT effect */
712    M4OSA_Float                 fBTVolLevel;
713    M4OSA_Float                 fPTVolLevel;
714    M4OSA_Bool                  bDoDucking;
715    M4OSA_Bool                  bLoop;
716    M4OSA_Bool                  bNoLooping;
717    M4OSA_Context              pLVAudioResampler;
718    M4OSA_Bool                  bjumpflag;
719
720} M4VSS3GPP_InternalAudioMixingContext;
721
722
723/**
724 ******************************************************************************
725 * structure    M4VSS3GPP_InternalExtractPictureContext
726 * @brief        This structure defines the extract picture VSS context (private)
727 * @note        This structure is used for all VSS picture extractions to store the context
728 ******************************************************************************
729*/
730typedef struct
731{
732    /**
733     *    VSS main variables */
734    M4VSS3GPP_ExtractPictureState State;                /**< VSS extract pictureinternal state */
735
736    /**
737     * Input files */
738    M4VSS3GPP_ClipSettings        ClipSettings;            /**< Structure internally used to
739                                                                manage the input 3FPP settings */
740    M4VSS3GPP_ClipContext*        pInputClipCtxt;           /**< Context of the input 3GPP clip */
741
742    /**
743     * Settings */
744    M4OSA_Int32                    iExtractCts;            /**< [Milliseconds] Cts of the AU
745                                                                to be extracted */
746
747    /**
748     * Video stuff */
749    M4VIFI_ImagePlane            decPlanes[3];            /**< Decoded YUV420 picture plane */
750    M4OSA_UInt32                uiVideoWidth;            /**< Decoded image width */
751    M4OSA_UInt32                uiVideoHeight;            /**< Decoded image height */
752
753    /*
754     * Decoder info */
755    M4OSA_Int32                iDecCts;      /**< [Milliseconds] Decoded AU Cts */
756    M4OSA_Bool                 bJumpFlag;     /**< 1 if a jump has been made */
757    M4OSA_Int32                iDeltaTime;   /**< [Milliseconds] Time between previous RAP and
758                                                     picture to extract */
759    M4OSA_Int32                iGap;         /**< [Milliseconds] Time between jump AU and
760                                                    extraction time */
761    M4OSA_UInt32               uiStep;          /**< [Milliseconds] Progress bar time increment */
762
763    /**
764     * Filesystem functions */
765     /**< OSAL file read functions, to be provided by user */
766    M4OSA_FileReadPointer*        pOsaFileReadPtr;
767    /**< OSAL file write functions, to be provided by user */
768    M4OSA_FileWriterPointer*    pOsaFileWritPtr;
769
770    M4OSA_Bool                    bClipOpened;
771} M4VSS3GPP_InternalExtractPictureContext;
772
773
774#ifdef __cplusplus
775}
776#endif
777
778#endif /* __M4VSS3GPP_INTERNALTYPES_H__ */
779
780