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  ******************************************************************************
     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
     56 extern "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 
     67 typedef 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 }
     78 M4VSS3GPP_EditState;
     79 
     80 typedef 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 }
     98 M4VSS3GPP_EditVideoState;
     99 
    100 typedef 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 }
    108 M4VSS3GPP_EditAudioState;
    109 
    110 
    111 /**
    112  ******************************************************************************
    113  * enum            M4VSS3GPP_ClipStatus
    114  * @brief        Status of the clip.
    115  ******************************************************************************
    116 */
    117 typedef 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 }
    124 M4VSS3GPP_ClipStatus;
    125 
    126 
    127 /**
    128  ******************************************************************************
    129  * enum            M4VSS3GPP_ClipCurrentEffect
    130  * @brief        Current effect applied to the clip.
    131  ******************************************************************************
    132 */
    133 typedef 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 }
    139 M4VSS3GPP_ClipCurrentEffect;
    140 
    141 
    142 /**
    143  ******************************************************************************
    144  * enum            M4VSS3GPP_AudioMixingState
    145  * @brief        Main state machine of the VSS audio mixing operation.
    146  ******************************************************************************
    147 */
    148 typedef 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 }
    157 M4VSS3GPP_AudioMixingState;
    158 
    159 
    160 /**
    161  ******************************************************************************
    162  * enum            M4VSS3GPP_ExtractPictureState
    163  * @brief        Main state machine of the VSS picture extraction.
    164  ******************************************************************************
    165 */
    166 typedef 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 }
    175 M4VSS3GPP_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 */
    184 typedef 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  */
    198 typedef 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 */
    218 typedef 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 */
    287 typedef 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 */
    391 enum
    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 */
    406 typedef 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_Int32                 outputVideoProfile;  /**< Output video profile */
    424     M4OSA_Int32                 outputVideoLevel;   /**< Output video level */
    425     M4OSA_UInt32                uiVideoBitrate;     /**< Average video bitrate of the output file,
    426                                                          computed from input bitrates, durations,
    427                                                           transitions and cuts */
    428     M4OSA_UInt32                uiVideoWidth;            /**< Output image width */
    429     M4OSA_UInt32                uiVideoHeight;            /**< Output image height */
    430     M4OSA_UInt32                uiVideoTimeScale;        /**< Time scale to use for the encoding
    431                                                             of the transition (if MPEG-4) */
    432     M4OSA_Bool                    bVideoDataPartitioning;    /**< Data partitioning to use for the
    433                                                                  encoding of the transition
    434                                                                  (if MPEG-4) */
    435     M4OSA_MemAddr8                pVideoOutputDsi;        /**< Decoder Specific Info of the output
    436                                                                  MPEG-4 track */
    437     M4OSA_UInt16                uiVideoOutputDsiSize;    /**< Size of the Decoder Specific Info
    438                                                                 of the output MPEG-4 track */
    439     /**
    440      * Output Audio Stream Stuff */
    441     M4SYS_StreamType            AudioStreamType;        /**< Type of the output audio stream */
    442     M4OSA_UInt32                uiNbChannels;           /**< Number of channels in the output
    443                                                             stream (1=mono, 2=stereo) */
    444     M4OSA_UInt32                uiAudioBitrate;         /**< Audio average bitrate (in bps) */
    445     M4OSA_UInt32                uiSamplingFrequency;    /**< Sampling audio frequency (8000 for
    446                                                                 amr, 16000 or more for aac) */
    447     M4OSA_MemAddr8                pAudioOutputDsi;        /**< Decoder Specific Info of the
    448                                                                 output audio track */
    449     M4OSA_UInt16                uiAudioOutputDsiSize;    /**< Size of the Decoder Specific Info
    450                                                                 of the output audio track */
    451 
    452     /**
    453      * Audio Encoder stuff */
    454     M4OSA_Context                   pAudioEncCtxt;        /**< Context of the audio encoder */
    455     M4ENCODER_AudioDecSpecificInfo  pAudioEncDSI;       /**< Decoder specific info built by the
    456                                                                 encoder */
    457     M4ENCODER_AudioParams           AudioEncParams;     /**< Config of the audio encoder */
    458 
    459     /**
    460      * Silence frame stuff */
    461     M4OSA_UInt32                uiSilencePcmSize;       /**< Size to reserve to store a pcm full
    462                                                              of zeros compatible with master clip
    463                                                              stream type */
    464     M4OSA_UInt8*                pSilenceFrameData;      /**< Pointer to silence frame data
    465                                                                 compatible with master clip
    466                                                                 stream type */
    467     M4OSA_UInt32                uiSilenceFrameSize;     /**< Size of silence frame data compatible
    468                                                              with master clip stream type */
    469     M4OSA_Int32                 iSilenceFrameDuration;  /**< [Timescale] Duration of silence frame
    470                                                                  data compatible with master clip
    471                                                                  stream type */
    472     M4OSA_Double                scale_audio;            /**< frequency / 1000.0 */
    473 
    474     /**
    475      * Video Encoder stuff */
    476     M4ENCODER_Context            pEncContext;            /**< Context of the encoder */
    477     M4WRITER_DataInterface        OurWriterDataInterface;    /**< Our own implementation of the
    478                                                                     writer interface, to give to
    479                                                                     the encoder shell */
    480     M4OSA_MemAddr32                pDummyAuBuffer;            /**< Buffer given to the encoder for
    481                                                                    it to write AUs we don't want
    482                                                                     in the output */
    483     M4OSA_Int32                    iMpeg4GovOffset;        /**< Clip GOV offset in ms between
    484                                                                  video and system time */
    485     M4OSA_ERR                    VppError;                /**< Error for VPP are masked by Video
    486                                                                Encoder, so we must remember it */
    487     M4OSA_UInt32                encoderState;
    488 
    489     /**
    490      * Writer stuff */
    491     M4WRITER_Context            p3gpWriterContext;        /**< Context of the 3GPP writer module */
    492     M4SYS_StreamDescription        WriterVideoStream;        /**< Description of the written
    493                                                                     video stream */
    494     M4SYS_StreamDescription        WriterAudioStream;        /**< Description of the written
    495                                                                     audio stream */
    496     M4WRITER_StreamVideoInfos    WriterVideoStreamInfo;    /**< Video properties of the written
    497                                                                      video stream */
    498     M4WRITER_StreamAudioInfos    WriterAudioStreamInfo;    /**< Audio properties of the written
    499                                                                     audio stream */
    500     M4SYS_AccessUnit            WriterVideoAU;            /**< Written video access unit */
    501     M4SYS_AccessUnit            WriterAudioAU;            /**< Written audio access unit */
    502     M4OSA_UInt32                uiVideoMaxAuSize;        /**< Max AU size set to the writer
    503                                                                 for the video */
    504     M4OSA_UInt32                uiAudioMaxAuSize;        /**< Max AU size set to the writer
    505                                                                 for the audio */
    506     M4OSA_UInt32                uiOutputAverageVideoBitrate; /**< Average video bitrate of the
    507                                                                     output file, computed from
    508                                                                     input bitrates, durations,
    509                                                                     transitions and cuts */
    510 
    511 } M4VSS3GPP_EncodeWriteContext;
    512 
    513 
    514 /**
    515  ******************************************************************************
    516  * structure    M4VSS3GPP_InternalEditContext
    517  * @brief        This structure defines the edit VSS context (private)
    518  * @note        This structure is used for all VSS edit operations to store the context
    519  ******************************************************************************
    520 */
    521 typedef struct
    522 {
    523     /**
    524      * VSS 3GPP main variables */
    525     M4VSS3GPP_EditState         State;                    /**< VSS internal state */
    526     M4VSS3GPP_EditVideoState    Vstate;
    527     M4VSS3GPP_EditAudioState    Astate;
    528 
    529     /**
    530      * User Settings (copied, thus owned by VSS3GPP) */
    531     M4OSA_UInt8                        uiClipNumber;        /**< Number of element of the clip
    532                                                                  list pClipList. */
    533     M4VSS3GPP_ClipSettings           *pClipList;            /**< List of the input clips settings
    534                                                             Array of uiClipNumber clip settings */
    535     M4VSS3GPP_TransitionSettings   *pTransitionList;    /**< List of the transition settings.
    536                                                     Array of uiClipNumber-1 transition settings */
    537     M4VSS3GPP_EffectSettings       *pEffectsList;        /**< List of the effects settings.
    538                                                              Array of nbEffects RC */
    539     M4OSA_UInt8                       *pActiveEffectsList;    /**< List of the active effects
    540                                                                 settings. Array of nbEffects RC */
    541     M4OSA_UInt8                        nbEffects;            /**< Numbers of effects RC */
    542     M4OSA_UInt8                        nbActiveEffects;    /**< Numbers of active effects RC */
    543 
    544     /**
    545      * Input Stuff */
    546     M4OSA_UInt8                        uiCurrentClip;        /**< Index of the current clip 1 in
    547                                                                     the input clip list */
    548     M4VSS3GPP_ClipContext*            pC1;                /**< Context of the current clip 1 */
    549     M4VSS3GPP_ClipContext*            pC2;                /**< Context of the current clip 2 */
    550 
    551     /**
    552      * Decoder stuff */
    553     M4OSA_Double                dOutputFrameDuration;    /**< [Milliseconds] directly related to
    554                                                                  output frame rate */
    555     M4VIFI_ImagePlane            yuv1[3];            /**< First temporary YUV420 image plane */
    556     M4VIFI_ImagePlane            yuv2[3];            /**< Second temporary YUV420 image plane */
    557     M4VIFI_ImagePlane            yuv3[3];            /**< Third temporary YUV420 image plane RC */
    558     M4VIFI_ImagePlane            yuv4[3];            /**< Fourth temporary YUV420 image plane RC */
    559 
    560     /**
    561      * Effect stuff */
    562     M4OSA_Bool                    bClip1AtBeginCut;        /**< [Milliseconds] The clip1 is at
    563                                                                 its begin cut */
    564     M4OSA_Int8                    iClip1ActiveEffect;        /**< The index of the active effect
    565                                                                     on Clip1 (<0 means none)
    566                                                                     (used for video and audio but
    567                                                                      not simultaneously) */
    568     M4OSA_Int8                    iClip2ActiveEffect;        /**< The index of the active effect
    569                                                                  on Clip2 (<0 means none)
    570                                                                  (used for video and audio but
    571                                                                  not simultaneously) */
    572     M4OSA_Bool                    bTransitionEffect;        /**< True if the transition effect
    573                                                                  must be applied at the current
    574                                                                  time */
    575 
    576     /**
    577      * Encoding and Writing operations */
    578     M4OSA_Bool                      bSupportSilence;    /**< Flag to know if the output stream can
    579                                                              support silence (even if not editable,
    580                                                               for example AAC+, but not EVRC) */
    581     M4VSS3GPP_EncodeWriteContext    ewc;                /**< Audio and video encode/write stuff */
    582     M4OSA_Bool                        bIsMMS;                /**< Boolean used to know if we are
    583                                                                 processing a file with an output
    584                                                                 size constraint */
    585     M4OSA_UInt32                    uiMMSVideoBitrate;    /**< If in MMS mode,
    586                                                                  targeted video bitrate */
    587     M4VIDEOEDITING_VideoFramerate    MMSvideoFramerate;    /**< If in MMS mode,
    588                                                                  targeted video framerate */
    589 
    590     /**
    591      * Filesystem functions */
    592     M4OSA_FileReadPointer*        pOsaFileReadPtr;     /**< OSAL file read functions,
    593                                                              to be provided by user */
    594     M4OSA_FileWriterPointer*    pOsaFileWritPtr;     /**< OSAL file write functions,
    595                                                              to be provided by user */
    596 
    597     /**
    598      * Interfaces of the used modules */
    599     M4VSS3GPP_MediaAndCodecCtxt         ShellAPI;           /**< Filesystem and shell reader,
    600                                                                  decoder functions */
    601     M4OSA_Bool               bIssecondClip;
    602     M4OSA_UInt8              *pActiveEffectsList1;  /**< List of the active effects settings. Array of nbEffects RC */
    603     M4OSA_UInt8              nbActiveEffects1;  /**< Numbers of active effects RC */
    604     M4OSA_Bool               m_bClipExternalHasStarted;  /**< Flag to indicate that an
    605                                                               external effect is active */
    606     M4OSA_Int32              iInOutTimeOffset;
    607     M4OSA_Bool               bEncodeTillEoF;
    608     M4xVSS_EditSettings      xVSS;
    609     M4OSA_Context            m_air_context;
    610 
    611     M4OSA_Bool bClip1ActiveFramingEffect; /**< Overlay flag for clip1 */
    612     M4OSA_Bool bClip2ActiveFramingEffect; /**< Overlay flag for clip2, used in transition */
    613 } M4VSS3GPP_InternalEditContext;
    614 
    615 
    616 /**
    617  ******************************************************************************
    618  * structure    M4VSS3GPP_InternalAudioMixingContext
    619  * @brief        This structure defines the audio mixing VSS 3GPP context (private)
    620  * @note        This structure is used for all VSS 3GPP audio mixing operations to store
    621  *                the context
    622  ******************************************************************************
    623 */
    624 typedef struct
    625 {
    626     /**
    627      *    VSS main variables */
    628     M4VSS3GPP_AudioMixingState State;                    /**< VSS audio mixing internal state */
    629 
    630     /**
    631      * Internal copy of the input settings */
    632     M4OSA_Int32                iAddCts;                 /**< [Milliseconds] Time, in milliseconds,
    633                                                              at which the added audio track is
    634                                                               inserted */
    635     M4OSA_UInt32               uiBeginLoop;                /**< Describes in milli-second the
    636                                                                 start time of the loop */
    637     M4OSA_UInt32               uiEndLoop;                /**< Describes in milli-second the end
    638                                                             time of the loop (0 means no loop) */
    639     M4OSA_Bool                 bRemoveOriginal;            /**< If true, the original audio track
    640                                                                 is not taken into account */
    641 
    642     /**
    643      * Input audio/video file */
    644     M4VSS3GPP_ClipSettings        InputClipSettings;        /**< Structure internally used to
    645                                                                  manage the input 3GPP settings */
    646     M4VSS3GPP_ClipContext*        pInputClipCtxt;           /**< Context of the input 3GPP clip */
    647 
    648     /**
    649      * Added audio file stuff */
    650     M4VSS3GPP_ClipSettings        AddedClipSettings;        /**< Structure internally used to
    651                                                                     manage the added settings */
    652     M4VSS3GPP_ClipContext*        pAddedClipCtxt;           /**< Context of the added 3GPP clip */
    653 
    654     /**
    655      * Audio stuff */
    656     M4OSA_Float                    fOrigFactor;            /**< Factor to apply to the original
    657                                                                 audio track for the mixing */
    658     M4OSA_Float                    fAddedFactor;            /**< Factor to apply to the added
    659                                                                     audio track for the mixing */
    660     M4OSA_Bool                  bSupportSilence;        /**< Flag to know if the output stream can
    661                                                              support silence (even if not editable,
    662                                                               for example AAC+, but not EVRC) */
    663     M4OSA_Bool                  bHasAudio;              /**< Flag to know if we have to delete
    664                                                             audio track */
    665     M4OSA_Bool                  bAudioMixingIsNeeded;  /**< Flag to know if we have to do mixing */
    666 
    667     /**
    668      * Encoding and Writing operations */
    669     M4VSS3GPP_EncodeWriteContext    ewc;                /**< Audio and video encode/write stuff */
    670 
    671     /**
    672      * Filesystem functions */
    673     M4OSA_FileReadPointer*        pOsaFileReadPtr;     /**< OSAL file read functions,
    674                                                              to be provided by user */
    675     M4OSA_FileWriterPointer*    pOsaFileWritPtr;     /**< OSAL file write functions,
    676                                                             to be provided by user */
    677 
    678     /**
    679      * Interfaces of the used modules */
    680     M4VSS3GPP_MediaAndCodecCtxt ShellAPI;               /**< Filesystem and shell reader,
    681                                                                  decoder functions */
    682 
    683     /**
    684      * Sample Rate Convertor (SSRC) stuff (needed in case of mixing with != ASF/nb of channels) */
    685     M4OSA_Bool                  b_SSRCneeded;        /**< If true, SSRC is needed
    686                                                             (!= ASF or nb of channels) */
    687     M4OSA_UInt8                 ChannelConversion;    /**< 1=Conversion from Mono to Stereo
    688                                                              2=Stereo to Mono, 0=no conversion */
    689     SSRC_Instance_t             SsrcInstance;        /**< Context of the Ssrc */
    690     SSRC_Scratch_t*             SsrcScratch;        /**< Working memory of the Ssrc */
    691     short                       iSsrcNbSamplIn;    /**< Number of sample the Ssrc needs as input */
    692     short                       iSsrcNbSamplOut;    /**< Number of sample the Ssrc outputs */
    693     M4OSA_MemAddr8              pSsrcBufferIn;        /**< Input of the SSRC */
    694     M4OSA_MemAddr8              pSsrcBufferOut;        /**< Output of the SSRC */
    695     M4OSA_MemAddr8              pPosInSsrcBufferIn;    /**< Position into the SSRC in buffer */
    696     M4OSA_MemAddr8              pPosInSsrcBufferOut;/**< Position into the SSRC out buffer */
    697     M4OSA_MemAddr8              pTempBuffer;        /**< Temporary buffer */
    698     M4OSA_MemAddr8              pPosInTempBuffer;    /**< Position in temporary buffer */
    699     M4OSA_UInt32                minimumBufferIn;    /**< Minimum amount of decoded data to be
    700                                                             processed by SSRC and channel
    701                                                              convertor */
    702     M4OSA_Bool                  b_DuckingNeedeed;
    703     M4OSA_Int32                 InDucking_threshold;  /**< Threshold value at which background
    704                                                                  music shall duck */
    705     M4OSA_Float                 InDucking_lowVolume;  /**< lower the background track to this
    706                                                                 factor and increase the primary
    707                                                                 track to inverse of this factor */
    708     M4OSA_Float                 lowVolume;
    709     M4OSA_Int32                 audioVolumeArray[WINDOW_SIZE]; // store peak audio vol. level
    710                                                                   // for duration for WINDOW_SIZE
    711     M4OSA_Int32                 audVolArrIndex;
    712     M4OSA_Float                 duckingFactor ;     /**< multiply by this factor to bring
    713                                                              FADE IN/FADE OUT effect */
    714     M4OSA_Float                 fBTVolLevel;
    715     M4OSA_Float                 fPTVolLevel;
    716     M4OSA_Bool                  bDoDucking;
    717     M4OSA_Bool                  bLoop;
    718     M4OSA_Bool                  bNoLooping;
    719     M4OSA_Context              pLVAudioResampler;
    720     M4OSA_Bool                  bjumpflag;
    721 
    722 } M4VSS3GPP_InternalAudioMixingContext;
    723 
    724 
    725 /**
    726  ******************************************************************************
    727  * structure    M4VSS3GPP_InternalExtractPictureContext
    728  * @brief        This structure defines the extract picture VSS context (private)
    729  * @note        This structure is used for all VSS picture extractions to store the context
    730  ******************************************************************************
    731 */
    732 typedef struct
    733 {
    734     /**
    735      *    VSS main variables */
    736     M4VSS3GPP_ExtractPictureState State;                /**< VSS extract pictureinternal state */
    737 
    738     /**
    739      * Input files */
    740     M4VSS3GPP_ClipSettings        ClipSettings;            /**< Structure internally used to
    741                                                                 manage the input 3FPP settings */
    742     M4VSS3GPP_ClipContext*        pInputClipCtxt;           /**< Context of the input 3GPP clip */
    743 
    744     /**
    745      * Settings */
    746     M4OSA_Int32                    iExtractCts;            /**< [Milliseconds] Cts of the AU
    747                                                                 to be extracted */
    748 
    749     /**
    750      * Video stuff */
    751     M4VIFI_ImagePlane            decPlanes[3];            /**< Decoded YUV420 picture plane */
    752     M4OSA_UInt32                uiVideoWidth;            /**< Decoded image width */
    753     M4OSA_UInt32                uiVideoHeight;            /**< Decoded image height */
    754 
    755     /*
    756      * Decoder info */
    757     M4OSA_Int32                iDecCts;      /**< [Milliseconds] Decoded AU Cts */
    758     M4OSA_Bool                 bJumpFlag;     /**< 1 if a jump has been made */
    759     M4OSA_Int32                iDeltaTime;   /**< [Milliseconds] Time between previous RAP and
    760                                                      picture to extract */
    761     M4OSA_Int32                iGap;         /**< [Milliseconds] Time between jump AU and
    762                                                     extraction time */
    763     M4OSA_UInt32               uiStep;          /**< [Milliseconds] Progress bar time increment */
    764 
    765     /**
    766      * Filesystem functions */
    767      /**< OSAL file read functions, to be provided by user */
    768     M4OSA_FileReadPointer*        pOsaFileReadPtr;
    769     /**< OSAL file write functions, to be provided by user */
    770     M4OSA_FileWriterPointer*    pOsaFileWritPtr;
    771 
    772     M4OSA_Bool                    bClipOpened;
    773 } M4VSS3GPP_InternalExtractPictureContext;
    774 
    775 
    776 #ifdef __cplusplus
    777 }
    778 #endif
    779 
    780 #endif /* __M4VSS3GPP_INTERNALTYPES_H__ */
    781 
    782