M4MCS_InternalTypes.h revision 100d01836041713337dd9532e417fb010bfb381c
1/*
2 * Copyright (C) 2004-2011 NXP Software
3 * Copyright (C) 2011 The Android Open Source Project
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 *      http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 */
17/**
18 *************************************************************************
19 * @file   M4MCS_API.h
20 * @brief  MCS internal types and structures definitions
21 * @note   This header file is not public
22 *************************************************************************
23 **/
24
25#ifndef __M4MCS_INTERNALTYPES_H__
26#define __M4MCS_INTERNALTYPES_H__
27
28/**
29 *    MCS public API and types */
30#include "M4MCS_API.h"
31#include "M4MCS_ErrorCodes.h"
32
33#include "NXPSW_CompilerSwitches.h"
34
35/** Determine absolute value of a. */
36#define M4MCS_ABS(a)               ( ( (a) < (0) ) ? (-(a)) : (a) )
37
38
39#define Y_PLANE_BORDER_VALUE    0x00
40#define U_PLANE_BORDER_VALUE    0x80
41#define V_PLANE_BORDER_VALUE    0x80
42
43
44/**
45 *    Internally used modules */
46#include "M4READER_3gpCom.h"        /**< Read 3GPP file     */
47#include "M4DECODER_Common.h"       /**< Decode video       */
48#include "M4VIFI_FiltersAPI.h"      /**< Video resize       */
49#include "M4AD_Common.h"            /**< Decoder audio      */
50#include "SSRC.h"                   /**< SSRC               */
51#include "From2iToMono_16.h"        /**< Stereo to Mono     */
52#include "MonoTo2I_16.h"            /**< Mono to Stereo     */
53#include "M4ENCODER_AudioCommon.h"  /**< Encode audio       */
54#include "M4WRITER_common.h"        /**< Writer common interface */
55#include "M4ENCODER_common.h"
56
57/**
58 *  Instead of including AAC core properties, it is better to redefine the needed type
59 *  AAC_DEC_STREAM_PROPS
60 *  In case of external AAC decoder, it will be necessary to put this type as public
61 */
62
63/**
64 ******************************************************************************
65 * struct AAC_DEC_STREAM_PROPS
66 * @brief AAC Stream properties
67 * @Note aNoChan and aSampFreq are used for parsing even the user parameters
68 *        are different.  User parameters will be input for the output behaviour
69 *        of the decoder whereas for parsing bitstream properties are used.
70 ******************************************************************************
71 */
72typedef struct {
73  M4OSA_Int32 aAudioObjectType;     /**< Audio object type of the stream - in fact
74                                         the type found in the Access Unit parsed */
75  M4OSA_Int32 aNumChan;             /**< number of channels (=1(mono) or =2(stereo))
76                                         as indicated by input bitstream*/
77  M4OSA_Int32 aSampFreq;            /**< sampling frequency in Hz */
78  M4OSA_Int32 aExtensionSampFreq;   /**< extended sampling frequency in Hz, = 0 is
79                                         no extended frequency */
80  M4OSA_Int32 aSBRPresent;          /**< presence=1/absence=0 of SBR */
81  M4OSA_Int32 aPSPresent;           /**< presence=1/absence=0 of PS */
82  M4OSA_Int32 aMaxPCMSamplesPerCh;  /**< max number of PCM samples per channel */
83} AAC_DEC_STREAM_PROPS;
84
85/**
86 ******************************************************************************
87 * @brief        Codecs registration same as in VPS and VES, so less mapping
88 *              is required toward MCS api types
89 ******************************************************************************
90 */
91typedef struct
92{
93    M4WRITER_GlobalInterface* pGlobalFcts;    /**< open, close, setoption,etc... functions */
94    M4WRITER_DataInterface*    pDataFcts;        /**< data manipulation functions */
95} M4MCS_WriterInterface;
96
97/**
98 ******************************************************************************
99 * enum            M4MCS_States
100 * @brief        Main state machine of the MCS.
101 ******************************************************************************
102 */
103typedef enum
104{
105    M4MCS_kState_CREATED,           /**< M4MCS_init has been called                */
106    M4MCS_kState_OPENED,            /**< M4MCS_open has been called                */
107    M4MCS_kState_SET,               /**< All mandatory parameters have been set    */
108    M4MCS_kState_READY,             /**< All optionnal parameters have been set    */
109    M4MCS_kState_BEGINVIDEOJUMP,    /**< Must jump to the Iframe before the begin cut */
110    M4MCS_kState_BEGINVIDEODECODE,  /**< Must decode up to the begin cut        */
111    M4MCS_kState_PROCESSING,        /**< Step can be called                        */
112    M4MCS_kState_PAUSED,            /**< Paused, Resume can be called            */
113    M4MCS_kState_FINISHED,          /**< Transcoding is finished                */
114    M4MCS_kState_CLOSED             /**< Output file has been created            */
115} M4MCS_States;
116
117/**
118 ******************************************************************************
119 * enum            M4MCS_StreamState
120 * @brief        State of a media stream encoding (audio or video).
121 ******************************************************************************
122 */
123typedef enum
124{
125    M4MCS_kStreamState_NOSTREAM  = 0,    /**< No stream present                    */
126    M4MCS_kStreamState_STARTED   = 1,    /**< The stream encoding is in progress */
127    M4MCS_kStreamState_FINISHED  = 2    /**< The stream has finished encoding    */
128} M4MCS_StreamState;
129
130#ifdef TIMESCALE_BUG
131/**
132 ******************************************************************************
133 * enum            M4MCS_VolParse
134 * @brief        VOL parsing results needed for VOP parsing
135 ******************************************************************************
136 */
137typedef struct
138{
139    M4OSA_UInt8 video_object_layer_shape;
140    M4OSA_UInt8 sprite_enable;
141    M4OSA_UInt8 reduced_resolution_vop_enable;
142    M4OSA_UInt8 scalability;
143    M4OSA_UInt8 enhancement_type;
144    M4OSA_UInt8 complexity_estimation_disable;
145    M4OSA_UInt8 interlaced;
146    M4OSA_UInt8 sprite_warping_points;
147    M4OSA_UInt8 sprite_brightness_change;
148    M4OSA_UInt8 quant_precision;
149
150} M4MCS_VolParse;
151#endif
152
153/**
154 ******************************************************************************
155 * enum            anonymous enum
156 * @brief        enum to keep track of the encoder state
157 ******************************************************************************
158 */
159enum
160{
161    M4MCS_kNoEncoder,
162    M4MCS_kEncoderClosed,
163    M4MCS_kEncoderStopped,
164    M4MCS_kEncoderRunning
165};
166
167/**
168 ******************************************************************************
169 * structure    M4MCS_InternalContext
170 * @brief        This structure defines the MCS context (private)
171 * @note        This structure is used for all MCS calls to store the context
172 ******************************************************************************
173 */
174typedef struct
175{
176    M4OSA_UInt32    bitPos;
177                 /* bit count of number of bits used so far */
178
179    M4OSA_UInt8   *streamBuffer;
180                /* Bitstream Buffer */
181
182    M4OSA_UInt32    byteCnt;
183                /* Number of Bytes written in Bitstream buffer*/
184
185    M4OSA_UInt32    currBuff;
186                /* Current buffer holds, 4bytes of bitstream*/
187
188    M4OSA_UInt8   prevByte;
189                /* Previous byte written in the buffer */
190
191    M4OSA_UInt8   prevPrevByte;
192                /* Previous to previous byte written in the buffer */
193
194}NSWAVC_bitStream_t_MCS;
195
196#define _MAXnum_slice_groups  8
197#define _MAXnum_ref_frames_in_pic_order_cnt_cycle  256
198
199typedef struct
200{
201  M4OSA_UInt32  level_idc_index;
202  M4OSA_UInt32  MaxFrameNum;
203  M4OSA_UInt32  expectedDeltaPerPicOrderCntCycle;
204  M4OSA_Int32   MaxPicOrderCntLsb;
205  M4OSA_Int32   max_dec_frame_buffering;
206
207  /* (pic_order_cnt_type == 1) */
208  M4OSA_Int32   offset_for_non_ref_pic;
209  M4OSA_Int32   offset_for_top_to_bottom_field;
210  M4OSA_Int32   frame_crop_left_offset;
211  M4OSA_Int32   frame_crop_right_offset;
212  M4OSA_Int32   frame_crop_top_offset;
213  M4OSA_Int32   frame_crop_bottom_offset;
214  M4OSA_Int32   offset_for_ref_frame[_MAXnum_ref_frames_in_pic_order_cnt_cycle];
215
216  M4OSA_UInt16 PicWidthInMbs;
217  M4OSA_UInt16 FrameHeightInMbs;
218  M4OSA_UInt16  pic_width_in_mbs_minus1;
219  M4OSA_UInt16  pic_height_in_map_units_minus1;
220
221#ifdef _CAP_FMO_
222  M4OSA_UInt16 NumSliceGroupMapUnits;
223  M4OSA_UInt16 MaxPicSizeInMbs;
224#endif /*_CAP_FMO_*/
225
226  M4OSA_UInt8   profile_idc;
227  M4OSA_UInt8   reserved_zero_4bits;
228  M4OSA_UInt8   level_idc;
229  M4OSA_UInt8   seq_parameter_set_id;
230  M4OSA_UInt8   log2_max_frame_num_minus4;
231  M4OSA_UInt8   pic_order_cnt_type;
232  /* if(pic_order_cnt_type == 0) */
233  M4OSA_UInt8   log2_max_pic_order_cnt_lsb_minus4;
234
235  M4OSA_UInt8   num_ref_frames_in_pic_order_cnt_cycle;
236  /* for( i = 0; i < num_ref_frames_in_pic_order_cnt_cycle; i++ ) */
237  M4OSA_UInt8   num_ref_frames;
238
239  M4OSA_Bool    constraint_set0_flag;
240  M4OSA_Bool    constraint_set1_flag;
241  M4OSA_Bool    constraint_set2_flag;
242  M4OSA_Bool    constraint_set3_flag;
243  M4OSA_Bool    delta_pic_order_always_zero_flag;
244  M4OSA_Bool    gaps_in_frame_num_value_allowed_flag;
245  M4OSA_Bool    frame_mbs_only_flag;
246  M4OSA_Bool    mb_adaptive_frame_field_flag;
247  M4OSA_Bool    direct_8x8_inference_flag;
248  M4OSA_Bool    frame_cropping_flag;
249  M4OSA_Bool    vui_parameters_present_flag;
250  M4OSA_Bool    Active;
251
252  /* vui_seq_parameters_t vui_seq_parameters; */
253} ComSequenceParameterSet_t_MCS;
254
255typedef struct
256{
257  M4OSA_Int16       pic_init_qp_minus26;
258  M4OSA_Int16       pic_init_qs_minus26;
259  M4OSA_Int16       chroma_qp_index_offset;
260
261//#ifdef _CAP_FMO_
262  /* if( slice_group_map_type = = 0 ) */
263  M4OSA_UInt16      run_length_minus1[_MAXnum_slice_groups];
264  /* else if( slice_group_map_type = = 2 ) */
265  M4OSA_UInt16      top_left[_MAXnum_slice_groups];
266  M4OSA_UInt16      bottom_right[_MAXnum_slice_groups];
267  /* else if( slice_group_map_type = = 6 ) */
268  M4OSA_UInt16      pic_size_in_map_units_minus1;
269  M4OSA_UInt16      slice_group_change_rate_minus1;
270
271  M4OSA_UInt16 FirstMbInSliceGroup[_MAXnum_slice_groups];
272  M4OSA_UInt16 LastMbInSliceGroup[_MAXnum_slice_groups];
273
274
275  M4OSA_UInt8  *slice_group_id;
276  M4OSA_UInt8  *MapUnitToSliceGroupMap;
277  M4OSA_UInt8  *MbToSliceGroupMap;
278  M4OSA_UInt16  NumSliceGroupMapUnits;
279
280  M4OSA_UInt8       slice_group_map_type;
281  /* else if( slice_group_map_type = = 3 || 4 || 5 */
282  M4OSA_Bool        slice_group_change_direction_flag;
283  M4OSA_Bool   map_initialized;
284// #endif /*_CAP_FMO_*/
285
286  M4OSA_UInt8       pic_parameter_set_id;
287  M4OSA_UInt8       seq_parameter_set_id;
288  M4OSA_UInt8      num_ref_idx_l0_active_minus1;
289  M4OSA_UInt8      num_ref_idx_l1_active_minus1;
290  M4OSA_UInt8       weighted_bipred_idc;
291  M4OSA_UInt8       num_slice_groups_minus1;
292
293  M4OSA_Bool        entropy_coding_mode_flag;
294  /* if( pic_order_cnt_type < 2 )  in the sequence parameter set */
295  M4OSA_Bool        pic_order_present_flag;
296  M4OSA_Bool        weighted_pred_flag;
297  M4OSA_Bool        deblocking_filter_control_present_flag;
298  M4OSA_Bool        constrained_intra_pred_flag;
299  M4OSA_Bool        redundant_pic_cnt_present_flag;
300  M4OSA_Bool    Active;
301
302  ComSequenceParameterSet_t_MCS *p_active_sps;
303} ComPictureParameterSet_t_MCS;
304
305typedef struct
306{
307      M4OSA_UInt32 bitPos;                /*!< bit position in buffer */
308      M4OSA_UInt32 totalBits;             /*!< bit position in file (total bits read so far) */
309
310      M4OSA_UInt32 lastTotalBits;         /*!< bit position in file of the last VOP */
311      M4OSA_UInt32 numBitsInBuffer;       /*!< number of bits in buffer */
312      M4OSA_UInt32 readableBytesInBuffer; /*!< number of bytes that can be read in decoder buffer*/
313      M4OSA_UInt32 maxBufferSize;         /*!< max buffer size in bit units */
314      M4OSA_UInt8  *Buffer;               /*!< char buffer at reading from file */
315      M4OSA_Int32     i8BitCnt;
316      M4OSA_UInt32     ui32TempBuff;
317      M4OSA_Int8*pui8BfrPtr;
318      M4OSA_UInt32    ui32LastTwoBytes;  /*!< stores the last read two bytes */
319} ComBitStreamMCS_t;
320
321
322typedef struct
323{
324
325    M4OSA_Int32 prev_frame_num;
326    M4OSA_Int32 cur_frame_num;
327    M4OSA_Int32 prev_new_frame_num;
328    M4OSA_Int32 log2_max_frame_num_minus4;
329    M4OSA_Int32 is_done;
330    M4OSA_Int32 is_first;
331    M4OSA_Int32 frame_count;
332    M4OSA_Int32 frame_mod_count;
333    M4OSA_Int32 POC_lsb;
334    M4OSA_Int32 POC_lsb_mod;
335
336
337    M4OSA_UInt32    m_Num_Bytes_NALUnitLength;
338
339    M4OSA_UInt8*    m_pDecoderSpecificInfo;   /**< Pointer on specific information required
340                                                   to create a decoder */
341    M4OSA_UInt32    m_decoderSpecificInfoSize;/**< Size of the specific information pointer above*/
342
343    M4OSA_UInt8*    m_pEncoderSPS;
344    M4OSA_UInt32    m_encoderSPSSize;
345
346    M4OSA_UInt8*    m_pEncoderPPS;
347    M4OSA_UInt32    m_encoderPPSSize;
348
349    M4OSA_UInt8*    m_pFinalDSI;
350    M4OSA_UInt32    m_pFinalDSISize;
351
352    M4OSA_UInt32    m_encoder_SPS_Cnt;
353    ComSequenceParameterSet_t_MCS *p_clip_sps;
354    M4OSA_UInt32    m_encoder_PPS_Cnt;
355    ComPictureParameterSet_t_MCS  *p_clip_pps;
356
357    ComSequenceParameterSet_t_MCS *p_encoder_sps;
358    ComPictureParameterSet_t_MCS  *p_encoder_pps;
359
360
361    ComSequenceParameterSet_t_MCS  encoder_sps;
362    ComPictureParameterSet_t_MCS   encoder_pps;
363    ComSequenceParameterSet_t_MCS  clip_sps;
364
365    /* Encoder SPS parameters */
366    M4OSA_UInt32 enc_seq_parameter_set_id;
367    M4OSA_UInt32 enc_log2_max_frame_num_minus4;
368    M4OSA_UInt32 enc_pic_order_cnt_type;
369    M4OSA_UInt32 enc_log2_max_pic_order_cnt_lsb_minus4; /* applicable when POC type = 0 */
370    M4OSA_UInt32 enc_delta_pic_order_always_zero_flag;
371    M4OSA_Int32 enc_offset_for_non_ref_pic;
372    M4OSA_Int32 enc_offset_for_top_to_bottom_field;
373    M4OSA_UInt32 enc_num_ref_frames_in_pic_order_cnt_cycle; /* range 0 to 255 */
374    /* array of size num_ref_frames_in_pic_order_cnt_cycle */
375    M4OSA_Int32   enc_offset_for_ref_frame[256];
376    M4OSA_UInt32 enc_num_ref_frames;
377    M4OSA_UInt32 enc_gaps_in_frame_num_value_allowed_flag;
378
379
380    /* Input clip SPS parameters */
381    M4OSA_UInt32 clip_seq_parameter_set_id;
382    M4OSA_UInt32 clip_log2_max_frame_num_minus4;
383    M4OSA_UInt32 clip_pic_order_cnt_type;
384    M4OSA_UInt32 clip_log2_max_pic_order_cnt_lsb_minus4; /* applicable when POC type = 0 */
385    M4OSA_UInt32 clip_delta_pic_order_always_zero_flag;
386    M4OSA_Int32  clip_offset_for_non_ref_pic;
387    M4OSA_Int32  clip_offset_for_top_to_bottom_field;
388    M4OSA_UInt32 clip_num_ref_frames_in_pic_order_cnt_cycle; /* range 0 to 255 */
389    /* array of size num_ref_frames_in_pic_order_cnt_cycle */
390    M4OSA_Int32  clip_offset_for_ref_frame[256];
391    M4OSA_UInt32 clip_num_ref_frames;
392    M4OSA_UInt32 clip_gaps_in_frame_num_value_allowed_flag;
393
394    M4OSA_UInt32 final_PPS_ID;
395    M4OSA_UInt32 final_SPS_ID;
396    NSWAVC_bitStream_t_MCS  encbs;
397
398} NSWAVC_MCS_t;
399
400
401
402/**
403 ******************************************************************************
404 * structure    M4MCS_InternalContext
405 * @brief       This structure defines the MCS context (private)
406 * @note        This structure is used for all MCS calls to store the context
407 ******************************************************************************
408 */
409typedef struct
410{
411    /**
412     * MCS State and settings stuff */
413    M4MCS_States            State;     /**< MCS internal state */
414    M4MCS_StreamState       VideoState;/**< State of the video encoding */
415    M4MCS_StreamState       AudioState;/**< State of the audio encoding */
416    M4OSA_Bool              noaudio;/**< Flag to know if we have to deal with audio transcoding */
417    M4OSA_Bool              novideo;/**< Flag to know if we have to deal with video transcoding */
418
419    M4VIDEOEDITING_ClipProperties  InputFileProperties;/**< Input audio/video stream properties */
420    M4OSA_Void*             pInputFile;             /**< Remember input file pointer between fast
421                                                         open and normal open */
422    M4VIDEOEDITING_FileType InputFileType;          /**< Remember input file type between fast
423                                                         open and normal open */
424    M4OSA_Bool              bFileOpenedInFastMode;  /**< Flag to know if a particular reader
425                                                         supports fast open */
426    M4OSA_UInt32            uiMaxMetadataSize;      /**< Limitation on the max acceptable moov
427                                                         size of a 3gpp file */
428
429    M4ENCODER_Format        EncodingVideoFormat;    /**< Output video format, set by the user */
430    M4ENCODER_FrameWidth    EncodingWidth;          /**< Output video width, set by the user */
431    M4ENCODER_FrameHeight   EncodingHeight;         /**< Output video height, set by the user */
432    M4ENCODER_FrameRate     EncodingVideoFramerate; /**< Output video framerate, set by the user*/
433
434    M4OSA_UInt32            uiBeginCutTime;     /**< Begin cut time, in milliseconds */
435    M4OSA_UInt32            uiEndCutTime;       /**< Begin cut time, in milliseconds */
436    M4OSA_UInt32            uiMaxFileSize;      /**< Maximum output file size, in bytes */
437    M4OSA_UInt32            uiAudioBitrate;     /**< Targeted audio bitrate in bps */
438    M4OSA_UInt32            uiVideoBitrate;     /**< Targeted video bitrate in bps */
439
440#ifdef TIMESCALE_BUG
441    M4OSA_UInt32    uiVideoTimescale;     /**< Targeted timescale without decode/encode process */
442    M4OSA_UInt32    uiTimescaleLength;    /**< Length of the VOP time increment in bits */
443    M4OSA_UInt32    uiOrigVideoTimescale; /**< Original timescale */
444    M4OSA_UInt32    uiOrigTimescaleLength;/**< Original length of the VOP time increment in bits*/
445    M4MCS_VolParse  volParsing;           /**< VOL parsing results needed for VOP parsing */
446#endif
447    M4OSA_UInt8     uiProgress;  /**< Progress information saved at each step to be able to
448                                      return it in case of pause */
449
450    /**
451     * Reader stuff */
452    M4OSA_Context           pReaderContext;           /**< Context of the reader module */
453    M4_VideoStreamHandler*  pReaderVideoStream;       /**< Description of the read video stream */
454    M4_AudioStreamHandler*  pReaderAudioStream;       /**< Description of the read audio stream */
455    M4OSA_Bool              bUnsupportedVideoFound;   /**< True if an unsupported video stream
456                                                            type has been found */
457    M4OSA_Bool              bUnsupportedAudioFound;   /**< True if an unsupported audio stream
458                                                            type has been found */
459    M4_AccessUnit           ReaderVideoAU;            /**< Read video access unit */
460    M4_AccessUnit           ReaderVideoAU1;           /**< Read video access unit */
461    M4_AccessUnit           ReaderVideoAU2;           /**< Read video access unit */
462    M4_AccessUnit           ReaderAudioAU;            /**< Read audio access unit */
463    M4_AccessUnit           ReaderAudioAU1;           /**< Read audio access unit */
464    M4_AccessUnit           ReaderAudioAU2;           /**< Read audio access unit */
465    M4OSA_MemAddr8          m_pDataAddress1;          /**< Temporary buffer for Access Unit */
466    M4OSA_MemAddr8          m_pDataAddress2;          /**< Temporary buffer for Access Unit */
467    M4OSA_MemAddr8          m_pDataVideoAddress1;     /**< Temporary buffer for Access Unit */
468    M4OSA_MemAddr8          m_pDataVideoAddress2;     /**< Temporary buffer for Access Unit */
469    M4OSA_UInt32            m_audioAUDuration;        /**< Audio AU duration */
470    M4OSA_Int32             iAudioCtsOffset;          /**< Audio AU CTS offset due to begin cut */
471
472    /**
473     * Video decoder stuff */
474    M4OSA_Context         pViDecCtxt;         /**< Video decoder context */
475    M4OSA_Double          dViDecStartingCts;  /**< Video CTS at which the decode/encode will start
476                                                   (used for begin cut and pause/resume) */
477    M4OSA_Double          dViDecCurrentCts;   /**< Video CTS to decode */
478    M4OSA_Int32           iVideoBeginDecIncr; /**< CTS step for the begin cut decode (doesn't
479                                                    need floating point precision) */
480    M4OSA_Double          dCtsIncrement;      /**< Cts increment from one video frame to another*/
481    M4OSA_Bool            isRenderDup;        /**< To handle duplicate frame rendering in case of
482                                                    external decoding */
483    M4VIFI_ImagePlane*    lastDecodedPlane;   /**< Last decoded plane */
484
485    /**
486     * Video encoder stuff */
487    M4OSA_Context         pViEncCtxt;         /**< Video encoder context */
488    M4VIFI_ImagePlane*    pPreResizeFrame;    /**< The decoded image before resize
489                                                  (allocated if resize needed only)*/
490    M4OSA_UInt32          uiEncVideoBitrate;  /**< Actual video bitrate for the video encoder */
491    M4OSA_Bool            bActivateEmp;    /**< Encode in Mpeg4 format with limitations for EMP */
492    M4OSA_UInt32          outputVideoTimescale;
493    M4OSA_UInt32          encoderState;
494
495    /**
496     * Audio decoder stuff */
497    M4OSA_Context         pAudioDecCtxt;        /**< Audio (AAC) decoder context */
498    M4AD_Buffer           AudioDecBufferIn;     /**< Input structure for the audio decoder */
499    M4AD_Buffer           AudioDecBufferOut;    /**< Output structure for the audio decoder */
500    M4OSA_MemAddr8        pPosInDecBufferOut;   /**< Position into the decoder buffer */
501    AAC_DEC_STREAM_PROPS  AacProperties;   /**< Structure for new api to get AAC properties */
502
503    /**
504     * Sample Rate Convertor (SSRC) stuff */
505    SSRC_Instance_t        SsrcInstance;       /**< Context of the Ssrc */
506    SSRC_Scratch_t*        SsrcScratch;        /**< Working memory of the Ssrc */
507    short                  iSsrcNbSamplIn;     /**< Number of sample the Ssrc needs as input */
508    short                  iSsrcNbSamplOut;    /**< Number of sample the Ssrc outputs */
509    M4OSA_MemAddr8         pSsrcBufferIn;      /**< Input of the SSRC */
510    M4OSA_MemAddr8         pSsrcBufferOut;     /**< Output of the SSRC */
511    M4OSA_MemAddr8         pPosInSsrcBufferIn; /**< Position into the SSRC in buffer */
512    M4OSA_MemAddr8         pPosInSsrcBufferOut;/**< Position into the SSRC out buffer */
513
514    M4OSA_Context          pLVAudioResampler;
515
516
517    /**
518     * audio encoder stuff */
519    M4OSA_Context                   pAudioEncCtxt; /**< Context of the audio encoder */
520    M4ENCODER_AudioDecSpecificInfo  pAudioEncDSI; /**< Decoder specific info built by the encoder*/
521    M4ENCODER_AudioParams           AudioEncParams;/**< Config of the audio encoder */
522    M4OSA_MemAddr8            pAudioEncoderBuffer;      /**< Input of the encoder */
523    M4OSA_MemAddr8            pPosInAudioEncoderBuffer; /**< Position into the encoder buffer */
524    M4OSA_UInt32              audioEncoderGranularity;  /**< Minimum number of pcm samples needed
525                                                             to feed audio encoder */
526
527    /**
528     * Writer stuff */
529    M4OSA_Context             pWriterContext;     /**< Context of the writer module */
530    M4OSA_Void*               pOutputFile;        /**< Output file to be created */
531    M4OSA_Void*               pTemporaryFile;     /**< Temporary file to be created to store
532                                                        metadata ("moov.bin") */
533    M4SYS_StreamDescription   WriterVideoStream;  /**< Description of the written video stream */
534    M4SYS_StreamDescription   WriterAudioStream;  /**< Description of the written audio stream */
535    M4WRITER_StreamVideoInfos WriterVideoStreamInfo;/**< Video properties of the written video
536                                                          stream */
537    M4SYS_AccessUnit          WriterVideoAU;        /**< Written video access unit */
538    M4SYS_AccessUnit          WriterAudioAU;        /**< Written audio access unit */
539    M4OSA_UInt32              uiVideoAUCount;       /**< Number of video AU written in output
540                                                          file */
541    M4OSA_UInt32              uiVideoMaxAuSize;     /**< Max access unit size for the output
542                                                          video stream */
543    M4OSA_UInt32              uiVideoMaxChunckSize; /**< Max chunck size for the output video
544                                                          stream */
545    M4OSA_UInt32              uiAudioAUCount;   /**< Number of audio AU written in output file */
546    M4OSA_UInt32              uiAudioMaxAuSize; /**< Max access unit size for the output
547                                                       audio stream */
548    M4OSA_UInt32              uiAudioCts;       /**< Audio AU cts (when audio is transcoded) */
549    M4OSA_Bool                b_isRawWriter;    /**< Boolean to know if the raw writer is
550                                                      registered or not */
551    M4OSA_Context             pOutputPCMfile;   /**< Output PCM file if not NULL */
552
553    /**
554     * Filesystem functions */
555    M4OSA_FileReadPointer*    pOsaFileReadPtr; /**< OSAL file read functions,
556                                                    to be provided by user */
557    M4OSA_FileWriterPointer*  pOsaFileWritPtr; /**< OSAL file write functions,
558                                                    to be provided by user */
559
560    /**
561      * Media and Codec registration */
562    /**< Table of M4VES_WriterInterface structures for avalaible Writers list */
563    M4MCS_WriterInterface               WriterInterface[M4WRITER_kType_NB];
564    /**< open, close, setoption,etc... functions of the used writer*/
565    M4WRITER_GlobalInterface*           pWriterGlobalFcts;
566    /**< data manipulation functions of the used writer */
567    M4WRITER_DataInterface*             pWriterDataFcts;
568    /**< Table of M4ENCODER_GlobalInterface structures for avalaible encoders list */
569    M4ENCODER_GlobalInterface*          pVideoEncoderInterface[M4ENCODER_kVideo_NB];
570    /**< Functions of the used encoder */
571    M4ENCODER_GlobalInterface*          pVideoEncoderGlobalFcts;
572
573    M4OSA_Void*                         pVideoEncoderExternalAPITable[M4ENCODER_kVideo_NB];
574    M4OSA_Void*                         pCurrentVideoEncoderExternalAPI;
575    M4OSA_Void*                         pVideoEncoderUserDataTable[M4ENCODER_kVideo_NB];
576    M4OSA_Void*                         pCurrentVideoEncoderUserData;
577
578    /**< Table of M4ENCODER_AudioGlobalInterface structures for avalaible encoders list */
579    M4ENCODER_AudioGlobalInterface*     pAudioEncoderInterface[M4ENCODER_kAudio_NB];
580    /**< Table of internal/external flags for avalaible encoders list */
581    M4OSA_Bool                          pAudioEncoderFlag[M4ENCODER_kAudio_NB];
582    /**< Functions of the used encoder */
583    M4ENCODER_AudioGlobalInterface*     pAudioEncoderGlobalFcts;
584    M4OSA_Void*                         pAudioEncoderUserDataTable[M4ENCODER_kAudio_NB];
585    M4OSA_Void*                         pCurrentAudioEncoderUserData;
586
587    M4READER_GlobalInterface*           m_pReaderGlobalItTable[M4READER_kMediaType_NB];
588    M4READER_DataInterface*             m_pReaderDataItTable[M4READER_kMediaType_NB];
589    M4READER_GlobalInterface*           m_pReader;
590    M4READER_DataInterface*             m_pReaderDataIt;
591    M4OSA_UInt8                         m_uiNbRegisteredReaders;
592
593    M4DECODER_VideoInterface*           m_pVideoDecoder;
594    M4DECODER_VideoInterface*           m_pVideoDecoderItTable[M4DECODER_kVideoType_NB];
595#ifdef M4VSS_ENABLE_EXTERNAL_DECODERS
596    M4OSA_Void*                         m_pCurrentVideoDecoderUserData;
597    M4OSA_Void*                         m_pVideoDecoderUserDataTable[M4DECODER_kVideoType_NB];
598#endif /* M4VSS_ENABLE_EXTERNAL_DECODERS */
599    M4OSA_UInt8                         m_uiNbRegisteredVideoDec;
600
601    M4AD_Interface*         m_pAudioDecoder;
602    M4AD_Interface*         m_pAudioDecoderItTable[M4AD_kType_NB];
603    M4OSA_Bool              m_pAudioDecoderFlagTable[M4AD_kType_NB]; /**< store indices of external
604                                                                      decoders */
605    M4OSA_Void*             m_pAudioDecoderUserDataTable[M4AD_kType_NB];
606    M4OSA_Void*             m_pCurrentAudioDecoderUserData;
607
608    M4MCS_MediaRendering    MediaRendering;     /**< FB: to crop, resize, or render black borders*/
609    M4OSA_Context           m_air_context;
610    M4OSA_Bool              bExtOMXAudDecoder;  /* External OMX Audio decoder */
611
612    /**< FlB 2009.03.04: Audio effects*/
613    M4MCS_EffectSettings    *pEffects;              /**< List of effects */
614    M4OSA_UInt8             nbEffects;              /**< Number of effects in the above list */
615    M4OSA_Int8              pActiveEffectNumber;    /**< Effect ID to be applied, if -1,
616                                                       no effect has to be applied currently*/
617
618#ifdef M4MCS_SUPPORT_STILL_PICTURE
619    M4OSA_Bool              m_bIsStillPicture;       /**< =TRUE if input file is a still picture
620                                                        (JPEG, PNG, BMP, GIF)*/
621    M4MCS_Context           m_pStillPictureContext; /**< Context of the still picture part of MCS*/
622#endif /*M4MCS_SUPPORT_STILL_PICTURE*/
623    NSWAVC_MCS_t            *m_pInstance;
624    M4OSA_UInt8             *H264MCSTempBuffer;
625    M4OSA_UInt32            H264MCSTempBufferSize;
626    M4OSA_UInt32            H264MCSTempBufferDataSize;
627    M4OSA_Bool              bH264Trim;
628    /* Flag when to get  lastdecodedframeCTS */
629    M4OSA_Bool              bLastDecodedFrameCTS;
630
631} M4MCS_InternalContext;
632
633
634#endif /* __M4MCS_INTERNALTYPES_H__ */
635
636