Fix for 4142219 Don't hard code platform-specific limitations.

Also fixes 5118207 add other video codec support for video editor export.

For importing video clips, Video Editor engine will query StageFright codecs
for supported codecs, profiles and levels.
For Export, the profile and level are configured in media_profiles.xml

Change-Id: I85c8bb8b87cfcf0f1351ecb8c4f369a8902e7a09
diff --git a/libvideoeditor/vss/common/inc/M4DECODER_Common.h b/libvideoeditor/vss/common/inc/M4DECODER_Common.h
index dd9c0fa..93e3062 100755
--- a/libvideoeditor/vss/common/inc/M4DECODER_Common.h
+++ b/libvideoeditor/vss/common/inc/M4DECODER_Common.h
@@ -130,21 +130,20 @@
     M4DECODER_kOptionID_EnableYuvWithEffect =
         M4OSA_OPTION_ID_CREATE(M4_READ, M4DECODER_COMMON, 0x09),
 
+    /**
+     * Get the supported video decoders and capabilities */
+    M4DECODER_kOptionID_VideoDecodersAndCapabilities =
+        M4OSA_OPTION_ID_CREATE(M4_READ, M4DECODER_COMMON, 0x10),
+
     /* common to MPEG4 decoders */
     /**
      * Get the DecoderConfigInfo */
     M4DECODER_MPEG4_kOptionID_DecoderConfigInfo = M4OSA_OPTION_ID_CREATE(M4_READ,\
                                                          M4DECODER_MPEG4, 0x01),
 
-    /* only for H.264 decoder. */
-    /**
-    Get AVC profile and level.
-    */
-    M4DECODER_kOptionID_AVCProfileAndLevel = M4OSA_OPTION_ID_CREATE(M4_READ, M4DECODER_AVC, 0x01),
-
     /* last decoded cts */
     M4DECODER_kOptionID_AVCLastDecodedFrameCTS = M4OSA_OPTION_ID_CREATE(M4_READ, M4DECODER_AVC,\
-                                                                             0x02)
+                                                                             0x01)
 /* Last decoded cts */
 
 } M4DECODER_OptionID;
@@ -223,6 +222,26 @@
 
 } M4DECODER_VideoType ;
 
+typedef struct {
+    M4OSA_UInt32 mProfile;
+    M4OSA_UInt32 mLevel;
+} VideoProfileLevel;
+
+typedef struct {
+    VideoProfileLevel *profileLevel;
+    M4OSA_UInt32 profileNumber;
+} VideoComponentCapabilities;
+
+typedef struct {
+    M4_StreamType codec;
+    VideoComponentCapabilities *component;
+    M4OSA_UInt32 componentNumber;
+} VideoDecoder;
+
+typedef struct {
+    VideoDecoder *decoder;
+    M4OSA_UInt32 decoderNumber;
+} M4DECODER_VideoDecoders;
 /**
  ************************************************************************
  * @brief    creates an instance of the decoder
diff --git a/libvideoeditor/vss/common/inc/M4ENCODER_common.h b/libvideoeditor/vss/common/inc/M4ENCODER_common.h
index c94a82e..9064602 100755
--- a/libvideoeditor/vss/common/inc/M4ENCODER_common.h
+++ b/libvideoeditor/vss/common/inc/M4ENCODER_common.h
@@ -266,7 +266,8 @@
     M4ENCODER_FrameRate        FrameRate;            /**< Framerate, see enum  */
     M4ENCODER_Format        Format;                /**< Video compression format, H263, MPEG4,
                                                          MJPEG ...  */
-
+    M4OSA_Int32            videoProfile; /** video profile */
+    M4OSA_Int32            videoLevel;   /** video level */
 } M4ENCODER_Params;
 
 /**
@@ -292,6 +293,8 @@
     M4ENCODER_FrameRate        FrameRate;
     /**< Video compression format: H263 or MPEG4 */
     M4ENCODER_Format        Format;
+    M4OSA_Int32            videoProfile; /** output video profile */
+    M4OSA_Int32            videoLevel;   /** output video level */
     M4OSA_UInt32            uiHorizontalSearchRange; /**< Set to 0 will use default value (15) */
     M4OSA_UInt32            uiVerticalSearchRange;   /**< Set to 0 will use default value (15) */
     /**< Set to 0 will use default value (0x7FFF i.e. let engine decide when to put an I) */
diff --git a/libvideoeditor/vss/common/inc/M4VD_EXTERNAL_Interface.h b/libvideoeditor/vss/common/inc/M4VD_EXTERNAL_Interface.h
index db48207..90bfcb6 100755
--- a/libvideoeditor/vss/common/inc/M4VD_EXTERNAL_Interface.h
+++ b/libvideoeditor/vss/common/inc/M4VD_EXTERNAL_Interface.h
@@ -29,13 +29,19 @@
 (useful for video editing) without having to instanciate a decoder, which can be useful precisely
 if HW decoders are a possibility. */
 
-M4OSA_ERR M4DECODER_EXTERNAL_ParseVideoDSI(M4OSA_UInt8* pVol, M4OSA_Int32 aVolSize,
-                                             M4DECODER_MPEG4_DecoderConfigInfo* pDci,
-                                             M4DECODER_VideoSize* pVideoSize);
+M4OSA_ERR M4DECODER_EXTERNAL_ParseVideoDSI(
+                      M4OSA_UInt8* pVol, M4OSA_Int32 aVolSize,
+                      M4DECODER_MPEG4_DecoderConfigInfo* pDci,
+                      M4DECODER_VideoSize* pVideoSize);
 
-M4OSA_ERR M4DECODER_EXTERNAL_ParseAVCDSI(M4OSA_UInt8* pDSI, M4OSA_Int32 DSISize,
-                                            M4DECODER_AVCProfileLevel *profile);
+M4OSA_ERR getAVCProfileAndLevel(M4OSA_UInt8* pDSI, M4OSA_Int32 DSISize,
+                      M4OSA_Int32 *pProfile, M4OSA_Int32 *pLevel);
 
+M4OSA_ERR getH263ProfileAndLevel(M4OSA_UInt8* pDSI, M4OSA_Int32 DSISize,
+                      M4OSA_Int32 *pProfile, M4OSA_Int32 *pLevel);
+
+M4OSA_ERR getMPEG4ProfileAndLevel(M4OSA_UInt8 profileAndLevel,
+                      M4OSA_Int32 *pProfile, M4OSA_Int32 *pLevel);
 
 #ifdef __cplusplus
 }
diff --git a/libvideoeditor/vss/common/inc/M4_VideoEditingCommon.h b/libvideoeditor/vss/common/inc/M4_VideoEditingCommon.h
index a9f6412..5581417 100755
--- a/libvideoeditor/vss/common/inc/M4_VideoEditingCommon.h
+++ b/libvideoeditor/vss/common/inc/M4_VideoEditingCommon.h
@@ -35,6 +35,8 @@
 #define M4VIDEOEDITING_VERSION_MINOR    1
 #define M4VIDEOEDITING_VERSION_REVISION    0
 
+#define M4VIDEOEDITING_VIDEO_UNKNOWN_PROFILE 0x7fffffff
+#define M4VIDEOEDITING_VIDEO_UNKNOWN_LEVEL 0x7fffffff
 
 /**
  ******************************************************************************
@@ -71,15 +73,12 @@
 */
 typedef enum
 {
-    M4VIDEOEDITING_kNoneVideo            = 0,    /**< Video not present */
-    M4VIDEOEDITING_kH263                = 1,    /**< H263 video */
-    M4VIDEOEDITING_kMPEG4                = 2,    /**< MPEG-4 video */
-    M4VIDEOEDITING_kMPEG4_EMP            = 3,    /**< MPEG-4 video with support for EMP
-                                                    (hsr=15, vsr=15, err=0, Iperiod=15,
-                                                     NO_M4V, NO_AC_PRED) */
-    M4VIDEOEDITING_kH264                = 4,    /**< H264 video */
-    M4VIDEOEDITING_kNullVideo           = 254,  /**< Do not care video type, use NULL encoder */
-    M4VIDEOEDITING_kUnsupportedVideo    = 255    /**< Unsupported video stream type */
+    M4VIDEOEDITING_kNoneVideo = 0, /**< Video not present */
+    M4VIDEOEDITING_kH263 = 1, /**< H263 video */
+    M4VIDEOEDITING_kH264 = 2,    /**< H264 video */
+    M4VIDEOEDITING_kMPEG4 = 3, /**< MPEG-4 video */
+    M4VIDEOEDITING_kNullVideo = 254,  /**< Do not care video type, use NULL encoder */
+    M4VIDEOEDITING_kUnsupportedVideo = 255    /**< Unsupported video stream type */
 } M4VIDEOEDITING_VideoFormat;
 
 /**
@@ -102,51 +101,6 @@
     M4VIDEOEDITING_kUnsupportedAudio    = 255    /**< Unsupported audio stream type */
 } M4VIDEOEDITING_AudioFormat;
 
-
-/**
- ******************************************************************************
- * enum        M4VIDEOEDITING_VideoProfileAndLevel
- * @brief    This enum defines the video profile and level for MPEG-4 and H263 streams.
- ******************************************************************************
-*/
-typedef enum
-{
-    /* H.263 Profiles and levels */
-    M4VIDEOEDITING_kH263_Profile_0_Level_10        = 0,
-    M4VIDEOEDITING_kH263_Profile_0_Level_20        = 1,
-    M4VIDEOEDITING_kH263_Profile_0_Level_30        = 2,
-    M4VIDEOEDITING_kH263_Profile_0_Level_40        = 3,
-    M4VIDEOEDITING_kH263_Profile_0_Level_45        = 4,
-    /* MPEG-4 Profiles and levels */
-    M4VIDEOEDITING_kMPEG4_SP_Level_0               = 50,
-    M4VIDEOEDITING_kMPEG4_SP_Level_0b              = 51,
-    M4VIDEOEDITING_kMPEG4_SP_Level_1               = 52,
-    M4VIDEOEDITING_kMPEG4_SP_Level_2               = 53,
-    M4VIDEOEDITING_kMPEG4_SP_Level_3               = 54,
-    M4VIDEOEDITING_kMPEG4_SP_Level_4a              = 55,
-    M4VIDEOEDITING_kMPEG4_SP_Level_5               = 56,
-    /* AVC Profiles and levels */
-    M4VIDEOEDITING_kH264_Profile_0_Level_1         = 150,
-    M4VIDEOEDITING_kH264_Profile_0_Level_1b        = 151,
-    M4VIDEOEDITING_kH264_Profile_0_Level_1_1       = 152,
-    M4VIDEOEDITING_kH264_Profile_0_Level_1_2       = 153,
-    M4VIDEOEDITING_kH264_Profile_0_Level_1_3       = 154,
-    M4VIDEOEDITING_kH264_Profile_0_Level_2         = 155,
-    M4VIDEOEDITING_kH264_Profile_0_Level_2_1       = 156,
-    M4VIDEOEDITING_kH264_Profile_0_Level_2_2       = 157,
-    M4VIDEOEDITING_kH264_Profile_0_Level_3         = 158,
-    M4VIDEOEDITING_kH264_Profile_0_Level_3_1       = 159,
-    M4VIDEOEDITING_kH264_Profile_0_Level_3_2       = 160,
-    M4VIDEOEDITING_kH264_Profile_0_Level_4         = 161,
-    M4VIDEOEDITING_kH264_Profile_0_Level_4_1       = 162,
-    M4VIDEOEDITING_kH264_Profile_0_Level_4_2       = 163,
-    M4VIDEOEDITING_kH264_Profile_0_Level_5         = 164,
-    M4VIDEOEDITING_kH264_Profile_0_Level_5_1       = 165,
-    /* Unsupported profile and level */
-    M4VIDEOEDITING_kProfile_and_Level_Out_Of_Range = 255
-} M4VIDEOEDITING_VideoProfileAndLevel;
-
-
 /**
  ******************************************************************************
  * enum        M4VIDEOEDITING_VideoFrameSize
@@ -328,11 +282,9 @@
     M4OSA_UInt32                        uiVideoTimeScale;    /**< Video time scale */
     M4OSA_Float                         fAverageFrameRate;   /**< Average frame rate of the video
                                                                   stream */
-    M4VIDEOEDITING_VideoProfileAndLevel    ProfileAndLevel;     /**< Supported MPEG4 and H263
-                                                                     profiles and levels */
-    M4OSA_UInt8                         uiH263level;         /**< H263 level (from core decoder)*/
-    M4OSA_UInt8                         uiVideoProfile;      /**< H263 or MPEG-4 profile
-                                                                (from core decoder) */
+    M4OSA_Int32 uiVideoLevel;   /**< video level*/
+    M4OSA_Int32 uiVideoProfile; /**< video profile */
+
     M4OSA_Bool                          bMPEG4dataPartition; /**< MPEG-4 uses data partitioning */
     M4OSA_Bool                          bMPEG4rvlc;          /**< MPEG-4 uses RVLC tool */
     M4OSA_Bool                          bMPEG4resynchMarker; /**< MPEG-4 stream uses Resynch
diff --git a/libvideoeditor/vss/inc/M4PTO3GPP_API.h b/libvideoeditor/vss/inc/M4PTO3GPP_API.h
index e81bc6d..4aa20d2 100755
--- a/libvideoeditor/vss/inc/M4PTO3GPP_API.h
+++ b/libvideoeditor/vss/inc/M4PTO3GPP_API.h
@@ -145,6 +145,8 @@
     M4OSA_Void*                     pTemporaryFile;
     /**< Number of input YUV frames to encode */
     M4OSA_UInt32                    NbVideoFrames;
+    M4OSA_Int32   videoProfile;
+    M4OSA_Int32   videoLevel;
 } M4PTO3GPP_Params;
 
 /**
diff --git a/libvideoeditor/vss/inc/M4VSS3GPP_ErrorCodes.h b/libvideoeditor/vss/inc/M4VSS3GPP_ErrorCodes.h
index 36e239c..4bf2e84 100755
--- a/libvideoeditor/vss/inc/M4VSS3GPP_ErrorCodes.h
+++ b/libvideoeditor/vss/inc/M4VSS3GPP_ErrorCodes.h
@@ -151,8 +151,12 @@
 #define M4VSS3GPP_ERR_EDITING_NO_SUPPORTED_VIDEO_STREAM_IN_FILE    M4OSA_ERR_CREATE( M4_ERR,\
                                                                                 M4VSS3GPP, 0x0026)
 /**
- * Unsupported H264 profile for Video Editing */
-#define M4VSS3GPP_ERR_EDITING_UNSUPPORTED_H264_PROFILE M4OSA_ERR_CREATE( M4_ERR, M4VSS3GPP, 0x0027)
+ * Unsupported video profile for Video Editing */
+#define M4VSS3GPP_ERR_EDITING_UNSUPPORTED_VIDEO_PROFILE M4OSA_ERR_CREATE( M4_ERR, M4VSS3GPP, 0x0027)
+
+/**
+ * Unsupported video profile for Video Editing */
+#define M4VSS3GPP_ERR_EDITING_UNSUPPORTED_VIDEO_LEVEL M4OSA_ERR_CREATE( M4_ERR, M4VSS3GPP, 0x0028)
 
 /************************************************************************/
 /* Errors returned by M4VSS3GPP_editCheckClipCompatibility()            */
diff --git a/libvideoeditor/vss/inc/M4VSS3GPP_Extended_API.h b/libvideoeditor/vss/inc/M4VSS3GPP_Extended_API.h
index ee750c4..9668b67 100755
--- a/libvideoeditor/vss/inc/M4VSS3GPP_Extended_API.h
+++ b/libvideoeditor/vss/inc/M4VSS3GPP_Extended_API.h
@@ -292,6 +292,9 @@
     M4xVSS_BGMSettings                        *pBGMtrack;
     /**< Function pointer on text rendering engine, if not used, must be set to NULL !! */
     M4xVSS_getTextRgbBufferFct                pTextRenderingFct;
+    /** output video profile and level*/
+    M4OSA_Int32   outputVideoProfile;
+    M4OSA_Int32   outputVideoLevel;
 
 } M4xVSS_EditSettings;
 
diff --git a/libvideoeditor/vss/inc/M4VSS3GPP_InternalTypes.h b/libvideoeditor/vss/inc/M4VSS3GPP_InternalTypes.h
index 2dd892a..2772e16 100755
--- a/libvideoeditor/vss/inc/M4VSS3GPP_InternalTypes.h
+++ b/libvideoeditor/vss/inc/M4VSS3GPP_InternalTypes.h
@@ -420,6 +420,8 @@
     /**
      * Output Video Stream Stuff */
     M4SYS_StreamType            VideoStreamType;        /**< Output video codec */
+    M4OSA_Int32                 outputVideoProfile;  /**< Output video profile */
+    M4OSA_Int32                 outputVideoLevel;   /**< Output video level */
     M4OSA_UInt32                uiVideoBitrate;     /**< Average video bitrate of the output file,
                                                          computed from input bitrates, durations,
                                                           transitions and cuts */
@@ -434,9 +436,6 @@
                                                                  MPEG-4 track */
     M4OSA_UInt16                uiVideoOutputDsiSize;    /**< Size of the Decoder Specific Info
                                                                 of the output MPEG-4 track */
-    M4OSA_Bool                  bActivateEmp;           /**< Encode in Mpeg4 format with
-                                                            limitations for EMP */
-
     /**
      * Output Audio Stream Stuff */
     M4SYS_StreamType            AudioStreamType;        /**< Type of the output audio stream */
diff --git a/libvideoeditor/vss/inc/M4xVSS_API.h b/libvideoeditor/vss/inc/M4xVSS_API.h
index 66d8c0f..5ce102f 100755
--- a/libvideoeditor/vss/inc/M4xVSS_API.h
+++ b/libvideoeditor/vss/inc/M4xVSS_API.h
@@ -32,7 +32,7 @@
 
 #include "M4VSS3GPP_API.h"
 #include "M4VSS3GPP_Extended_API.h"
-
+#include "M4DECODER_Common.h"
 /* Errors codes */
 
 /**
@@ -581,6 +581,8 @@
 */
 M4OSA_ERR M4xVSS_getVSS3GPPContext(M4OSA_Context pContext, M4OSA_Context* vss3gppContext);
 
+// Get supported video decoders and capabilities.
+M4OSA_ERR M4xVSS_getVideoDecoderCapabilities(M4DECODER_VideoDecoders **decoders);
 #ifdef __cplusplus
 }
 #endif /* __cplusplus */
diff --git a/libvideoeditor/vss/inc/M4xVSS_Internal.h b/libvideoeditor/vss/inc/M4xVSS_Internal.h
index 8811beb..faf160f 100755
--- a/libvideoeditor/vss/inc/M4xVSS_Internal.h
+++ b/libvideoeditor/vss/inc/M4xVSS_Internal.h
@@ -348,7 +348,8 @@
     M4MCS_MediaRendering                 MediaRendering;   /**< FB: to crop, resize, or render
                                                                 black borders*/
     M4OSA_UInt32                         videoclipnumber;
-
+    M4OSA_UInt32  outputVideoProfile;
+    M4OSA_UInt32  outputVideoLevel;
 } M4xVSS_MCS_params;
 
 /**
diff --git a/libvideoeditor/vss/mcs/inc/M4MCS_API.h b/libvideoeditor/vss/mcs/inc/M4MCS_API.h
index b5d7212..a8987e2 100755
--- a/libvideoeditor/vss/mcs/inc/M4MCS_API.h
+++ b/libvideoeditor/vss/mcs/inc/M4MCS_API.h
@@ -206,6 +206,8 @@
     (and rotation info is set to 0)*/
     M4OSA_Bool                              bAdjustOrientation ;
     /*--- STILL PICTURE ---*/
+    M4OSA_Int32 outputVideoProfile;
+    M4OSA_Int32 outputVideoLevel;
 } M4MCS_OutputParams;
 
 /*--- STILL PICTURE ---*/
diff --git a/libvideoeditor/vss/mcs/inc/M4MCS_InternalTypes.h b/libvideoeditor/vss/mcs/inc/M4MCS_InternalTypes.h
index 5a12f69..5e4f236 100755
--- a/libvideoeditor/vss/mcs/inc/M4MCS_InternalTypes.h
+++ b/libvideoeditor/vss/mcs/inc/M4MCS_InternalTypes.h
@@ -458,7 +458,6 @@
     M4VIFI_ImagePlane*    pPreResizeFrame;    /**< The decoded image before resize
                                                   (allocated if resize needed only)*/
     M4OSA_UInt32          uiEncVideoBitrate;  /**< Actual video bitrate for the video encoder */
-    M4OSA_Bool            bActivateEmp;    /**< Encode in Mpeg4 format with limitations for EMP */
     M4OSA_UInt32          outputVideoTimescale;
     M4OSA_UInt32          encoderState;
 
@@ -597,6 +596,8 @@
     M4OSA_Bool              bH264Trim;
     /* Flag when to get  lastdecodedframeCTS */
     M4OSA_Bool              bLastDecodedFrameCTS;
+    M4OSA_Int32             encodingVideoProfile;
+    M4OSA_Int32             encodingVideoLevel;
 
 } M4MCS_InternalContext;
 
diff --git a/libvideoeditor/vss/mcs/src/M4MCS_API.c b/libvideoeditor/vss/mcs/src/M4MCS_API.c
index 79eedba..8a93720 100755
--- a/libvideoeditor/vss/mcs/src/M4MCS_API.c
+++ b/libvideoeditor/vss/mcs/src/M4MCS_API.c
@@ -2199,7 +2199,6 @@
     pC->pViEncCtxt = M4OSA_NULL;
     pC->pPreResizeFrame = M4OSA_NULL;
     pC->uiEncVideoBitrate = 0;
-    pC->bActivateEmp = M4OSA_FALSE;
     pC->encoderState = M4MCS_kNoEncoder;
 
     /**
@@ -3688,9 +3687,6 @@
                 M4ERR_CHECK_RETURN(err);
                 break;
 
-            case M4VIDEOEDITING_kMPEG4_EMP:
-                pC->bActivateEmp = M4OSA_TRUE;
-
             case M4VIDEOEDITING_kMPEG4:
 
                 pC->EncodingVideoFormat = M4ENCODER_kMPEG4;
@@ -3714,12 +3710,6 @@
                     return M4MCS_ERR_H263_FORBIDDEN_IN_MP4_FILE;
 
 
-                /* If input file is EMP, output file will be too */
-
-                if( pC->InputFileProperties.VideoStreamType
-                    == M4VIDEOEDITING_kMPEG4_EMP )
-                    pC->bActivateEmp = M4OSA_TRUE;
-
                 /* Encoder needed for begin cut to generate an I-frame */
                 pC->EncodingVideoFormat = M4ENCODER_kNULL;
                 err = M4MCS_setCurrentVideoEncoder(pContext,
@@ -3742,9 +3732,18 @@
                 pC->EncodingWidth = pC->InputFileProperties.uiVideoWidth;
             uiFrameHeight =
                 pC->EncodingHeight = pC->InputFileProperties.uiVideoHeight;
+            /**
+            * Set output video profile and level */
+            pC->encodingVideoProfile = pC->InputFileProperties.uiVideoProfile;
+            pC->encodingVideoLevel = pC->InputFileProperties.uiVideoLevel;
         }
         else
         {
+            /**
+            * Set output video profile and level */
+            pC->encodingVideoProfile = pParams->outputVideoProfile;
+            pC->encodingVideoLevel = pParams->outputVideoLevel;
+
             switch( pParams->OutputVideoFrameSize )
             {
                 case M4VIDEOEDITING_kSQCIF:
@@ -5664,6 +5663,8 @@
 
             /* Set useful parameters to encode the first I-frame */
             EncParams.InputFormat = M4ENCODER_kIYUV420;
+            EncParams.videoProfile = pC->encodingVideoProfile;
+            EncParams.videoLevel= pC->encodingVideoLevel;
 
             switch( pC->InputFileProperties.VideoStreamType )
             {
@@ -5672,7 +5673,6 @@
                     break;
 
                 case M4VIDEOEDITING_kMPEG4:
-                case M4VIDEOEDITING_kMPEG4_EMP:
                     EncParams.Format = M4ENCODER_kMPEG4;
                     break;
 
@@ -5720,6 +5720,8 @@
         * Set encoder shell parameters according to MCS settings */
         EncParams.Format = pC->EncodingVideoFormat;
         EncParams.InputFormat = M4ENCODER_kIYUV420;
+        EncParams.videoProfile = pC->encodingVideoProfile;
+        EncParams.videoLevel= pC->encodingVideoLevel;
 
         /**
         * Video frame size */
@@ -5736,32 +5738,18 @@
 
         /**
         * Other encoder settings */
-        if( M4OSA_TRUE == pC->bActivateEmp )
-        {
-            EncParams.uiHorizontalSearchRange = 15;   /* set value */
-            EncParams.uiVerticalSearchRange = 15;     /* set value */
-            EncParams.bErrorResilience = M4OSA_FALSE; /* no error resilience */
-            EncParams.uiIVopPeriod = 15; /* one I frame every 15 frames */
-            EncParams.uiMotionEstimationTools =
-                1; /* M4V_MOTION_EST_TOOLS_NO_4MV */
-            EncParams.bAcPrediction = M4OSA_FALSE;    /* no AC prediction */
-            EncParams.uiStartingQuantizerValue = 10;  /* initial QP = 10 */
-            EncParams.bDataPartitioning =
-                M4OSA_FALSE; /* no data partitioning */
-        }
-        else
-        {
-            EncParams.uiHorizontalSearchRange = 0;    /* use default */
-            EncParams.uiVerticalSearchRange = 0;      /* use default */
-            EncParams.bErrorResilience = M4OSA_FALSE; /* no error resilience */
-            EncParams.uiIVopPeriod = 0;               /* use default */
-            EncParams.uiMotionEstimationTools =
-                0; /* M4V_MOTION_EST_TOOLS_ALL */
-            EncParams.bAcPrediction = M4OSA_TRUE;     /* use AC prediction */
-            EncParams.uiStartingQuantizerValue = 10;  /* initial QP = 10 */
-            EncParams.bDataPartitioning =
-                M4OSA_FALSE; /* no data partitioning */
-        }
+
+        EncParams.uiHorizontalSearchRange = 0;    /* use default */
+        EncParams.uiVerticalSearchRange = 0;      /* use default */
+        EncParams.bErrorResilience = M4OSA_FALSE; /* no error resilience */
+        EncParams.uiIVopPeriod = 0;               /* use default */
+        EncParams.uiMotionEstimationTools =
+            0; /* M4V_MOTION_EST_TOOLS_ALL */
+        EncParams.bAcPrediction = M4OSA_TRUE;     /* use AC prediction */
+        EncParams.uiStartingQuantizerValue = 10;  /* initial QP = 10 */
+        EncParams.bDataPartitioning =
+            M4OSA_FALSE; /* no data partitioning */
+
 
         /**
         * Video encoder frame rate and rate factor */
@@ -5849,15 +5837,20 @@
         //EncParams1.InputFrameHeight = EncParams.InputFrameHeight;
         EncParams1.FrameWidth = EncParams.FrameWidth;
         EncParams1.FrameHeight = EncParams.FrameHeight;
+        EncParams1.videoProfile= EncParams.videoProfile;
+        EncParams1.videoLevel= EncParams.videoLevel;
         EncParams1.Bitrate = EncParams.Bitrate;
         EncParams1.FrameRate = EncParams.FrameRate;
         EncParams1.Format = M4ENCODER_kH264; //EncParams.Format;
-
+        M4OSA_TRACE1_2("mcs encoder open profile :%d, level %d",
+            EncParams1.videoProfile, EncParams1.videoLevel);
         err = pC->pVideoEncoderGlobalFcts->pFctOpen(pC->pViEncCtxt,
             &pC->WriterVideoAU, &EncParams1);
     }
     else
     {
+        M4OSA_TRACE1_2("mcs encoder open Adv profile :%d, level %d",
+            EncParams.videoProfile, EncParams.videoLevel);
         err = pC->pVideoEncoderGlobalFcts->pFctOpen(pC->pViEncCtxt,
             &pC->WriterVideoAU, &EncParams);
     }
@@ -6568,31 +6561,6 @@
     }
 
     /**
-    * In case of EMP, we have to explicitely give an emp ftyp to the writer */
-    if( M4OSA_TRUE == pC->bActivateEmp )
-    {
-        M4VIDEOEDITING_FtypBox ftyp;
-
-        ftyp.major_brand = M4VIDEOEDITING_BRAND_3GP4;
-        ftyp.minor_version = M4VIDEOEDITING_BRAND_0000;
-        ftyp.nbCompatibleBrands = 2;
-        ftyp.compatible_brands[0] = M4VIDEOEDITING_BRAND_3GP4;
-        ftyp.compatible_brands[1] = M4VIDEOEDITING_BRAND_EMP;
-
-        err = pC->pWriterGlobalFcts->pFctSetOption(pC->pWriterContext,
-            (M4OSA_UInt32)M4WRITER_kSetFtypBox, (M4OSA_DataOption) &ftyp);
-
-        if( M4NO_ERROR != err )
-        {
-            M4OSA_TRACE1_1(
-                "M4MCS_intPrepareWriter:\
-                 pWriterGlobalFcts->pFctSetOption(M4WRITER_kSetFtypBox) returns 0x%x!",
-                err);
-            return err;
-        }
-    }
-
-    /**
     * If there is a video input, allocate and fill the video stream structures for the writer */
     if( pC->novideo == M4OSA_FALSE )
     {
@@ -6626,7 +6594,6 @@
                 switch( pC->InputFileProperties.VideoStreamType )
                 {
                     case M4VIDEOEDITING_kMPEG4:
-                    case M4VIDEOEDITING_kMPEG4_EMP: /* RC */
                         pC->WriterVideoStream.streamType = M4SYS_kMPEG_4;
                         break;
 
@@ -9340,13 +9307,7 @@
     M4READER_3GP_H263Properties H263prop;
     M4OSA_ERR err;
     M4OSA_UInt32 videoBitrate;
-    M4DECODER_AVCProfileLevel AVCProfle;
-#ifdef M4VSS_ENABLE_EXTERNAL_DECODERS
-
     M4DECODER_VideoSize videoSize;
-
-#endif /* M4VSS_ENABLE_EXTERNAL_DECODERS */
-
     M4_AACType iAacType = 0;
 
     /**
@@ -9376,10 +9337,10 @@
     pC->InputFileProperties.uiVideoHeight = 0;
     pC->InputFileProperties.uiVideoTimeScale = 0;
     pC->InputFileProperties.fAverageFrameRate = 0.0;
-    pC->InputFileProperties.ProfileAndLevel =
-        M4VIDEOEDITING_kProfile_and_Level_Out_Of_Range;
-    pC->InputFileProperties.uiH263level = 0;
-    pC->InputFileProperties.uiVideoProfile = 0;
+    pC->InputFileProperties.uiVideoLevel =
+        M4VIDEOEDITING_VIDEO_UNKNOWN_LEVEL;
+    pC->InputFileProperties.uiVideoProfile =
+        M4VIDEOEDITING_VIDEO_UNKNOWN_PROFILE;
     pC->InputFileProperties.bMPEG4dataPartition = M4OSA_FALSE;
     pC->InputFileProperties.bMPEG4rvlc = M4OSA_FALSE;
     pC->InputFileProperties.bMPEG4resynchMarker = M4OSA_FALSE;
@@ -9450,7 +9411,6 @@
             && (M4VIDEOEDITING_kH264
             != pC->InputFileProperties.VideoStreamType) )
         {
-#ifdef M4VSS_ENABLE_EXTERNAL_DECODERS
             /* Use the DSI parsing function from the external video shell decoder.
             See the comments in M4VSS3GPP_ClipAnalysis.c, it's pretty much the
             same issue. */
@@ -9472,47 +9432,6 @@
 
             pC->pReaderVideoStream->m_videoWidth = videoSize.m_uiWidth;
             pC->pReaderVideoStream->m_videoHeight = videoSize.m_uiHeight;
-
-#else
-            /*FB 2009-02-09: add a check on the video decoder context to
-            avoid crash when the MCS is used only with audio codecs compilated*/
-
-            if( pC->m_pVideoDecoder != M4OSA_NULL )
-            {
-                if( M4OSA_NULL == pC->pViDecCtxt )
-                {
-                    err = pC->m_pVideoDecoder->m_pFctCreate(&pC->pViDecCtxt,
-                        &pC->pReaderVideoStream->m_basicProperties,
-                        pC->m_pReaderDataIt, &pC->ReaderVideoAU,
-                        M4OSA_NULL);
-
-                    if( M4NO_ERROR != err )
-                    {
-                        M4OSA_TRACE1_1(
-                            "M4MCS_intGetInputClipProperties:\
-                             m_pVideoDecoder->m_pFctCreate returns 0x%x!",
-                            err);
-                        return err;
-                    }
-                }
-
-                err = pC->m_pVideoDecoder->m_pFctGetOption(pC->pViDecCtxt,
-                    M4DECODER_MPEG4_kOptionID_DecoderConfigInfo,
-                    &DecConfInfo);
-
-                if( M4NO_ERROR != err )
-                {
-                    M4OSA_TRACE1_1(
-                        "M4MCS_intGetInputClipProperties:\
-                         m_pVideoDecoder->m_pFctGetOption returns 0x%x!",
-                        err);
-                    return err;
-                }
-            }
-
-#endif /* M4VSS_ENABLE_EXTERNAL_DECODERS */
-
-            pC->InputFileProperties.uiVideoProfile = DecConfInfo.uiProfile;
             pC->InputFileProperties.uiVideoTimeScale = DecConfInfo.uiTimeScale;
             pC->InputFileProperties.bMPEG4dataPartition =
                 DecConfInfo.bDataPartition;
@@ -9520,241 +9439,45 @@
             pC->InputFileProperties.bMPEG4resynchMarker =
                 DecConfInfo.uiUseOfResynchMarker;
 
-            /* Supported enum value for profile and level */
-            switch( pC->InputFileProperties.uiVideoProfile )
-            {
-                case 0x08:
-                    pC->InputFileProperties.ProfileAndLevel =
-                        M4VIDEOEDITING_kMPEG4_SP_Level_0;
-                    break;
-
-                case 0x09:
-                    pC->InputFileProperties.ProfileAndLevel =
-                        M4VIDEOEDITING_kMPEG4_SP_Level_0b;
-                    break;
-
-                case 0x01:
-                    pC->InputFileProperties.ProfileAndLevel =
-                        M4VIDEOEDITING_kMPEG4_SP_Level_1;
-                    break;
-
-                case 0x02:
-                    pC->InputFileProperties.ProfileAndLevel =
-                        M4VIDEOEDITING_kMPEG4_SP_Level_2;
-                    break;
-
-                case 0x03:
-                    pC->InputFileProperties.ProfileAndLevel =
-                        M4VIDEOEDITING_kMPEG4_SP_Level_3;
-                    break;
-
-                case 0x04:
-                    pC->InputFileProperties.ProfileAndLevel =
-                        M4VIDEOEDITING_kMPEG4_SP_Level_4a;
-                    break;
-
-                case 0x05:
-                    pC->InputFileProperties.ProfileAndLevel =
-                        M4VIDEOEDITING_kMPEG4_SP_Level_5;
-                    break;
-            }
-        }
-        else if( M4VIDEOEDITING_kH263
-            == pC->InputFileProperties.VideoStreamType )
-        {
-            err = pC->m_pReader->m_pFctGetOption(pC->pReaderContext,
-                M4READER_3GP_kOptionID_H263Properties, &H263prop);
-
-            if( M4NO_ERROR != err )
-            {
-                M4OSA_TRACE1_1(
-                    "M4MCS_intGetInputClipProperties: m_pReader->m_pFctGetOption returns 0x%x!",
-                    err);
+            err = getMPEG4ProfileAndLevel(DecConfInfo.uiProfile,
+                        &(pC->InputFileProperties.uiVideoProfile),
+                        &(pC->InputFileProperties.uiVideoLevel));
+            if ( M4NO_ERROR != err ) {
+                M4OSA_TRACE1_1("M4MCS_intGetInputClipProperties():\
+                    getMPEG4ProfileAndLevel returns 0x%08X", err);
                 return err;
             }
+        }
+        else if( M4VIDEOEDITING_kH263 ==
+            pC->InputFileProperties.VideoStreamType ) {
 
-            pC->InputFileProperties.uiH263level = H263prop.uiLevel;
-            pC->InputFileProperties.uiVideoProfile = H263prop.uiProfile;
-
-            /* Supported enum value for profile and level */
-            if( pC->InputFileProperties.uiVideoProfile == 0 )
-            {
-                switch( pC->InputFileProperties.uiH263level )
-                {
-                    case 10:
-                        pC->InputFileProperties.ProfileAndLevel =
-                            M4VIDEOEDITING_kH263_Profile_0_Level_10;
-                        break;
-
-                    case 20:
-                        pC->InputFileProperties.ProfileAndLevel =
-                            M4VIDEOEDITING_kH263_Profile_0_Level_20;
-                        break;
-
-                    case 30:
-                        pC->InputFileProperties.ProfileAndLevel =
-                            M4VIDEOEDITING_kH263_Profile_0_Level_30;
-                        break;
-
-                    case 40:
-                        pC->InputFileProperties.ProfileAndLevel =
-                            M4VIDEOEDITING_kH263_Profile_0_Level_40;
-                        break;
-
-                    case 45:
-                        pC->InputFileProperties.ProfileAndLevel =
-                            M4VIDEOEDITING_kH263_Profile_0_Level_45;
-                        break;
-                }
+            err = getH263ProfileAndLevel(pC->pReaderVideoStream->
+                        m_basicProperties.m_pDecoderSpecificInfo,
+                        pC->pReaderVideoStream->m_basicProperties.m_decoderSpecificInfoSize,
+                        &(pC->InputFileProperties.uiVideoProfile),
+                        &(pC->InputFileProperties.uiVideoLevel));
+            if ( M4NO_ERROR != err ) {
+                M4OSA_TRACE1_1("M4MCS_intGetInputClipProperties():\
+                    getH263ProfileAndLevel returns 0x%08X", err);
+                return err;
             }
-
             /* For h263 set default timescale : 30000:1001 */
             pC->InputFileProperties.uiVideoTimeScale = 30000;
         }
-        else if( M4VIDEOEDITING_kH264
-            == pC->InputFileProperties.VideoStreamType )
-        {
-            AVCProfle = M4DECODER_AVC_kProfile_and_Level_Out_Of_Range;
+        else if ( M4VIDEOEDITING_kH264 ==
+            pC->InputFileProperties.VideoStreamType ) {
+
             pC->InputFileProperties.uiVideoTimeScale = 30000;
-#ifdef M4VSS_ENABLE_EXTERNAL_DECODERS
-
-            err = M4DECODER_EXTERNAL_ParseAVCDSI(pC->pReaderVideoStream->
-                m_basicProperties.m_pDecoderSpecificInfo,
-                pC->pReaderVideoStream->
-                m_basicProperties.m_decoderSpecificInfoSize,
-                &AVCProfle);
-
-            if( M4NO_ERROR != err )
-            {
-                M4OSA_TRACE1_1(
-                    "M4MCS_intGetInputClipProperties():\
-                     M4DECODER_EXTERNAL_ParseAVCDSI returns 0x%08X",
-                    err);
+            err = getAVCProfileAndLevel(pC->pReaderVideoStream->
+                        m_basicProperties.m_pDecoderSpecificInfo,
+                        pC->pReaderVideoStream->m_basicProperties.m_decoderSpecificInfoSize,
+                        &(pC->InputFileProperties.uiVideoProfile),
+                        &(pC->InputFileProperties.uiVideoLevel));
+            if ( M4NO_ERROR != err ) {
+                M4OSA_TRACE1_1("M4MCS_intGetInputClipProperties():\
+                    getAVCProfileAndLevel returns 0x%08X", err);
                 return err;
             }
-
-#else
-
-            if( pC->m_pVideoDecoder != M4OSA_NULL )
-            {
-                if( M4OSA_NULL == pC->pViDecCtxt )
-                {
-                    err = pC->m_pVideoDecoder->m_pFctCreate(&pC->pViDecCtxt,
-                        &pC->pReaderVideoStream->m_basicProperties,
-                        pC->m_pReaderDataIt, &pC->ReaderVideoAU,
-                        M4OSA_NULL);
-
-                    if( M4NO_ERROR != err )
-                    {
-                        M4OSA_TRACE1_1(
-                            "M4MCS_intGetInputClipProperties:\
-                             m_pVideoDecoder->m_pFctCreate returns 0x%x!",
-                            err);
-                        return err;
-                    }
-                }
-                err = pC->m_pVideoDecoder->m_pFctGetOption(pC->pViDecCtxt,
-                    M4DECODER_kOptionID_AVCProfileAndLevel, &AVCProfle);
-
-                if( M4NO_ERROR != err )
-                {
-                    M4OSA_TRACE1_1(
-                        "M4MCS_intGetInputClipProperties:\
-                         m_pVideoDecoder->m_pFctGetOption returns 0x%x!",
-                        err);
-                    return err;
-                }
-            }
-
-#endif /* M4VSS_ENABLE_EXTERNAL_DECODERS */
-
-            switch( AVCProfle )
-            {
-                case M4DECODER_AVC_kProfile_0_Level_1:
-                    pC->InputFileProperties.ProfileAndLevel =
-                        M4VIDEOEDITING_kH264_Profile_0_Level_1;
-                    break;
-
-                case M4DECODER_AVC_kProfile_0_Level_1b:
-                    pC->InputFileProperties.ProfileAndLevel =
-                        M4VIDEOEDITING_kH264_Profile_0_Level_1b;
-                    break;
-
-                case M4DECODER_AVC_kProfile_0_Level_1_1:
-                    pC->InputFileProperties.ProfileAndLevel =
-                        M4VIDEOEDITING_kH264_Profile_0_Level_1_1;
-                    break;
-
-                case M4DECODER_AVC_kProfile_0_Level_1_2:
-                    pC->InputFileProperties.ProfileAndLevel =
-                        M4VIDEOEDITING_kH264_Profile_0_Level_1_2;
-                    break;
-
-                case M4DECODER_AVC_kProfile_0_Level_1_3:
-                    pC->InputFileProperties.ProfileAndLevel =
-                        M4VIDEOEDITING_kH264_Profile_0_Level_1_3;
-                    break;
-
-                case M4DECODER_AVC_kProfile_0_Level_2:
-                    pC->InputFileProperties.ProfileAndLevel =
-                        M4VIDEOEDITING_kH264_Profile_0_Level_2;
-                    break;
-
-                case M4DECODER_AVC_kProfile_0_Level_2_1:
-                    pC->InputFileProperties.ProfileAndLevel =
-                        M4VIDEOEDITING_kH264_Profile_0_Level_2_1;
-                    break;
-
-                case M4DECODER_AVC_kProfile_0_Level_2_2:
-                    pC->InputFileProperties.ProfileAndLevel =
-                        M4VIDEOEDITING_kH264_Profile_0_Level_2_2;
-                    break;
-
-                case M4DECODER_AVC_kProfile_0_Level_3:
-                    pC->InputFileProperties.ProfileAndLevel =
-                        M4VIDEOEDITING_kH264_Profile_0_Level_3;
-                    break;
-
-                case M4DECODER_AVC_kProfile_0_Level_3_1:
-                    pC->InputFileProperties.ProfileAndLevel =
-                        M4VIDEOEDITING_kH264_Profile_0_Level_3_1;
-                    break;
-
-                case M4DECODER_AVC_kProfile_0_Level_3_2:
-                    pC->InputFileProperties.ProfileAndLevel =
-                        M4VIDEOEDITING_kH264_Profile_0_Level_3_2;
-                    break;
-
-                case M4DECODER_AVC_kProfile_0_Level_4:
-                    pC->InputFileProperties.ProfileAndLevel =
-                        M4VIDEOEDITING_kH264_Profile_0_Level_4;
-                    break;
-
-                case M4DECODER_AVC_kProfile_0_Level_4_1:
-                    pC->InputFileProperties.ProfileAndLevel =
-                        M4VIDEOEDITING_kH264_Profile_0_Level_4_1;
-                    break;
-
-                case M4DECODER_AVC_kProfile_0_Level_4_2:
-                    pC->InputFileProperties.ProfileAndLevel =
-                        M4VIDEOEDITING_kH264_Profile_0_Level_4_2;
-                    break;
-
-                case M4DECODER_AVC_kProfile_0_Level_5:
-                    pC->InputFileProperties.ProfileAndLevel =
-                        M4VIDEOEDITING_kH264_Profile_0_Level_5;
-                    break;
-
-                case M4DECODER_AVC_kProfile_0_Level_5_1:
-                    pC->InputFileProperties.ProfileAndLevel =
-                        M4VIDEOEDITING_kH264_Profile_0_Level_5_1;
-                    break;
-
-                case M4DECODER_AVC_kProfile_and_Level_Out_Of_Range:
-                default:
-                    pC->InputFileProperties.ProfileAndLevel =
-                        M4VIDEOEDITING_kProfile_and_Level_Out_Of_Range;
-            }
         }
 
         /* Here because width x height is correct only after dsi parsing
@@ -10021,17 +9744,6 @@
     err = pC->m_pReader->m_pFctGetOption(pC->pReaderContext,
         M4READER_kOptionID_3gpFtypBox, &pC->InputFileProperties.ftyp);
 
-    if( M4NO_ERROR == err )
-    {
-        M4OSA_UInt8 i;
-
-        for ( i = 0; i < pC->InputFileProperties.ftyp.nbCompatibleBrands; i++ )
-            if( M4VIDEOEDITING_BRAND_EMP
-                == pC->InputFileProperties.ftyp.compatible_brands[i] )
-                pC->InputFileProperties.VideoStreamType =
-                M4VIDEOEDITING_kMPEG4_EMP;
-    }
-
     /* Analysis is successful */
     if( pC->InputFileProperties.uiClipVideoDuration
         > pC->InputFileProperties.uiClipAudioDuration )
diff --git a/libvideoeditor/vss/mcs/src/M4MCS_Codecs.c b/libvideoeditor/vss/mcs/src/M4MCS_Codecs.c
index 9a00f38..554492b 100755
--- a/libvideoeditor/vss/mcs/src/M4MCS_Codecs.c
+++ b/libvideoeditor/vss/mcs/src/M4MCS_Codecs.c
@@ -680,7 +680,6 @@
             encoderType = M4ENCODER_kH263;
             break;
         case M4VIDEOEDITING_kMPEG4:
-        case M4VIDEOEDITING_kMPEG4_EMP:
             encoderType = M4ENCODER_kMPEG4;
             break;
         case M4VIDEOEDITING_kH264:
diff --git a/libvideoeditor/vss/src/Android.mk b/libvideoeditor/vss/src/Android.mk
index 11483fa..2001f0d 100755
--- a/libvideoeditor/vss/src/Android.mk
+++ b/libvideoeditor/vss/src/Android.mk
@@ -69,6 +69,7 @@
     $(TOP)/frameworks/media/libvideoeditor/vss/common/inc \
     $(TOP)/frameworks/media/libvideoeditor/vss/stagefrightshells/inc \
     $(TOP)/frameworks/base/services/audioflinger \
+    $(TOP)/frameworks/base/include/media/stagefright/openmax
 
 
 LOCAL_SHARED_LIBRARIES += libdl
diff --git a/libvideoeditor/vss/src/M4PTO3GPP_API.c b/libvideoeditor/vss/src/M4PTO3GPP_API.c
index 2d4afdf..042ffb7 100755
--- a/libvideoeditor/vss/src/M4PTO3GPP_API.c
+++ b/libvideoeditor/vss/src/M4PTO3GPP_API.c
@@ -311,7 +311,6 @@
      * Video Format */
     if( (M4VIDEOEDITING_kH263 != pParams->OutputVideoFormat) &&
         (M4VIDEOEDITING_kMPEG4 != pParams->OutputVideoFormat) &&
-        (M4VIDEOEDITING_kMPEG4_EMP != pParams->OutputVideoFormat) &&
         (M4VIDEOEDITING_kH264 != pParams->OutputVideoFormat)) {
         M4OSA_TRACE1_0("M4PTO3GPP_Open: Undefined output video format");
         return ERR_PTO3GPP_UNDEFINED_OUTPUT_VIDEO_FORMAT;
@@ -1003,8 +1002,7 @@
     {
         /* HW encoder: fetch the DSI from the shell video encoder, and feed it to the writer before
         closing it. */
-        if ( (M4VIDEOEDITING_kMPEG4_EMP == pC->m_Params.OutputVideoFormat)
-            || (M4VIDEOEDITING_kMPEG4 == pC->m_Params.OutputVideoFormat)
+        if ((M4VIDEOEDITING_kMPEG4 == pC->m_Params.OutputVideoFormat)
             || (M4VIDEOEDITING_kH264 == pC->m_Params.OutputVideoFormat))
         {
             osaErr = pC->m_pEncoderInt->pFctGetOption(pC->m_pMp4EncoderContext,
@@ -1226,7 +1224,6 @@
     M4ENCODER_Format        encFormat;
     M4ENCODER_AdvancedParams   EncParams;    /**< Encoder advanced parameters */
     M4SYS_StreamIDValue     optionValue;
-    M4OSA_Bool              bActivateEmp = M4OSA_FALSE;
 
     M4OSA_TRACE3_1("M4PTO3GPP_Ready4Processing called with pC=0x%x", pC);
 
@@ -1243,7 +1240,6 @@
      *  Get the correct encoder interface */
     switch(pC->m_Params.OutputVideoFormat)
     {
-        case M4VIDEOEDITING_kMPEG4_EMP: bActivateEmp = M4OSA_TRUE; /* no break */
         case M4VIDEOEDITING_kMPEG4:
 #ifdef M4VSS_SUPPORT_ENCODER_MPEG4
                 err = VideoEditorVideoEncoder_getInterface_MPEG4(&encFormat, &pC->m_pEncoderInt,
@@ -1407,7 +1403,6 @@
      * Video format */
     switch(pC->m_Params.OutputVideoFormat)
     {
-        case M4VIDEOEDITING_kMPEG4_EMP :
         case M4VIDEOEDITING_kMPEG4 :
             EncParams.Format    = M4ENCODER_kMPEG4;
             break;
@@ -1482,28 +1477,6 @@
     }
 
     /**
-     * In case of EMP, we have to explicitely give an emp ftyp to the writer */
-    if(M4OSA_TRUE == bActivateEmp)
-    {
-        M4VIDEOEDITING_FtypBox ftyp;
-
-        ftyp.major_brand          = M4VIDEOEDITING_BRAND_3GP4;
-        ftyp.minor_version        = M4VIDEOEDITING_BRAND_0000;
-        ftyp.nbCompatibleBrands   = 2;
-        ftyp.compatible_brands[0] = M4VIDEOEDITING_BRAND_3GP4;
-        ftyp.compatible_brands[1] = M4VIDEOEDITING_BRAND_EMP;
-
-        err = pC->m_pWriterGlobInt->pFctSetOption(pC->m_p3gpWriterContext,
-            (M4OSA_UInt32)M4WRITER_kSetFtypBox, (M4OSA_DataOption) &ftyp);
-        if (M4NO_ERROR != err)
-        {
-            M4OSA_TRACE1_1("M4PTO3GPP_Ready4Processing:\
-                         m_pWriterGlobInt->pFctSetOption(M4WRITER_kSetFtypBox) returns 0x%x!", err);
-            return err;
-        }
-    }
-
-    /**
      *  Allocate and fill the video stream structures for the writer */
     pC->m_pWriterVideoStream =
         (M4SYS_StreamDescription*)M4OSA_32bitAlignedMalloc(sizeof(M4SYS_StreamDescription), M4PTO3GPP,
@@ -1541,7 +1514,6 @@
      * Video format */
     switch(pC->m_Params.OutputVideoFormat)
     {
-        case M4VIDEOEDITING_kMPEG4_EMP:
         case M4VIDEOEDITING_kMPEG4:
             pC->m_pWriterVideoStream->streamType = M4SYS_kMPEG_4;   break;
         case M4VIDEOEDITING_kH263:
@@ -1709,28 +1681,20 @@
     EncParams.bInternalRegulation = M4OSA_TRUE; //M4OSA_FALSE;
     EncParams.uiStartingQuantizerValue = M4PTO3GPP_QUANTIZER_STEP;
 
+    EncParams.videoProfile = pC->m_Params.videoProfile;
+    EncParams.videoLevel = pC->m_Params.videoLevel;
+
     /**
      * Other encoder settings */
-    if(M4OSA_TRUE == bActivateEmp)
-    {
-        EncParams.uiHorizontalSearchRange  = 15;            /* set value */
-        EncParams.uiVerticalSearchRange    = 15;            /* set value */
-        EncParams.bErrorResilience         = M4OSA_FALSE;   /* no error resilience */
-        EncParams.uiIVopPeriod             = 15;            /* one I frame every 15 frames */
-        EncParams.uiMotionEstimationTools  = 1;             /* M4V_MOTION_EST_TOOLS_NO_4MV */
-        EncParams.bAcPrediction            = M4OSA_FALSE;   /* no AC prediction */
-        EncParams.bDataPartitioning        = M4OSA_FALSE;   /* no data partitioning */
-    }
-    else
-    {
-        EncParams.uiHorizontalSearchRange  = 0;             /* use default */
-        EncParams.uiVerticalSearchRange    = 0;             /* use default */
-        EncParams.bErrorResilience         = M4OSA_FALSE;   /* no error resilience */
-        EncParams.uiIVopPeriod             = 15;             /* use default */
-        EncParams.uiMotionEstimationTools  = 0;             /* M4V_MOTION_EST_TOOLS_ALL */
-        EncParams.bAcPrediction            = M4OSA_TRUE;    /* use AC prediction */
-        EncParams.bDataPartitioning        = M4OSA_FALSE;   /* no data partitioning */
-    }
+
+    EncParams.uiHorizontalSearchRange  = 0;             /* use default */
+    EncParams.uiVerticalSearchRange    = 0;             /* use default */
+    EncParams.bErrorResilience         = M4OSA_FALSE;   /* no error resilience */
+    EncParams.uiIVopPeriod             = 15;             /* use default */
+    EncParams.uiMotionEstimationTools  = 0;             /* M4V_MOTION_EST_TOOLS_ALL */
+    EncParams.bAcPrediction            = M4OSA_TRUE;    /* use AC prediction */
+    EncParams.bDataPartitioning        = M4OSA_FALSE;   /* no data partitioning */
+
 
     /**
      * Create video encoder */
diff --git a/libvideoeditor/vss/src/M4VD_EXTERNAL_BitstreamParser.c b/libvideoeditor/vss/src/M4VD_EXTERNAL_BitstreamParser.c
index 4150070..3026ab9 100755
--- a/libvideoeditor/vss/src/M4VD_EXTERNAL_BitstreamParser.c
+++ b/libvideoeditor/vss/src/M4VD_EXTERNAL_BitstreamParser.c
@@ -13,13 +13,14 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-
+#include "utils/Log.h"
 #include "M4OSA_Types.h"
 #include "M4OSA_Debug.h"
 
 #include "M4VD_EXTERNAL_Interface.h"
 #include "M4VD_Tools.h"
-
+#include "M4_VideoEditingCommon.h"
+#include "OMX_Video.h"
 /**
  ************************************************************************
  * @file   M4VD_EXTERNAL_BitstreamParser.c
@@ -28,6 +29,58 @@
  ************************************************************************
  */
 
+typedef struct {
+    M4OSA_UInt8 code;
+    M4OSA_Int32 profile;
+    M4OSA_Int32 level;
+} codeProfileLevel;
+
+static codeProfileLevel mpeg4ProfileLevelTable[] = {
+    {0x01, OMX_VIDEO_MPEG4ProfileSimple, OMX_VIDEO_MPEG4Level1},
+    {0x02, OMX_VIDEO_MPEG4ProfileSimple, OMX_VIDEO_MPEG4Level2},
+    {0x03, OMX_VIDEO_MPEG4ProfileSimple, OMX_VIDEO_MPEG4Level3},
+    {0x04, OMX_VIDEO_MPEG4ProfileSimple, OMX_VIDEO_MPEG4Level4a},
+    {0x05, OMX_VIDEO_MPEG4ProfileSimple, OMX_VIDEO_MPEG4Level5},
+    {0x08, OMX_VIDEO_MPEG4ProfileSimple, OMX_VIDEO_MPEG4Level0},
+    {0x11, OMX_VIDEO_MPEG4ProfileSimpleScalable,OMX_VIDEO_MPEG4Level1},
+    {0x12, OMX_VIDEO_MPEG4ProfileSimpleScalable,OMX_VIDEO_MPEG4Level2},
+    {0x21, OMX_VIDEO_MPEG4ProfileCore, OMX_VIDEO_MPEG4Level1},
+    {0x22, OMX_VIDEO_MPEG4ProfileCore, OMX_VIDEO_MPEG4Level2},
+    {0x32, OMX_VIDEO_MPEG4ProfileMain, OMX_VIDEO_MPEG4Level2},
+    {0x33, OMX_VIDEO_MPEG4ProfileMain, OMX_VIDEO_MPEG4Level3},
+    {0x34, OMX_VIDEO_MPEG4ProfileMain, OMX_VIDEO_MPEG4Level4},
+    {0x42, OMX_VIDEO_MPEG4ProfileNbit, OMX_VIDEO_MPEG4Level2},
+    {0x51, OMX_VIDEO_MPEG4ProfileScalableTexture, OMX_VIDEO_MPEG4Level1},
+    {0x61, OMX_VIDEO_MPEG4ProfileSimpleFace, OMX_VIDEO_MPEG4Level1},
+    {0x62, OMX_VIDEO_MPEG4ProfileSimpleFace, OMX_VIDEO_MPEG4Level2},
+    {0x71, OMX_VIDEO_MPEG4ProfileBasicAnimated, OMX_VIDEO_MPEG4Level1},
+    {0x72, OMX_VIDEO_MPEG4ProfileBasicAnimated, OMX_VIDEO_MPEG4Level2},
+    {0x81, OMX_VIDEO_MPEG4ProfileHybrid, OMX_VIDEO_MPEG4Level1},
+    {0x82, OMX_VIDEO_MPEG4ProfileHybrid, OMX_VIDEO_MPEG4Level2},
+    {0x91, OMX_VIDEO_MPEG4ProfileAdvancedRealTime, OMX_VIDEO_MPEG4Level1},
+    {0x92, OMX_VIDEO_MPEG4ProfileAdvancedRealTime, OMX_VIDEO_MPEG4Level2},
+    {0x93, OMX_VIDEO_MPEG4ProfileAdvancedRealTime, OMX_VIDEO_MPEG4Level3},
+    {0x94, OMX_VIDEO_MPEG4ProfileAdvancedRealTime, OMX_VIDEO_MPEG4Level4},
+    {0xa1, OMX_VIDEO_MPEG4ProfileCoreScalable, OMX_VIDEO_MPEG4Level1},
+    {0xa2, OMX_VIDEO_MPEG4ProfileCoreScalable, OMX_VIDEO_MPEG4Level2},
+    {0xa3, OMX_VIDEO_MPEG4ProfileCoreScalable, OMX_VIDEO_MPEG4Level3},
+    {0xb1, OMX_VIDEO_MPEG4ProfileAdvancedCoding, OMX_VIDEO_MPEG4Level1},
+    {0xb2, OMX_VIDEO_MPEG4ProfileAdvancedCoding, OMX_VIDEO_MPEG4Level2},
+    {0xb3, OMX_VIDEO_MPEG4ProfileAdvancedCoding, OMX_VIDEO_MPEG4Level3},
+    {0xb4, OMX_VIDEO_MPEG4ProfileAdvancedCoding, OMX_VIDEO_MPEG4Level4},
+    {0xc1, OMX_VIDEO_MPEG4ProfileAdvancedCore, OMX_VIDEO_MPEG4Level1},
+    {0xc2, OMX_VIDEO_MPEG4ProfileAdvancedCore, OMX_VIDEO_MPEG4Level2},
+    {0xd1, OMX_VIDEO_MPEG4ProfileAdvancedScalable, OMX_VIDEO_MPEG4Level1},
+    {0xd2, OMX_VIDEO_MPEG4ProfileAdvancedScalable, OMX_VIDEO_MPEG4Level2},
+    {0xd3, OMX_VIDEO_MPEG4ProfileAdvancedScalable, OMX_VIDEO_MPEG4Level3},
+    {0xf0, OMX_VIDEO_MPEG4ProfileAdvancedSimple, OMX_VIDEO_MPEG4Level0},
+    {0xf1, OMX_VIDEO_MPEG4ProfileAdvancedSimple, OMX_VIDEO_MPEG4Level1},
+    {0xf2, OMX_VIDEO_MPEG4ProfileAdvancedSimple, OMX_VIDEO_MPEG4Level2},
+    {0xf3, OMX_VIDEO_MPEG4ProfileAdvancedSimple, OMX_VIDEO_MPEG4Level3},
+    {0xf4, OMX_VIDEO_MPEG4ProfileAdvancedSimple, OMX_VIDEO_MPEG4Level4},
+    {0xf5, OMX_VIDEO_MPEG4ProfileAdvancedSimple, OMX_VIDEO_MPEG4Level5}
+};
+
 M4OSA_UInt32 M4VD_EXTERNAL_GetBitsFromMemory(M4VS_Bitstream_ctxt* parsingCtxt,
      M4OSA_UInt32 nb_bits)
 {
@@ -434,90 +487,212 @@
     return M4NO_ERROR;
 }
 
-M4OSA_ERR M4DECODER_EXTERNAL_ParseAVCDSI(M4OSA_UInt8* pDSI, M4OSA_Int32 DSISize,
-                                         M4DECODER_AVCProfileLevel *profile)
-{
-    M4OSA_ERR err = M4NO_ERROR;
-    M4OSA_Bool NALSPS_and_Profile0Found = M4OSA_FALSE;
+M4OSA_ERR getAVCProfileAndLevel(M4OSA_UInt8* pDSI, M4OSA_Int32 DSISize,
+                      M4OSA_Int32 *pProfile, M4OSA_Int32 *pLevel) {
+
     M4OSA_UInt16 index = 28; /* the 29th byte is SPS start */
     M4OSA_Bool constraintSet3;
 
-    if (DSISize <= index) {
-        M4OSA_TRACE1_0("M4DECODER_EXTERNAL_ParseAVCDSI: DSI is invalid");
-        *profile = M4DECODER_AVC_kProfile_and_Level_Out_Of_Range;
+    if ((pProfile == M4OSA_NULL) || (pLevel == M4OSA_NULL)) {
         return M4ERR_PARAMETER;
     }
 
-    /* check for baseline profile */
-    if(((pDSI[index] & 0x1f) == 0x07) && (pDSI[index+1] == 0x42))
-    {
-        NALSPS_and_Profile0Found = M4OSA_TRUE;
+    if ((DSISize <= index) || (pDSI == M4OSA_NULL)) {
+        LOGE("getAVCProfileAndLevel: DSI is invalid");
+        *pProfile = M4VIDEOEDITING_VIDEO_UNKNOWN_PROFILE;
+        *pLevel = M4VIDEOEDITING_VIDEO_UNKNOWN_LEVEL;
+        return M4ERR_PARAMETER;
     }
 
-    if(M4OSA_FALSE == NALSPS_and_Profile0Found)
-    {
-        M4OSA_TRACE1_1("M4DECODER_EXTERNAL_ParseAVCDSI: index bad = %d", index);
-        *profile = M4DECODER_AVC_kProfile_and_Level_Out_Of_Range;
-    }
-    else
-    {
-        M4OSA_TRACE1_1("M4DECODER_EXTERNAL_ParseAVCDSI: index = %d", index);
-        constraintSet3 = (pDSI[index+2] & 0x10);
-        M4OSA_TRACE1_1("M4DECODER_EXTERNAL_ParseAVCDSI: level = %d", pDSI[index+3]);
-        switch(pDSI[index+3])
-        {
-        case 10:
-            *profile = M4DECODER_AVC_kProfile_0_Level_1;
+    constraintSet3 = (pDSI[index+2] & 0x10);
+    LOGV("getAVCProfileAndLevel profile_byte %d, level_byte: %d constrain3flag",
+          pDSI[index+1], pDSI[index+3], constraintSet3);
+
+    switch (pDSI[index+1]) {
+        case 66:
+            *pProfile = OMX_VIDEO_AVCProfileBaseline;
             break;
-        case 11:
-            if(constraintSet3)
-                *profile = M4DECODER_AVC_kProfile_0_Level_1b;
-            else
-                *profile = M4DECODER_AVC_kProfile_0_Level_1_1;
+        case 77:
+            *pProfile = OMX_VIDEO_AVCProfileMain;
             break;
-        case 12:
-            *profile = M4DECODER_AVC_kProfile_0_Level_1_2;
+        case 88:
+            *pProfile = OMX_VIDEO_AVCProfileExtended;
             break;
-        case 13:
-            *profile = M4DECODER_AVC_kProfile_0_Level_1_3;
+        case 100:
+            *pProfile = OMX_VIDEO_AVCProfileHigh;
             break;
-        case 20:
-            *profile = M4DECODER_AVC_kProfile_0_Level_2;
+        case 110:
+            *pProfile = OMX_VIDEO_AVCProfileHigh10;
             break;
-        case 21:
-            *profile = M4DECODER_AVC_kProfile_0_Level_2_1;
+        case 122:
+            *pProfile = OMX_VIDEO_AVCProfileHigh422;
             break;
-        case 22:
-            *profile = M4DECODER_AVC_kProfile_0_Level_2_2;
-            break;
-        case 30:
-            *profile = M4DECODER_AVC_kProfile_0_Level_3;
-            break;
-        case 31:
-            *profile = M4DECODER_AVC_kProfile_0_Level_3_1;
-            break;
-        case 32:
-            *profile = M4DECODER_AVC_kProfile_0_Level_3_2;
-            break;
-        case 40:
-            *profile = M4DECODER_AVC_kProfile_0_Level_4;
-            break;
-        case 41:
-            *profile = M4DECODER_AVC_kProfile_0_Level_4_1;
-            break;
-        case 42:
-            *profile = M4DECODER_AVC_kProfile_0_Level_4_2;
-            break;
-        case 50:
-            *profile = M4DECODER_AVC_kProfile_0_Level_5;
-            break;
-        case 51:
-            *profile = M4DECODER_AVC_kProfile_0_Level_5_1;
+        case 244:
+            *pProfile = OMX_VIDEO_AVCProfileHigh444;
             break;
         default:
-            *profile = M4DECODER_AVC_kProfile_and_Level_Out_Of_Range;
-        }
+            *pProfile = M4VIDEOEDITING_VIDEO_UNKNOWN_PROFILE;
     }
-    return err;
+
+    switch (pDSI[index+3]) {
+        case 10:
+            *pLevel = OMX_VIDEO_AVCLevel1;
+            break;
+        case 11:
+            if (constraintSet3)
+                *pLevel = OMX_VIDEO_AVCLevel1b;
+            else
+                *pLevel = OMX_VIDEO_AVCLevel11;
+            break;
+        case 12:
+            *pLevel = OMX_VIDEO_AVCLevel12;
+            break;
+        case 13:
+            *pLevel = OMX_VIDEO_AVCLevel13;
+            break;
+        case 20:
+            *pLevel = OMX_VIDEO_AVCLevel2;
+            break;
+        case 21:
+            *pLevel = OMX_VIDEO_AVCLevel21;
+            break;
+        case 22:
+            *pLevel = OMX_VIDEO_AVCLevel22;
+            break;
+        case 30:
+            *pLevel = OMX_VIDEO_AVCLevel3;
+            break;
+        case 31:
+            *pLevel = OMX_VIDEO_AVCLevel31;
+            break;
+        case 32:
+            *pLevel = OMX_VIDEO_AVCLevel32;
+            break;
+        case 40:
+            *pLevel = OMX_VIDEO_AVCLevel4;
+            break;
+        case 41:
+            *pLevel = OMX_VIDEO_AVCLevel41;
+            break;
+        case 42:
+            *pLevel = OMX_VIDEO_AVCLevel42;
+            break;
+        case 50:
+            *pLevel = OMX_VIDEO_AVCLevel5;
+            break;
+        case 51:
+            *pLevel = OMX_VIDEO_AVCLevel51;
+            break;
+        default:
+            *pLevel = M4VIDEOEDITING_VIDEO_UNKNOWN_LEVEL;
+    }
+    LOGI("getAVCProfileAndLevel profile %ld level %ld", *pProfile, *pLevel);
+    return M4NO_ERROR;
 }
 
+M4OSA_ERR getH263ProfileAndLevel(M4OSA_UInt8* pDSI, M4OSA_Int32 DSISize,
+                      M4OSA_Int32 *pProfile, M4OSA_Int32 *pLevel) {
+
+    M4OSA_UInt16 index = 7; /* the 5th and 6th bytes contain the level and profile */
+
+    if ((pProfile == M4OSA_NULL) || (pLevel == M4OSA_NULL)) {
+        LOGE("getH263ProfileAndLevel invalid pointer for pProfile");
+        return M4ERR_PARAMETER;
+    }
+
+    if ((DSISize < index) || (pDSI == M4OSA_NULL)) {
+        LOGE("getH263ProfileAndLevel: DSI is invalid");
+        *pProfile = M4VIDEOEDITING_VIDEO_UNKNOWN_PROFILE;
+        *pLevel = M4VIDEOEDITING_VIDEO_UNKNOWN_LEVEL;
+        return M4ERR_PARAMETER;
+    }
+    LOGV("getH263ProfileAndLevel profile_byte %d, level_byte",
+          pDSI[6], pDSI[5]);
+    /* get the H263 level */
+    switch (pDSI[5]) {
+        case 10:
+            *pLevel = OMX_VIDEO_H263Level10;
+            break;
+        case 20:
+            *pLevel = OMX_VIDEO_H263Level20;
+            break;
+        case 30:
+            *pLevel = OMX_VIDEO_H263Level30;
+            break;
+        case 40:
+            *pLevel = OMX_VIDEO_H263Level40;
+            break;
+        case 45:
+            *pLevel = OMX_VIDEO_H263Level45;
+            break;
+        case 50:
+            *pLevel = OMX_VIDEO_H263Level50;
+            break;
+        case 60:
+            *pLevel = OMX_VIDEO_H263Level60;
+            break;
+        case 70:
+            *pLevel = OMX_VIDEO_H263Level70;
+            break;
+        default:
+           *pLevel = M4VIDEOEDITING_VIDEO_UNKNOWN_LEVEL;
+    }
+
+    /* get H263 profile */
+    switch (pDSI[6]) {
+        case 0:
+            *pProfile = OMX_VIDEO_H263ProfileBaseline;
+            break;
+        case 1:
+            *pProfile = OMX_VIDEO_H263ProfileH320Coding;
+            break;
+        case 2:
+            *pProfile = OMX_VIDEO_H263ProfileBackwardCompatible;
+            break;
+        case 3:
+            *pProfile = OMX_VIDEO_H263ProfileISWV2;
+            break;
+        case 4:
+            *pProfile = OMX_VIDEO_H263ProfileISWV3;
+            break;
+        case 5:
+            *pProfile = OMX_VIDEO_H263ProfileHighCompression;
+            break;
+        case 6:
+            *pProfile = OMX_VIDEO_H263ProfileInternet;
+            break;
+        case 7:
+            *pProfile = OMX_VIDEO_H263ProfileInterlace;
+            break;
+        case 8:
+            *pProfile = OMX_VIDEO_H263ProfileHighLatency;
+            break;
+        default:
+           *pProfile = M4VIDEOEDITING_VIDEO_UNKNOWN_PROFILE;
+    }
+    LOGI("getH263ProfileAndLevel profile %ld level %ld", *pProfile, *pLevel);
+    return M4NO_ERROR;
+}
+
+M4OSA_ERR getMPEG4ProfileAndLevel(M4OSA_UInt8 profileAndLevel,
+                      M4OSA_Int32 *pProfile, M4OSA_Int32 *pLevel) {
+
+    M4OSA_UInt32 i = 0;
+    M4OSA_UInt32 length = 0;
+    if ((pProfile == M4OSA_NULL) || (pLevel == M4OSA_NULL)) {
+        return M4ERR_PARAMETER;
+    }
+    LOGV("getMPEG4ProfileAndLevel profileAndLevel %d", profileAndLevel);
+    length = sizeof(mpeg4ProfileLevelTable) /sizeof(mpeg4ProfileLevelTable[0]);
+    *pProfile = M4VIDEOEDITING_VIDEO_UNKNOWN_PROFILE;
+    *pLevel = M4VIDEOEDITING_VIDEO_UNKNOWN_LEVEL;
+    for (i = 0; i < length; i++) {
+        if (mpeg4ProfileLevelTable[i].code == profileAndLevel) {
+            *pProfile = mpeg4ProfileLevelTable[i].profile;
+            *pLevel = mpeg4ProfileLevelTable[i].level;
+            break;
+        }
+    }
+    LOGI("getMPEG4ProfileAndLevel profile %ld level %ld", *pProfile, *pLevel);
+    return M4NO_ERROR;
+}
diff --git a/libvideoeditor/vss/src/M4VSS3GPP_AudioMixing.c b/libvideoeditor/vss/src/M4VSS3GPP_AudioMixing.c
index c2bdd75..bf0bc06 100755
--- a/libvideoeditor/vss/src/M4VSS3GPP_AudioMixing.c
+++ b/libvideoeditor/vss/src/M4VSS3GPP_AudioMixing.c
@@ -178,7 +178,6 @@
     pC->ewc.VideoStreamType = M4SYS_kVideoUnknown;
     pC->ewc.bVideoDataPartitioning = M4OSA_FALSE;
     pC->ewc.pVideoOutputDsi = M4OSA_NULL;
-    pC->ewc.bActivateEmp = M4OSA_FALSE;
     pC->ewc.AudioStreamType = M4SYS_kAudioUnknown;
     pC->ewc.uiNbChannels = 1;
     pC->ewc.pAudioOutputDsi = M4OSA_NULL;
@@ -925,16 +924,16 @@
         pC->pInputClipCtxt->pSettings->ClipProperties.uiVideoTimeScale;
     pC->ewc.bVideoDataPartitioning =
         pC->pInputClipCtxt->pSettings->ClipProperties.bMPEG4dataPartition;
-
+    pC->ewc.outputVideoProfile =
+        pC->pInputClipCtxt->pSettings->ClipProperties.uiVideoProfile;
+    pC->ewc.outputVideoLevel =
+        pC->pInputClipCtxt->pSettings->ClipProperties.uiVideoLevel;
     switch( pC->pInputClipCtxt->pSettings->ClipProperties.VideoStreamType )
     {
         case M4VIDEOEDITING_kH263:
             pC->ewc.VideoStreamType = M4SYS_kH263;
             break;
 
-        case M4VIDEOEDITING_kMPEG4_EMP:
-            pC->ewc.bActivateEmp = M4OSA_TRUE; /* no break */
-
         case M4VIDEOEDITING_kMPEG4:
             pC->ewc.VideoStreamType = M4SYS_kMPEG_4;
             break;
@@ -3906,6 +3905,8 @@
     EncParams.FrameWidth = pC->ewc.uiVideoWidth;
     EncParams.FrameHeight = pC->ewc.uiVideoHeight;
     EncParams.uiTimeScale = pC->ewc.uiVideoTimeScale;
+    EncParams.videoProfile = pC->ewc.outputVideoProfile;
+    EncParams.videoLevel = pC->ewc.outputVideoLevel;
 
     /* No strict regulation in video editor */
     /* Because of the effects and transitions we should allow more flexibility */
@@ -3977,19 +3978,6 @@
             return M4VSS3GPP_ERR_EDITING_UNSUPPORTED_VIDEO_FORMAT;
     }
 
-    /* In case of EMP we overwrite certain parameters */
-    if( M4OSA_TRUE == pC->ewc.bActivateEmp )
-    {
-        EncParams.uiHorizontalSearchRange = 15;    /* set value */
-        EncParams.uiVerticalSearchRange = 15;      /* set value */
-        EncParams.bErrorResilience = M4OSA_FALSE;  /* no error resilience */
-        EncParams.uiIVopPeriod = 15; /* one I frame every 15 frames */
-        EncParams.uiMotionEstimationTools = 1; /* M4V_MOTION_EST_TOOLS_NO_4MV */
-        EncParams.bAcPrediction = M4OSA_FALSE;     /* no AC prediction */
-        EncParams.uiStartingQuantizerValue = 10;   /* initial QP = 10 */
-        EncParams.bDataPartitioning = M4OSA_FALSE; /* no data partitioning */
-    }
-
     EncParams.Bitrate =
         pC->pInputClipCtxt->pSettings->ClipProperties.uiVideoBitrate;
 
@@ -4014,7 +4002,8 @@
     pC->ewc.encoderState = M4VSS3GPP_kEncoderClosed;
     M4OSA_TRACE1_0(
         "M4VSS3GPP_intAudioMixingCreateVideoEncoder: calling encoder pFctOpen");
-
+    M4OSA_TRACE1_2("vss: audio mix encoder open profile :%d, level %d",
+        EncParams.videoProfile, EncParams.videoLevel);
     err = pC->ShellAPI.pVideoEncoderGlobalFcts->pFctOpen(pC->ewc.pEncContext,
         &pC->ewc.WriterVideoAU, &EncParams);
 
diff --git a/libvideoeditor/vss/src/M4VSS3GPP_ClipAnalysis.c b/libvideoeditor/vss/src/M4VSS3GPP_ClipAnalysis.c
index 723c0c1..e2c6d7a 100755
--- a/libvideoeditor/vss/src/M4VSS3GPP_ClipAnalysis.c
+++ b/libvideoeditor/vss/src/M4VSS3GPP_ClipAnalysis.c
@@ -33,12 +33,8 @@
 #include "M4VSS3GPP_InternalTypes.h"
 #include "M4VSS3GPP_InternalFunctions.h"
 #include "M4VSS3GPP_InternalConfig.h"
-
-
-#ifdef M4VSS_ENABLE_EXTERNAL_DECODERS
 #include "M4VD_EXTERNAL_Interface.h"
 
-#endif
 
 /**
  *    OSAL headers */
@@ -377,10 +373,10 @@
     pClipProperties->uiVideoHeight = 0;
     pClipProperties->uiVideoTimeScale = 0;
     pClipProperties->fAverageFrameRate = 0.0;
-    pClipProperties->ProfileAndLevel =
-        M4VIDEOEDITING_kProfile_and_Level_Out_Of_Range;
-    pClipProperties->uiH263level = 0;
-    pClipProperties->uiVideoProfile = 0;
+    pClipProperties->uiVideoProfile =
+        M4VIDEOEDITING_VIDEO_UNKNOWN_PROFILE;
+    pClipProperties->uiVideoLevel =
+        M4VIDEOEDITING_VIDEO_UNKNOWN_LEVEL;
     pClipProperties->bMPEG4dataPartition = M4OSA_FALSE;
     pClipProperties->bMPEG4rvlc = M4OSA_FALSE;
     pClipProperties->bMPEG4resynchMarker = M4OSA_FALSE;
@@ -403,7 +399,6 @@
 
                 pClipProperties->VideoStreamType = M4VIDEOEDITING_kMPEG4;
 
-#ifdef M4VSS_ENABLE_EXTERNAL_DECODERS
    /* This issue is so incredibly stupid that it's depressing. Basically, a file can be analysed
    outside of any context (besides that of the clip itself), so that for instance two clips can
    be checked for compatibility before allocating an edit context for editing them. But this
@@ -422,10 +417,9 @@
          whatsoever). */
 
                 err = M4DECODER_EXTERNAL_ParseVideoDSI(pClipCtxt->pVideoStream->
-                    m_basicProperties.m_pDecoderSpecificInfo,
-                    pClipCtxt->pVideoStream->
-                    m_basicProperties.m_decoderSpecificInfoSize,
-                    &DecConfigInfo, &dummySize);
+                            m_basicProperties.m_pDecoderSpecificInfo,
+                            pClipCtxt->pVideoStream->m_basicProperties.m_decoderSpecificInfoSize,
+                            &DecConfigInfo, &dummySize);
 
                 if( M4NO_ERROR != err )
                 {
@@ -435,252 +429,66 @@
                     return err;
                 }
 
-    #else /* an external decoder cannot be present, so we can rely on the
-                software decoder to be installed already */
-                /* Get MPEG-4 decoder config. */
-
-                err = pClipCtxt->ShellAPI.m_pVideoDecoder->m_pFctGetOption(
-                    pClipCtxt->pViDecCtxt,
-                    M4DECODER_MPEG4_kOptionID_DecoderConfigInfo,
-                    &DecConfigInfo);
-
-                if( M4NO_ERROR != err )
-                {
-                    M4OSA_TRACE1_1("M4VSS3GPP_intBuildAnalysis(): m_pFctGetOption(DecConfigInfo)\
-                        returns 0x%x", err);
-                    return err;
-                }
-
-    #endif /* M4VSS_ENABLE_EXTERNAL_DECODERS */
-
-                pClipProperties->uiVideoProfile = DecConfigInfo.uiProfile;
-                pClipProperties->uiVideoTimeScale = DecConfigInfo.uiTimeScale;
+                pClipProperties->uiVideoTimeScale =
+                    DecConfigInfo.uiTimeScale;
                 pClipProperties->bMPEG4dataPartition =
                     DecConfigInfo.bDataPartition;
-                pClipProperties->bMPEG4rvlc = DecConfigInfo.bUseOfRVLC;
+                pClipProperties->bMPEG4rvlc =
+                    DecConfigInfo.bUseOfRVLC;
                 pClipProperties->bMPEG4resynchMarker =
                     DecConfigInfo.uiUseOfResynchMarker;
-
-                /* Supported enum value for profile and level */
-                switch( pClipProperties->uiVideoProfile )
-                {
-                    case 0x08:
-                        pClipProperties->ProfileAndLevel =
-                            M4VIDEOEDITING_kMPEG4_SP_Level_0;
-                        break;
-
-                    case 0x09:
-                        pClipProperties->ProfileAndLevel =
-                            M4VIDEOEDITING_kMPEG4_SP_Level_0b;
-                        break;
-
-                    case 0x01:
-                        pClipProperties->ProfileAndLevel =
-                            M4VIDEOEDITING_kMPEG4_SP_Level_1;
-                        break;
-
-                    case 0x02:
-                        pClipProperties->ProfileAndLevel =
-                            M4VIDEOEDITING_kMPEG4_SP_Level_2;
-                        break;
-
-                    case 0x03:
-                        pClipProperties->ProfileAndLevel =
-                            M4VIDEOEDITING_kMPEG4_SP_Level_3;
-                        break;
-
-                    case 0x04:
-                        pClipProperties->ProfileAndLevel =
-                            M4VIDEOEDITING_kMPEG4_SP_Level_4a;
-                        break;
-
-                    case 0x05:
-                        pClipProperties->ProfileAndLevel =
-                            M4VIDEOEDITING_kMPEG4_SP_Level_5;
-                        break;
+                err = getMPEG4ProfileAndLevel(DecConfigInfo.uiProfile,
+                            &(pClipProperties->uiVideoProfile),
+                            &(pClipProperties->uiVideoLevel));
+               if (M4NO_ERROR != err) {
+                    M4OSA_TRACE1_1("M4VSS3GPP_intBuildAnalysis(): \
+                         getMPEG4ProfileAndLevel returns 0x%08X", err);
+                    return err;
                 }
                 break;
 
             case M4DA_StreamTypeVideoH263:
 
                 pClipProperties->VideoStreamType = M4VIDEOEDITING_kH263;
-
-                /* Get H263 level, which is sixth byte in the DSI */
-                pClipProperties->uiH263level = pClipCtxt->pVideoStream->
-                    m_basicProperties.m_pDecoderSpecificInfo[5];
-                /* Get H263 profile, which is fifth byte in the DSI */
-                pClipProperties->uiVideoProfile = pClipCtxt->pVideoStream->
-                    m_basicProperties.m_pDecoderSpecificInfo[6];
                 /* H263 time scale is always 30000 */
                 pClipProperties->uiVideoTimeScale = 30000;
 
-                /* Supported enum value for profile and level */
-                if( pClipProperties->uiVideoProfile == 0 )
-                {
-                    switch( pClipProperties->uiH263level )
-                    {
-                        case 10:
-                            pClipProperties->ProfileAndLevel =
-                                M4VIDEOEDITING_kH263_Profile_0_Level_10;
-                            break;
-
-                        case 20:
-                            pClipProperties->ProfileAndLevel =
-                                M4VIDEOEDITING_kH263_Profile_0_Level_20;
-                            break;
-
-                        case 30:
-                            pClipProperties->ProfileAndLevel =
-                                M4VIDEOEDITING_kH263_Profile_0_Level_30;
-                            break;
-
-                        case 40:
-                            pClipProperties->ProfileAndLevel =
-                                M4VIDEOEDITING_kH263_Profile_0_Level_40;
-                            break;
-
-                        case 45:
-                            pClipProperties->ProfileAndLevel =
-                                M4VIDEOEDITING_kH263_Profile_0_Level_45;
-                            break;
-                    }
+                err = getH263ProfileAndLevel(pClipCtxt->pVideoStream->
+                            m_basicProperties.m_pDecoderSpecificInfo,
+                            pClipCtxt->pVideoStream->m_basicProperties.m_decoderSpecificInfoSize,
+                            &pClipProperties->uiVideoProfile,
+                            &pClipProperties->uiVideoLevel);
+                if (M4NO_ERROR != err) {
+                    M4OSA_TRACE1_1("M4VSS3GPP_intBuildAnalysis(): \
+                         getH263ProfileAndLevel returns 0x%08X", err);
+                    return err;
                 }
                 break;
 
             case M4DA_StreamTypeVideoMpeg4Avc:
 
                 pClipProperties->VideoStreamType = M4VIDEOEDITING_kH264;
-#ifdef M4VSS_ENABLE_EXTERNAL_DECODERS
-
-                err = M4DECODER_EXTERNAL_ParseAVCDSI(pClipCtxt->pVideoStream->
-                    m_basicProperties.m_pDecoderSpecificInfo,
-                    pClipCtxt->pVideoStream->
-                    m_basicProperties.m_decoderSpecificInfoSize,
-                    &AVCProfle);
-
-                if( M4NO_ERROR != err )
-                {
-                    M4OSA_TRACE1_1(
-                        "M4VSS3GPP_intBuildAnalysis(): \
-                         M4DECODER_EXTERNAL_ParseAVCDSI returns 0x%08X",
-                         err);
+                err = getAVCProfileAndLevel(pClipCtxt->pVideoStream->
+                            m_basicProperties.m_pDecoderSpecificInfo,
+                            pClipCtxt->pVideoStream->m_basicProperties.m_decoderSpecificInfoSize,
+                            &pClipProperties->uiVideoProfile,
+                            &pClipProperties->uiVideoLevel);
+                if (M4NO_ERROR != err) {
+                    M4OSA_TRACE1_1("M4VSS3GPP_intBuildAnalysis(): \
+                         getAVCProfileAndLevel returns 0x%08X", err);
                     return err;
                 }
-
-#else /* an external decoder cannot be present, so we can rely on the
-                software decoder to be installed already */
-
-                err = pClipCtxt->ShellAPI.m_pVideoDecoder->m_pFctGetOption(
-                    pClipCtxt->pViDecCtxt,
-                    M4DECODER_kOptionID_AVCProfileAndLevel, &AVCProfle);
-
-                if( M4NO_ERROR != err )
-                {
-                    M4OSA_TRACE1_1(
-                        "M4VSS3GPP_intBuildAnalysis(): m_pFctGetOption(AVCProfileInfo)\
-                            returns 0x%x", err);
-                    return err;
-                }
-
-#endif /* M4VSS_ENABLE_EXTERNAL_DECODERS */
-
-                switch( AVCProfle )
-                {
-                    case M4DECODER_AVC_kProfile_0_Level_1:
-                        pClipProperties->ProfileAndLevel =
-                            M4VIDEOEDITING_kH264_Profile_0_Level_1;
-                        break;
-
-                    case M4DECODER_AVC_kProfile_0_Level_1b:
-                        pClipProperties->ProfileAndLevel =
-                            M4VIDEOEDITING_kH264_Profile_0_Level_1b;
-                        break;
-
-                    case M4DECODER_AVC_kProfile_0_Level_1_1:
-                        pClipProperties->ProfileAndLevel =
-                            M4VIDEOEDITING_kH264_Profile_0_Level_1_1;
-                        break;
-
-                    case M4DECODER_AVC_kProfile_0_Level_1_2:
-                        pClipProperties->ProfileAndLevel =
-                            M4VIDEOEDITING_kH264_Profile_0_Level_1_2;
-                        break;
-
-                    case M4DECODER_AVC_kProfile_0_Level_1_3:
-                        pClipProperties->ProfileAndLevel =
-                            M4VIDEOEDITING_kH264_Profile_0_Level_1_3;
-                        break;
-
-                    case M4DECODER_AVC_kProfile_0_Level_2:
-                        pClipProperties->ProfileAndLevel =
-                            M4VIDEOEDITING_kH264_Profile_0_Level_2;
-                        break;
-
-                    case M4DECODER_AVC_kProfile_0_Level_2_1:
-                        pClipProperties->ProfileAndLevel =
-                            M4VIDEOEDITING_kH264_Profile_0_Level_2_1;
-                        break;
-
-                    case M4DECODER_AVC_kProfile_0_Level_2_2:
-                        pClipProperties->ProfileAndLevel =
-                            M4VIDEOEDITING_kH264_Profile_0_Level_2_2;
-                        break;
-
-                    case M4DECODER_AVC_kProfile_0_Level_3:
-                        pClipProperties->ProfileAndLevel =
-                            M4VIDEOEDITING_kH264_Profile_0_Level_3;
-                        break;
-
-                    case M4DECODER_AVC_kProfile_0_Level_3_1:
-                        pClipProperties->ProfileAndLevel =
-                            M4VIDEOEDITING_kH264_Profile_0_Level_3_1;
-                        break;
-
-                    case M4DECODER_AVC_kProfile_0_Level_3_2:
-                        pClipProperties->ProfileAndLevel =
-                            M4VIDEOEDITING_kH264_Profile_0_Level_3_2;
-                        break;
-
-                    case M4DECODER_AVC_kProfile_0_Level_4:
-                        pClipProperties->ProfileAndLevel =
-                            M4VIDEOEDITING_kH264_Profile_0_Level_4;
-                        break;
-
-                    case M4DECODER_AVC_kProfile_0_Level_4_1:
-                        pClipProperties->ProfileAndLevel =
-                            M4VIDEOEDITING_kH264_Profile_0_Level_4_1;
-                        break;
-
-                    case M4DECODER_AVC_kProfile_0_Level_4_2:
-                        pClipProperties->ProfileAndLevel =
-                            M4VIDEOEDITING_kH264_Profile_0_Level_4_2;
-                        break;
-
-                    case M4DECODER_AVC_kProfile_0_Level_5:
-                        pClipProperties->ProfileAndLevel =
-                            M4VIDEOEDITING_kH264_Profile_0_Level_5;
-                        break;
-
-                    case M4DECODER_AVC_kProfile_0_Level_5_1:
-                        pClipProperties->ProfileAndLevel =
-                            M4VIDEOEDITING_kH264_Profile_0_Level_5_1;
-                        break;
-
-                    case M4DECODER_AVC_kProfile_and_Level_Out_Of_Range:
-                    default:
-                        pClipProperties->ProfileAndLevel =
-                            M4VIDEOEDITING_kProfile_and_Level_Out_Of_Range;
-                }
-
                 break;
 
             default:
                 M4OSA_TRACE1_1(
                     "M4VSS3GPP_intBuildAnalysis: unknown input video format (0x%x),\
-                    returning M4NO_ERROR",pClipCtxt->pVideoStream->m_basicProperties.m_streamType);
-                return
-                    M4NO_ERROR; /**< We do not return error here.
-                                The video format compatibility check will be done latter */
+                     returning M4NO_ERROR",
+                    pClipCtxt->pVideoStream->m_basicProperties.m_streamType);
+
+                 /** We do not return error here.
+                   *  The video format compatibility check will be done latter */
+                return M4NO_ERROR;
         }
 
         pClipProperties->uiClipVideoDuration =
@@ -838,16 +646,6 @@
         pClipCtxt->pReaderContext,
         M4READER_kOptionID_3gpFtypBox, &pClipProperties->ftyp);
 
-    if( M4NO_ERROR == err )
-    {
-        M4OSA_UInt8 i;
-
-        for ( i = 0; i < pClipProperties->ftyp.nbCompatibleBrands; i++ )
-            if( M4VIDEOEDITING_BRAND_EMP
-                == pClipProperties->ftyp.compatible_brands[i] )
-                pClipProperties->VideoStreamType = M4VIDEOEDITING_kMPEG4_EMP;
-    }
-
     /**
     * We write the VSS 3GPP version in the clip analysis to be sure the integrator doesn't
     * mix older analysis results with newer libraries */
@@ -916,59 +714,12 @@
     if( M4VIDEOEDITING_kNoneVideo
         != pClipProperties->VideoStreamType ) /**< if there is a video stream */
     {
-        /**
-        * Check video format is MPEG-4 or H263 */
+        /* Check video format is MPEG-4, H263 or H264 */
         switch( pClipProperties->VideoStreamType )
         {
             case M4VIDEOEDITING_kH263:
-                if( M4VIDEOEDITING_kProfile_and_Level_Out_Of_Range
-                    == pClipProperties->ProfileAndLevel )
-                {
-                    M4OSA_TRACE1_0(
-                        "M4VSS3GPP_intCheckClipCompatibleWithVssEditing():\
-                        unsupported H263 profile");
-                    video_err = M4VSS3GPP_ERR_EDITING_UNSUPPORTED_H263_PROFILE;
-                    break;
-                }
-                uiNbOfValidStreams++;
-                pClipProperties->bVideoIsEditable = M4OSA_TRUE;
-                break;
-
-            case M4VIDEOEDITING_kMPEG4_EMP:
             case M4VIDEOEDITING_kMPEG4:
-                if( M4VIDEOEDITING_kProfile_and_Level_Out_Of_Range
-                    == pClipProperties->ProfileAndLevel )
-                {
-                    M4OSA_TRACE1_0(
-                        "M4VSS3GPP_intCheckClipCompatibleWithVssEditing():\
-                        unsupported MPEG-4 profile");
-                    video_err = M4VSS3GPP_ERR_EDITING_UNSUPPORTED_MPEG4_PROFILE;
-                    break;
-                }
-
-                if( M4OSA_TRUE == pClipProperties->bMPEG4rvlc )
-                {
-                    M4OSA_TRACE1_0(
-                        "M4VSS3GPP_intCheckClipCompatibleWithVssEditing():\
-                        unsupported MPEG-4 RVLC tool");
-                    video_err = M4VSS3GPP_ERR_EDITING_UNSUPPORTED_MPEG4_RVLC;
-                    break;
-                }
-                uiNbOfValidStreams++;
-                pClipProperties->bVideoIsEditable = M4OSA_TRUE;
-                break;
-
             case M4VIDEOEDITING_kH264:
-                if( M4VIDEOEDITING_kProfile_and_Level_Out_Of_Range
-                    == pClipProperties->ProfileAndLevel )
-                {
-                    M4OSA_TRACE1_0(
-                        "M4VSS3GPP_intCheckClipCompatibleWithVssEditing():\
-                        unsupported H264 profile");
-                    video_err = M4VSS3GPP_ERR_EDITING_UNSUPPORTED_H264_PROFILE;
-                    break;
-                }
-
                 uiNbOfValidStreams++;
                 pClipProperties->bVideoIsEditable = M4OSA_TRUE;
                 break;
diff --git a/libvideoeditor/vss/src/M4VSS3GPP_Edit.c b/libvideoeditor/vss/src/M4VSS3GPP_Edit.c
index 5bde983..9ac15a9 100755
--- a/libvideoeditor/vss/src/M4VSS3GPP_Edit.c
+++ b/libvideoeditor/vss/src/M4VSS3GPP_Edit.c
@@ -189,7 +189,6 @@
     pC->ewc.bVideoDataPartitioning = M4OSA_FALSE;
     pC->ewc.pVideoOutputDsi = M4OSA_NULL;
     pC->ewc.uiVideoOutputDsiSize = 0;
-    pC->ewc.bActivateEmp = M4OSA_FALSE;
     pC->ewc.AudioStreamType = M4SYS_kAudioUnknown;
     pC->ewc.uiNbChannels = 1;
     pC->ewc.uiAudioBitrate = 0;
@@ -332,10 +331,10 @@
     pClipSettings->ClipProperties.uiVideoHeight = 0;
     pClipSettings->ClipProperties.uiVideoTimeScale = 0;
     pClipSettings->ClipProperties.fAverageFrameRate = 0.0;
-    pClipSettings->ClipProperties.ProfileAndLevel =
-        M4VIDEOEDITING_kProfile_and_Level_Out_Of_Range;
-    pClipSettings->ClipProperties.uiH263level = 0;
-    pClipSettings->ClipProperties.uiVideoProfile = 0;
+    pClipSettings->ClipProperties.uiVideoProfile =
+        M4VIDEOEDITING_VIDEO_UNKNOWN_PROFILE;
+    pClipSettings->ClipProperties.uiVideoLevel =
+        M4VIDEOEDITING_VIDEO_UNKNOWN_LEVEL;
     pClipSettings->ClipProperties.bMPEG4dataPartition = M4OSA_FALSE;
     pClipSettings->ClipProperties.bMPEG4rvlc = M4OSA_FALSE;
     pClipSettings->ClipProperties.bMPEG4resynchMarker = M4OSA_FALSE;
@@ -951,6 +950,9 @@
 
     pC->ewc.uiVideoTimeScale        = 30;
     pC->ewc.bVideoDataPartitioning  = 0;
+    /* Set output video profile and level */
+    pC->ewc.outputVideoProfile = pC->xVSS.outputVideoProfile;
+    pC->ewc.outputVideoLevel = pC->xVSS.outputVideoLevel;
 
     switch(pC->xVSS.outputVideoFormat) {
         case M4VIDEOEDITING_kH263:
@@ -2303,32 +2305,6 @@
         return err;
     }
 
-    /**
-    * In case of EMP, we have to explicitely give an emp ftyp to the writer */
-    if( M4OSA_TRUE == pC_ewc->bActivateEmp )
-    {
-        M4VIDEOEDITING_FtypBox ftyp;
-
-        ftyp.major_brand = M4VIDEOEDITING_BRAND_3GP4;
-        ftyp.minor_version = M4VIDEOEDITING_BRAND_0000;
-        ftyp.nbCompatibleBrands = 2;
-        ftyp.compatible_brands[0] = M4VIDEOEDITING_BRAND_3GP4;
-        ftyp.compatible_brands[1] = M4VIDEOEDITING_BRAND_EMP;
-
-        err = pC_ShellAPI->pWriterGlobalFcts->pFctSetOption(
-            pC_ewc->p3gpWriterContext,
-            M4WRITER_kSetFtypBox, (M4OSA_DataOption) &ftyp);
-
-        if( M4NO_ERROR != err )
-        {
-            M4OSA_TRACE1_1(
-                "M4VSS3GPP_intCreate3GPPOutputFile:\
-                pWriterGlobalFcts->pFctSetOption(M4WRITER_kSetFtypBox) returns 0x%x!",
-                err);
-            return err;
-        }
-    }
-
     if( M4SYS_kVideoUnknown != pC_ewc->VideoStreamType )
     {
         /**
@@ -2610,8 +2586,6 @@
 M4VSS3GPP_intComputeOutputVideoAndAudioDsi( M4VSS3GPP_InternalEditContext *pC,
                                            M4OSA_UInt8 uiMasterClip )
 {
-    M4OSA_UInt8 uiCurrentLevel, uiNewLevel;
-    M4OSA_UInt8 uiCurrentProf, uiNewProf;
     M4OSA_Int32 iResynchMarkerDsiIndex;
     M4_StreamHandler *pStreamForDsi;
     M4VSS3GPP_ClipContext *pClip;
@@ -2660,313 +2634,20 @@
         pC->ewc.pVideoOutputDsi[4] = 0;
 
         /**
-        * We take the max level of all input streams, but 10 is the minimum */
-        uiCurrentLevel = 10;
-
-        for ( i = 0; i < pC->uiClipNumber; i++ )
-        {
-            if(pC->pClipList[i].bTranscodingRequired == M4OSA_FALSE) {
-                uiNewLevel = pC->pClipList[i].ClipProperties.uiH263level;
-                if (uiNewLevel > uiCurrentLevel) {
-                    uiCurrentLevel = uiNewLevel;
-                }
-            }
-        }
+        * Level is the sixth byte in the DSI */
+        pC->ewc.pVideoOutputDsi[5] = pC->xVSS.outputVideoLevel;
 
         /**
-        * Level is the sixth byte i the DSI */
-        pC->ewc.pVideoOutputDsi[5] = uiCurrentLevel;
-
-        /**
-        * Profile is always 0, and it's the seventh byte in the DSI */
-        pC->ewc.pVideoOutputDsi[6] = 0;
+        * Profile is the seventh byte in the DSI*/
+        pC->ewc.pVideoOutputDsi[6] = pC->xVSS.outputVideoProfile;
     }
 
     /**
     * MPEG-4 case */
-    else if( M4SYS_kMPEG_4 == pC->ewc.VideoStreamType )
-    {
-        /**
-        * Profile combination rules:
-        *   8 and x -> x
-        *   1, 2 or 3 -> max
-        *   9 and 1 -> 2
-        *   9 and 2 -> 2
-        *   9 and 3 -> 3
-        */
+    else if( M4SYS_kMPEG_4 == pC->ewc.VideoStreamType ||
+        M4SYS_kH264 == pC->ewc.VideoStreamType) {
 
-        /**
-        * Note:
-        *   The part of the output video encoded by the VSS3GPP
-        *   have a profile of 8.
-        *   Since 8 is the less "strong" profile (8 and x --> x),
-        *   we can check only the input clips to compute the
-        *   profile of the output combined clip.
-        */
-
-        /**
-        * Start with profile of the first clip */
-        M4OSA_TRACE1_0("M4VSS3GPP_intComputeOutputVideoAndAudioDsi: \
-            get DSI for Mpeg4 stream");
-        if(M4OSA_NULL == pC->ewc.pEncContext) {
-            M4OSA_TRACE1_0("M4VSS3GPP_intComputeOutputVideoAndAudioDsi: \
-                pC->ewc.pEncContext is NULL");
-            err = M4VSS3GPP_intCreateVideoEncoder(pC);
-            if(M4NO_ERROR != err) {
-                M4OSA_TRACE1_1("M4VSS3GPP_intComputeOutputVideoAndAudioDsi: \
-                    M4VSS3GPP_intCreateVideoEncoder returned error 0x%x", err);
-            }
-        }
-        if(M4OSA_NULL != pC->ewc.pEncContext) {
-            err = pC->ShellAPI.pVideoEncoderGlobalFcts->pFctGetOption(
-                    pC->ewc.pEncContext, M4ENCODER_kOptionID_EncoderHeader,
-                    (M4OSA_DataOption)&encHeader);
-            if ( (M4NO_ERROR != err) || (M4OSA_NULL == encHeader->pBuf)) {
-                M4OSA_TRACE1_1("M4VSS3GPP_intComputeOutputVideoAndAudioDsi: \
-                    failed to get the encoder header (err 0x%x)", err);
-                M4OSA_TRACE1_2("M4VSS3GPP_intComputeOutputVideoAndAudioDsi: \
-                    encHeader->pBuf=0x%x, size=0x%x", encHeader->pBuf,
-                    encHeader->Size);
-            }
-        }
-        err = M4DECODER_EXTERNAL_ParseVideoDSI((M4OSA_UInt8 *)encHeader->pBuf,
-                  encHeader->Size, &DecConfigInfo, &dummySize);
-        if (M4NO_ERROR != err) {
-            M4OSA_TRACE1_1("M4VSS3GPP_intBuildAnalysis(): \
-                M4DECODER_EXTERNAL_ParseVideoDSI returns 0x%08X", err);
-            return err;
-        }
-
-        uiCurrentProf = DecConfigInfo.uiProfile;
-
-        /**
-        * Combine current profile with the one of the next clip */
-        for (i=0; i<pC->uiClipNumber; i++) {
-            if(pC->pClipList[i].bTranscodingRequired == M4OSA_FALSE) {
-                uiNewProf = pC->pClipList[i].ClipProperties.uiVideoProfile;
-
-                switch( uiNewProf )
-                {
-                    case 8:
-                        /**< 8 + x --> x */
-                        /**< uiCurrentProf is not updated */
-                        break;
-
-                    case 1:
-                    case 2:
-                    case 3:
-                        switch( uiCurrentProf )
-                        {
-                            case 1:
-                            case 2:
-                            case 3:
-                            case 4:
-                            case 5:
-                                /**< 1, 2, 3, 4 or 5 -> max */
-                                uiCurrentProf = (uiCurrentProf > uiNewProf)
-                                    ? uiCurrentProf : uiNewProf;
-                                break;
-
-                            case 8: /**< 8 + x -> x */
-                                uiCurrentProf = uiNewProf;
-                                break;
-
-                            case 9:
-                                /**< 9 and 1 -> 2 */
-                                /**< 9 and 2 -> 2 */
-                                /**< 9 and 3 -> 3 */
-                                /**< 9 and 4 -> 4 */
-                                /**< 9 and 5 -> 5 */
-                                uiCurrentProf = (uiNewProf > 2) ? uiNewProf : 2;
-                                break;
-                        }
-                        break;
-
-                    case 9:
-                        switch( uiCurrentProf )
-                        {
-                            case 1:
-                            case 2:
-                            case 3:
-                                /**< 9 and 1 -> 2 */
-                                /**< 9 and 2 -> 2 */
-                                /**< 9 and 3 -> 3 */
-                                uiCurrentProf =
-                                    (uiCurrentProf > 2) ? uiCurrentProf : 2;
-                                break;
-
-                            case 9: /**< 9 + x -> x */
-                            case 8: /**< 8 + x -> x */
-                                uiCurrentProf = uiNewProf;
-                                break;
-                    }
-                }
-            }
-        }
-
-        /**
-        * Look for the DSI of an input video stream which would use the Resynch. Marker tool */
-        i = 0;
-        iResynchMarkerDsiIndex =
-            0; /**< By default we take the first DSI (if we find no Resynch Marker DSI) */
-
-        while( i < pC->uiClipNumber )
-        {
-            if ((M4OSA_TRUE ==
-                    pC->pClipList[i].ClipProperties.bMPEG4resynchMarker) &&
-                 (pC->pClipList[i].bTranscodingRequired == M4OSA_FALSE)) {
-                iResynchMarkerDsiIndex = i;
-                break; /**< we found it, get out the while loop */
-            }
-            i++;
-        }
-
-        /**
-        * Get the DSI of the clip found. If it is the first clip, it is already opened.
-        * Else we must open it (and later close it...) */
-        if( 0 == iResynchMarkerDsiIndex )
-        {
-            for (i=0; i<pC->uiClipNumber; i++) {
-                if(pC->pClipList[i].bTranscodingRequired == M4OSA_FALSE) {
-                    /**
-                    * We can use the fast open mode and the skip audio mode
-                      to get the DSI */
-                    err = M4VSS3GPP_intClipInit(&pClip, pC->pOsaFileReadPtr);
-                    if (M4NO_ERROR != err) {
-                        M4OSA_TRACE1_1(
-                            "M4VSS3GPP_intComputeOutputVideoAndAudioDsi: \
-                            M4VSS3GPP_intClipInit() returns 0x%x!", err);
-                        if (M4OSA_NULL != pClip) {
-                            M4VSS3GPP_intClipCleanUp(pClip);
-                        }
-                        return err;
-                    }
-                    err = M4VSS3GPP_intClipOpen(
-                              pClip, &pC->pClipList[i],
-                              M4OSA_TRUE, M4OSA_TRUE,
-                              M4OSA_TRUE);
-                    if (M4NO_ERROR != err) {
-                        M4OSA_TRACE1_1(
-                            "M4VSS3GPP_intComputeOutputVideoAndAudioDsi: \
-                            M4VSS3GPP_intClipOpen() returns 0x%x!", err);
-                        M4VSS3GPP_intClipCleanUp(pClip);
-                        return err;
-                    }
-                    pStreamForDsi = &(pClip->pVideoStream->m_basicProperties);
-                    /*got the DSI  */
-
-                    bGetDSiFromEncoder = M4OSA_TRUE;
-
-                    break;
-                }
-            }
-            if(bGetDSiFromEncoder == M4OSA_FALSE) {
-                /**
-                * Allocate and copy the new DSI */
-                pC->ewc.pVideoOutputDsi = (M4OSA_MemAddr8)M4OSA_32bitAlignedMalloc(
-                    encHeader->Size, M4VSS3GPP, (M4OSA_Char *)"ewc dsi (MPEG4)");
-                if (M4OSA_NULL == pC->ewc.pVideoOutputDsi) {
-                    M4OSA_TRACE1_0(
-                        "M4VSS3GPP_intComputeOutputVideoAndAudioDsi(): \
-                        unable to allocate pVideoOutputDsi (MPEG4)");
-                    return M4ERR_ALLOC;
-                }
-                pC->ewc.uiVideoOutputDsiSize = (M4OSA_UInt16)encHeader->Size;
-                memcpy((void *)pC->ewc.pVideoOutputDsi,
-                    (void *)encHeader->pBuf, pC->ewc.uiVideoOutputDsiSize);
-
-            }
-
-            err = M4VSS3GPP_intDestroyVideoEncoder(pC);
-            if(M4NO_ERROR != err) {
-                M4OSA_TRACE1_1("M4VSS3GPP_intComputeOutputVideoAndAudioDsi: \
-                    M4VSS3GPP_intDestroyVideoEncoder error 0x%x", err);
-            }
-        }
-        else
-        {
-            /**
-            * We can use the fast open mode and the skip audio mode to get the DSI */
-            err = M4VSS3GPP_intClipInit(&pClip, pC->pOsaFileReadPtr);
-
-            if( M4NO_ERROR != err )
-            {
-                M4OSA_TRACE1_1(
-                    "M4VSS3GPP_intComputeOutputVideoAndAudioDsi:\
-                    M4VSS3GPP_intClipInit() returns 0x%x!",
-                    err);
-
-                if( M4OSA_NULL != pClip )
-                {
-                    M4VSS3GPP_intClipCleanUp(pClip);
-                }
-                return err;
-            }
-
-            err = M4VSS3GPP_intClipOpen(pClip,
-                &pC->pClipList[iResynchMarkerDsiIndex], M4OSA_TRUE,
-                M4OSA_TRUE, M4OSA_TRUE);
-
-            if( M4NO_ERROR != err )
-            {
-                M4OSA_TRACE1_1(
-                    "M4VSS3GPP_intComputeOutputVideoAndAudioDsi:\
-                    M4VSS3GPP_intClipOpen() returns 0x%x!",
-                    err);
-                M4VSS3GPP_intClipCleanUp(pClip);
-                return err;
-            }
-
-            pStreamForDsi = &(pClip->pVideoStream->m_basicProperties);
-        }
-
-        if(pC->ewc.pVideoOutputDsi == M4OSA_NULL) {
-
-            /**
-            * Allocate and copy the new DSI */
-            pC->ewc.pVideoOutputDsi = (M4OSA_MemAddr8)M4OSA_32bitAlignedMalloc(
-                pStreamForDsi->m_decoderSpecificInfoSize,
-                M4VSS3GPP, (M4OSA_Char *)"pC->ewc.pVideoOutputDsi (MPEG4)");
-
-            if( M4OSA_NULL == pC->ewc.pVideoOutputDsi )
-            {
-                M4OSA_TRACE1_0(
-                    "M4VSS3GPP_intComputeOutputVideoAndAudioDsi():\
-                    unable to allocate pVideoOutputDsi (MPEG4), returning M4ERR_ALLOC");
-                return M4ERR_ALLOC;
-            }
-            pC->ewc.uiVideoOutputDsiSize =
-                (M4OSA_UInt16)pStreamForDsi->m_decoderSpecificInfoSize;
-            memcpy((void *)pC->ewc.pVideoOutputDsi,
-                (void *)pStreamForDsi->m_pDecoderSpecificInfo,
-                pC->ewc.uiVideoOutputDsiSize);
-        }
-
-        /**
-        * We rewrite the profile in the output DSI because it may not be the good one
-        * The profile and level is always at byte number 4 */
-        (pC->ewc.pVideoOutputDsi)[4] = uiCurrentProf;
-
-        /**
-        * If a clip has been temporarily opened to get its DSI, close it */
-        if( M4OSA_NULL != pClip )
-        {
-            err = M4VSS3GPP_intClipCleanUp(pClip);
-
-            if( M4NO_ERROR != err )
-            {
-                M4OSA_TRACE1_1(
-                    "M4VSS3GPP_intComputeOutputVideoAndAudioDsi:\
-                    M4VSS3GPP_intClipCleanUp() returns 0x%x!",
-                    err);
-                return err;
-            }
-        }
-    }
-    else if( M4SYS_kH264 == pC->ewc.VideoStreamType )
-    {
-
-        /* For H.264 encoder case
+        /* For MPEG4 and H.264 encoder case
         * Fetch the DSI from the shell video encoder, and feed it to the writer before
         closing it. */
 
@@ -3008,7 +2689,7 @@
             {
                 M4OSA_TRACE1_0(
                     "M4VSS3GPP_intComputeOutputVideoAndAudioDsi:\
-                    send DSI for H264 stream to 3GP writer");
+                     send DSI for video stream to 3GP writer");
 
                 /**
                 * Allocate and copy the new DSI */
@@ -3020,7 +2701,7 @@
                 {
                     M4OSA_TRACE1_0(
                         "M4VSS3GPP_intComputeOutputVideoAndAudioDsi():\
-                        unable to allocate pVideoOutputDsi (H264), returning M4ERR_ALLOC");
+                         unable to allocate pVideoOutputDsi, returning M4ERR_ALLOC");
                     return M4ERR_ALLOC;
                 }
                 pC->ewc.uiVideoOutputDsiSize = (M4OSA_UInt16)encHeader->Size;
diff --git a/libvideoeditor/vss/src/M4VSS3GPP_EditVideo.c b/libvideoeditor/vss/src/M4VSS3GPP_EditVideo.c
index e6271ea..b880dc3 100755
--- a/libvideoeditor/vss/src/M4VSS3GPP_EditVideo.c
+++ b/libvideoeditor/vss/src/M4VSS3GPP_EditVideo.c
@@ -2294,6 +2294,11 @@
     EncParams.uiStartingQuantizerValue = 10;   /* initial QP = 10 */
     EncParams.bDataPartitioning = M4OSA_FALSE; /* no data partitioning */
 
+    /**
+    * Set the video profile and level */
+    EncParams.videoProfile = pC->ewc.outputVideoProfile;
+    EncParams.videoLevel= pC->ewc.outputVideoLevel;
+
     switch ( pC->ewc.VideoStreamType )
     {
         case M4SYS_kH263:
@@ -2350,19 +2355,6 @@
             return M4VSS3GPP_ERR_EDITING_UNSUPPORTED_VIDEO_FORMAT;
     }
 
-    /* In case of EMP we overwrite certain parameters */
-    if( M4OSA_TRUE == pC->ewc.bActivateEmp )
-    {
-        EncParams.uiHorizontalSearchRange = 15;    /* set value */
-        EncParams.uiVerticalSearchRange = 15;      /* set value */
-        EncParams.bErrorResilience = M4OSA_FALSE;  /* no error resilience */
-        EncParams.uiIVopPeriod = 15; /* one I frame every 15 frames */
-        EncParams.uiMotionEstimationTools = 1; /* M4V_MOTION_EST_TOOLS_NO_4MV */
-        EncParams.bAcPrediction = M4OSA_FALSE;     /* no AC prediction */
-        EncParams.uiStartingQuantizerValue = 10;   /* initial QP = 10 */
-        EncParams.bDataPartitioning = M4OSA_FALSE; /* no data partitioning */
-    }
-
     if( pC->bIsMMS == M4OSA_FALSE )
     {
         EncParams.Bitrate = pC->xVSS.outputVideoBitrate;
diff --git a/libvideoeditor/vss/src/M4xVSS_API.c b/libvideoeditor/vss/src/M4xVSS_API.c
index 6bf8c81..a654f88 100755
--- a/libvideoeditor/vss/src/M4xVSS_API.c
+++ b/libvideoeditor/vss/src/M4xVSS_API.c
@@ -33,7 +33,8 @@
 #include "M4OSA_CharStar.h"
 // StageFright encoders require %16 resolution
 #include "M4ENCODER_common.h"
-
+#include "M4DECODER_Common.h"
+#include "VideoEditorVideoDecoder.h"
 
 /**
  * VSS 3GPP API definition */
@@ -664,6 +665,10 @@
             != pSettings->xVSS.outputVideoSize
             || xVSS_context->pSettings->xVSS.outputVideoFormat
             != pSettings->xVSS.outputVideoFormat
+            || xVSS_context->pSettings->xVSS.outputVideoProfile
+            != pSettings->xVSS.outputVideoProfile
+            || xVSS_context->pSettings->xVSS.outputVideoLevel
+            != pSettings->xVSS.outputVideoLevel
             || xVSS_context->pSettings->xVSS.outputAudioFormat
             != pSettings->xVSS.outputAudioFormat
             || xVSS_context->pSettings->xVSS.bAudioMono
@@ -796,6 +801,10 @@
     /* Copy settings from user given structure to our "local" structure */
     xVSS_context->pSettings->xVSS.outputVideoFormat =
         pSettings->xVSS.outputVideoFormat;
+    xVSS_context->pSettings->xVSS.outputVideoProfile =
+        pSettings->xVSS.outputVideoProfile;
+    xVSS_context->pSettings->xVSS.outputVideoLevel =
+        pSettings->xVSS.outputVideoLevel;
     xVSS_context->pSettings->xVSS.outputVideoSize =
         pSettings->xVSS.outputVideoSize;
     xVSS_context->pSettings->xVSS.outputAudioFormat =
@@ -888,8 +897,6 @@
         && xVSS_context->pSettings->xVSS.outputVideoFormat
         != M4VIDEOEDITING_kH263
         && xVSS_context->pSettings->xVSS.outputVideoFormat
-        != M4VIDEOEDITING_kMPEG4_EMP
-        && xVSS_context->pSettings->xVSS.outputVideoFormat
         != M4VIDEOEDITING_kH264 )
     {
         xVSS_context->pSettings->xVSS.outputVideoFormat =
@@ -2498,6 +2505,10 @@
                 {
                     pParams->OutputVideoFormat =
                         xVSS_context->pSettings->xVSS.outputVideoFormat;
+                    pParams->outputVideoProfile =
+                        xVSS_context->pSettings->xVSS.outputVideoProfile;
+                    pParams->outputVideoLevel =
+                        xVSS_context->pSettings->xVSS.outputVideoLevel;
                     pParams->OutputVideoFrameRate =
                         xVSS_context->pSettings->videoFrameRate;
                     pParams->OutputVideoFrameSize =
@@ -6317,3 +6328,12 @@
 
     return err;
 }
+
+M4OSA_ERR M4xVSS_getVideoDecoderCapabilities(M4DECODER_VideoDecoders **decoders) {
+    M4OSA_ERR err = M4NO_ERROR;
+
+    // Call the decoder api directly
+    // to get all the video decoder capablities.
+    err = VideoEditorVideoDecoder_getVideoDecodersAndCapabilities(decoders);
+    return err;
+}
diff --git a/libvideoeditor/vss/src/M4xVSS_internal.c b/libvideoeditor/vss/src/M4xVSS_internal.c
index 66e3b80..f4f4137 100755
--- a/libvideoeditor/vss/src/M4xVSS_internal.c
+++ b/libvideoeditor/vss/src/M4xVSS_internal.c
@@ -108,6 +108,8 @@
        MCS parameters chained list */
     Params.OutputFileType = xVSS_context->pMCScurrentParams->OutputFileType;
     Params.OutputVideoFormat = xVSS_context->pMCScurrentParams->OutputVideoFormat;
+    Params.outputVideoProfile= xVSS_context->pMCScurrentParams->outputVideoProfile;
+    Params.outputVideoLevel = xVSS_context->pMCScurrentParams->outputVideoLevel;
     Params.OutputVideoFrameSize = xVSS_context->pMCScurrentParams->OutputVideoFrameSize;
     Params.OutputVideoFrameRate = xVSS_context->pMCScurrentParams->OutputVideoFrameRate;
     Params.OutputAudioFormat = xVSS_context->pMCScurrentParams->OutputAudioFormat;
@@ -1520,6 +1522,8 @@
 
     Params.OutputVideoFrameSize = xVSS_context->pSettings->xVSS.outputVideoSize;
     Params.OutputVideoFormat = xVSS_context->pSettings->xVSS.outputVideoFormat;
+    Params.videoProfile = xVSS_context->pSettings->xVSS.outputVideoProfile;
+    Params.videoLevel = xVSS_context->pSettings->xVSS.outputVideoLevel;
 
     /**
      * Generate "dummy" amr file containing silence in temporary folder */
@@ -2370,6 +2374,10 @@
             xVSS_context->pSettings->xVSS.outputAudioBitrate ;
         pVSSContext->xVSS.bAudioMono =
             xVSS_context->pSettings->xVSS.bAudioMono;
+        pVSSContext->xVSS.outputVideoProfile =
+            xVSS_context->pSettings->xVSS.outputVideoProfile;
+        pVSSContext->xVSS.outputVideoLevel =
+            xVSS_context->pSettings->xVSS.outputVideoLevel;
     /* In case of MMS use case, we fill directly into the VSS context the targeted bitrate */
     if(xVSS_context->targetedBitrate != 0)
     {
diff --git a/libvideoeditor/vss/stagefrightshells/inc/VideoEditorVideoDecoder.h b/libvideoeditor/vss/stagefrightshells/inc/VideoEditorVideoDecoder.h
index f4092e2..1eea3a6 100755
--- a/libvideoeditor/vss/stagefrightshells/inc/VideoEditorVideoDecoder.h
+++ b/libvideoeditor/vss/stagefrightshells/inc/VideoEditorVideoDecoder.h
@@ -40,4 +40,7 @@
         M4DECODER_VideoType *pDecoderType,
         M4OSA_Context *pDecInterface);
 
+M4OSA_ERR VideoEditorVideoDecoder_getVideoDecodersAndCapabilities(
+    M4DECODER_VideoDecoders** decoders);
+
 #endif // VIDEOEDITOR_VIDEODECODER_H
diff --git a/libvideoeditor/vss/stagefrightshells/src/VideoEditorUtils.cpp b/libvideoeditor/vss/stagefrightshells/src/VideoEditorUtils.cpp
index 875d99d..70d864b 100755
--- a/libvideoeditor/vss/stagefrightshells/src/VideoEditorUtils.cpp
+++ b/libvideoeditor/vss/stagefrightshells/src/VideoEditorUtils.cpp
@@ -373,16 +373,6 @@
         }
     }
 
-    {
-        // Check on the profiles
-        // These profiles requires additional parameter set extensions
-        if (ctx.mProfileIdc == 100 || ctx.mProfileIdc == 110 ||
-            ctx.mProfileIdc == 122 || ctx.mProfileIdc == 144) {
-            LOGE("Sorry, no support for profile_idc: %d!", ctx.mProfileIdc);
-            return BAD_VALUE;
-        }
-    }
-
     // ISO 14496-15: AVC file format
     outputSize += 7;  // 7 more bytes in the header
     outputData = (uint8_t *)malloc(outputSize);
diff --git a/libvideoeditor/vss/stagefrightshells/src/VideoEditorVideoDecoder.cpp b/libvideoeditor/vss/stagefrightshells/src/VideoEditorVideoDecoder.cpp
index 13dea53..f038b47 100755
--- a/libvideoeditor/vss/stagefrightshells/src/VideoEditorVideoDecoder.cpp
+++ b/libvideoeditor/vss/stagefrightshells/src/VideoEditorVideoDecoder.cpp
@@ -31,7 +31,7 @@
 
 #include <media/stagefright/MetaData.h>
 #include <media/stagefright/MediaDefs.h>
-
+#include <media/stagefright/MediaDebug.h>
 /********************
  *   DEFINITIONS    *
  ********************/
@@ -636,81 +636,135 @@
     }
     return return_code;
 }
-
-M4OSA_ERR VideoEditorVideoDecoder_ParseAVCDSI(M4OSA_UInt8* pDSI,
-        M4OSA_Int32 DSISize, M4DECODER_AVCProfileLevel *profile) {
+void logSupportDecodersAndCapabilities(M4DECODER_VideoDecoders* decoders) {
+    VideoDecoder *pDecoder;
+    VideoComponentCapabilities *pOmxComponents = NULL;
+    VideoProfileLevel *pProfileLevel = NULL;
+    pDecoder = decoders->decoder;
+    for (size_t i = 0; i< decoders->decoderNumber; i++) {
+        LOGV("Supported Codec[%d] :%d", i, pDecoder->codec);
+        pOmxComponents = pDecoder->component;
+        for(size_t j = 0; j <  pDecoder->componentNumber; j++) {
+           pProfileLevel = pOmxComponents->profileLevel;
+           LOGV("-->component %d", j);
+           for(size_t k = 0; k < pOmxComponents->profileNumber; k++) {
+               LOGV("-->profile:%ld maxLevel:%ld", pProfileLevel->mProfile,
+                   pProfileLevel->mLevel);
+               pProfileLevel++;
+           }
+           pOmxComponents++;
+        }
+        pDecoder++;
+    }
+}
+M4OSA_ERR queryVideoDecoderCapabilities
+    (M4DECODER_VideoDecoders** decoders) {
     M4OSA_ERR err = M4NO_ERROR;
-    M4OSA_Bool NALSPS_and_Profile0Found = M4OSA_FALSE;
-    M4OSA_UInt16 index;
-    M4OSA_Bool constraintSet3;
+    const char *kMimeTypes[] = {
+        MEDIA_MIMETYPE_VIDEO_AVC, MEDIA_MIMETYPE_VIDEO_MPEG4,
+        MEDIA_MIMETYPE_VIDEO_H263
+    };
 
-    for(index = 0; index < (DSISize-1); index++) {
-        if(((pDSI[index] & 0x1f) == 0x07) && (pDSI[index+1] == 0x42)) {
-            NALSPS_and_Profile0Found = M4OSA_TRUE;
-            break;
-        }
-    }
-    if(M4OSA_FALSE == NALSPS_and_Profile0Found) {
-        LOGV("VideoEditorVideoDecoder_ParseAVCDSI: index bad = %d", index);
-        *profile = M4DECODER_AVC_kProfile_and_Level_Out_Of_Range;
-    } else {
-        LOGV("VideoEditorVideoDecoder_ParseAVCDSI: index = %d", index);
-        constraintSet3 = (pDSI[index+2] & 0x10);
-        LOGV("VideoEditorVideoDecoder_ParseAVCDSI: level = %d", pDSI[index+3]);
-        switch(pDSI[index+3]) {
-            case 10:
-                *profile = M4DECODER_AVC_kProfile_0_Level_1;
-                break;
-            case 11:
-                if(constraintSet3) {
-                    *profile = M4DECODER_AVC_kProfile_0_Level_1b;
-                } else {
-                    *profile = M4DECODER_AVC_kProfile_0_Level_1_1;
+    int32_t supportFormats = sizeof(kMimeTypes) / sizeof(kMimeTypes[0]);
+    M4DECODER_VideoDecoders *pDecoders;
+    VideoDecoder *pDecoder;
+    VideoComponentCapabilities *pOmxComponents = NULL;
+    VideoProfileLevel *pProfileLevel = NULL;
+    OMXClient client;
+    status_t status = OK;
+    SAFE_MALLOC(pDecoders, M4DECODER_VideoDecoders, 1, "VideoDecoders");
+    SAFE_MALLOC(pDecoder, VideoDecoder, supportFormats,
+        "VideoDecoder");
+    pDecoders->decoder = pDecoder;
+
+    pDecoders->decoderNumber= supportFormats;
+    status = client.connect();
+    CHECK(status == OK);
+    for (size_t k = 0; k < sizeof(kMimeTypes) / sizeof(kMimeTypes[0]);
+             ++k) {
+            Vector<CodecCapabilities> results;
+            CHECK_EQ(QueryCodecs(client.interface(), kMimeTypes[k],
+                                 true, // queryDecoders
+                                 &results), (status_t)OK);
+
+            if (results.size()) {
+                SAFE_MALLOC(pOmxComponents, VideoComponentCapabilities,
+                    results.size(), "VideoComponentCapabilities");
+                LOGV("K=%d",k);
+                pDecoder->component = pOmxComponents;
+                pDecoder->componentNumber = results.size();
+            }
+
+            for (size_t i = 0; i < results.size(); ++i) {
+                LOGV("  decoder '%s' supports ",
+                       results[i].mComponentName.string());
+
+                if (results[i].mProfileLevels.size() == 0) {
+                    LOGV("NOTHING.\n");
+                    continue;
                 }
-                break;
-            case 12:
-                *profile = M4DECODER_AVC_kProfile_0_Level_1_2;
-                break;
-            case 13:
-                *profile = M4DECODER_AVC_kProfile_0_Level_1_3;
-                break;
-            case 20:
-                *profile = M4DECODER_AVC_kProfile_0_Level_2;
-                break;
-            case 21:
-                *profile = M4DECODER_AVC_kProfile_0_Level_2_1;
-                break;
-            case 22:
-                *profile = M4DECODER_AVC_kProfile_0_Level_2_2;
-                break;
-            case 30:
-                *profile = M4DECODER_AVC_kProfile_0_Level_3;
-                break;
-            case 31:
-                *profile = M4DECODER_AVC_kProfile_0_Level_3_1;
-                break;
-            case 32:
-                *profile = M4DECODER_AVC_kProfile_0_Level_3_2;
-                break;
-            case 40:
-                *profile = M4DECODER_AVC_kProfile_0_Level_4;
-                break;
-            case 41:
-                *profile = M4DECODER_AVC_kProfile_0_Level_4_1;
-                break;
-            case 42:
-                *profile = M4DECODER_AVC_kProfile_0_Level_4_2;
-                break;
-            case 50:
-                *profile = M4DECODER_AVC_kProfile_0_Level_5;
-                break;
-            case 51:
-                *profile = M4DECODER_AVC_kProfile_0_Level_5_1;
-                break;
-            default:
-                *profile = M4DECODER_AVC_kProfile_and_Level_Out_Of_Range;
-        }
+                // Count the supported profiles
+                int32_t profileNumber = 0;
+                int32_t profile = -1;
+                for (size_t j = 0; j < results[i].mProfileLevels.size(); ++j) {
+                    const CodecProfileLevel &profileLevel =
+                        results[i].mProfileLevels[j];
+                    if (profileLevel.mProfile != profile) {
+                        profile = profileLevel.mProfile;
+                        profileNumber++;
+                    }
+                }
+                SAFE_MALLOC(pProfileLevel, VideoProfileLevel,
+                    profileNumber, "VideoProfileLevel");
+
+
+
+                pOmxComponents->profileLevel = pProfileLevel;
+
+                pOmxComponents->profileNumber = profileNumber;
+
+                // Get the max Level for each profile.
+                int32_t maxLevel = -1;
+                profile = -1;
+                profileNumber = 0;
+                for (size_t j = 0; j < results[i].mProfileLevels.size(); ++j) {
+                    const CodecProfileLevel &profileLevel =
+                        results[i].mProfileLevels[j];
+                    if (profile == -1 && maxLevel == -1) {
+                        profile = profileLevel.mProfile;
+                        maxLevel = profileLevel.mLevel;
+                    }
+                    if (profileLevel.mProfile != profile) {
+                        // Save the current profile and the max level for this profile.
+                        LOGV("profile :%d maxLevel;%d", profile, maxLevel);
+                        pProfileLevel->mProfile = profile;
+                        pProfileLevel->mLevel = maxLevel;
+                        profileNumber++;
+                        pProfileLevel++;
+                        profile = profileLevel.mProfile;
+                        maxLevel = profileLevel.mLevel;
+                    } else {
+                        if (profileLevel.mLevel > maxLevel) {
+                            maxLevel = profileLevel.mLevel;
+                        }
+                    }
+
+                }
+                pOmxComponents++;
+            }
+            if (!strcmp(MEDIA_MIMETYPE_VIDEO_AVC, kMimeTypes[k]))
+                pDecoder->codec = M4DA_StreamTypeVideoMpeg4Avc;
+            if (!strcmp(MEDIA_MIMETYPE_VIDEO_MPEG4, kMimeTypes[k]))
+                pDecoder->codec = M4DA_StreamTypeVideoMpeg4;
+            if (!strcmp(MEDIA_MIMETYPE_VIDEO_H263, kMimeTypes[k]))
+                pDecoder->codec = M4DA_StreamTypeVideoH263;
+
+            pDecoder++;
     }
+
+    logSupportDecodersAndCapabilities(pDecoders);
+    *decoders = pDecoders;
+cleanUp:
     return err;
 }
 /********************
@@ -1209,15 +1263,6 @@
             pNextFrameCts = (M4OSA_UInt32 *)pValue;
             *pNextFrameCts = pDecShellContext->m_lastDecodedCTS;
             break;
-        case M4DECODER_kOptionID_AVCProfileAndLevel:
-            profile = (M4DECODER_AVCProfileLevel *) pValue;
-            VideoEditorVideoDecoder_ParseAVCDSI (
-                pDecShellContext->m_pVideoStreamhandler->\
-                    m_basicProperties.m_pDecoderSpecificInfo,
-                pDecShellContext->m_pVideoStreamhandler->\
-                    m_basicProperties.m_decoderSpecificInfoSize,
-                profile);
-            break;
         case M4DECODER_MPEG4_kOptionID_DecoderConfigInfo:
             if(pDecShellContext->mDecoderType == VIDEOEDITOR_kMpeg4VideoDec) {
                 (*(M4DECODER_MPEG4_DecoderConfigInfo*)pValue) =
@@ -1685,4 +1730,9 @@
 
 }
 
+M4OSA_ERR VideoEditorVideoDecoder_getVideoDecodersAndCapabilities(
+    M4DECODER_VideoDecoders** decoders) {
+    return queryVideoDecoderCapabilities(decoders);
+}
+
 }  // extern "C"
diff --git a/libvideoeditor/vss/stagefrightshells/src/VideoEditorVideoEncoder.cpp b/libvideoeditor/vss/stagefrightshells/src/VideoEditorVideoEncoder.cpp
index abfd16b..b0a6fdb 100755
--- a/libvideoeditor/vss/stagefrightshells/src/VideoEditorVideoEncoder.cpp
+++ b/libvideoeditor/vss/stagefrightshells/src/VideoEditorVideoEncoder.cpp
@@ -730,6 +730,8 @@
     sp<MetaData> encoderMetadata = NULL;
     const char* mime = NULL;
     int32_t iProfile = 0;
+    int32_t iLevel = 0;
+
     int32_t iFrameRate = 0;
     uint32_t codecFlags = 0;
 
@@ -761,6 +763,8 @@
     pEncoderContext->mCodecParams->Bitrate = pCodecParams->Bitrate;
     pEncoderContext->mCodecParams->FrameRate = pCodecParams->FrameRate;
     pEncoderContext->mCodecParams->Format = pCodecParams->Format;
+    pEncoderContext->mCodecParams->videoProfile = pCodecParams->videoProfile;
+    pEncoderContext->mCodecParams->videoLevel= pCodecParams->videoLevel;
 
     // Check output format consistency and resolution
     VIDEOEDITOR_CHECK(
@@ -780,23 +784,39 @@
     switch( pEncoderContext->mCodecParams->Format ) {
         case M4ENCODER_kH263:
             mime     = MEDIA_MIMETYPE_VIDEO_H263;
-            iProfile = OMX_VIDEO_H263ProfileBaseline;
             break;
         case M4ENCODER_kMPEG4:
             mime     = MEDIA_MIMETYPE_VIDEO_MPEG4;
-            iProfile = OMX_VIDEO_MPEG4ProfileSimple;
             break;
         case M4ENCODER_kH264:
             mime     = MEDIA_MIMETYPE_VIDEO_AVC;
-            iProfile = OMX_VIDEO_AVCProfileBaseline;
             break;
         default:
             VIDEOEDITOR_CHECK(!"VideoEncoder_open : incorrect input format",
                 M4ERR_PARAMETER);
             break;
     }
+    iProfile = pEncoderContext->mCodecParams->videoProfile;
+    iLevel = pEncoderContext->mCodecParams->videoLevel;
+    LOGV("Encoder mime %s profile %d, level %d",
+        mime,iProfile, iLevel);
+    LOGV("Encoder w %d, h %d, bitrate %d, fps %d",
+        pEncoderContext->mCodecParams->FrameWidth,
+        pEncoderContext->mCodecParams->FrameHeight,
+        pEncoderContext->mCodecParams->Bitrate,
+        pEncoderContext->mCodecParams->FrameRate);
+    CHECK(iProfile != 0x7fffffff);
+    CHECK(iLevel != 0x7fffffff);
+
     encoderMetadata->setCString(kKeyMIMEType, mime);
     encoderMetadata->setInt32(kKeyVideoProfile, iProfile);
+    //FIXME:
+    // Temp: Do not set the level for Mpeg4 / H.263 Enc
+    // as OMX.Nvidia.mp4.encoder and OMX.Nvidia.h263.encoder
+    // return 0x80001019
+    if (pEncoderContext->mCodecParams->Format == M4ENCODER_kH264) {
+        encoderMetadata->setInt32(kKeyVideoLevel, iLevel);
+    }
     encoderMetadata->setInt32(kKeyWidth,
         (int32_t)pEncoderContext->mCodecParams->FrameWidth);
     encoderMetadata->setInt32(kKeyStride,
@@ -837,9 +857,11 @@
     encoderMetadata->setInt32(kKeyColorFormat,
         pEncoderContext->mEncoderColorFormat);
 
-    // Get the encoder DSI
-    err = VideoEditorVideoEncoder_getDSI(pEncoderContext, encoderMetadata);
-    VIDEOEDITOR_CHECK(M4NO_ERROR == err, err);
+    if (pEncoderContext->mCodecParams->Format != M4ENCODER_kH263) {
+        // Get the encoder DSI
+        err = VideoEditorVideoEncoder_getDSI(pEncoderContext, encoderMetadata);
+        VIDEOEDITOR_CHECK(M4NO_ERROR == err, err);
+    }
 
     // Create the encoder source
     pEncoderContext->mEncoderSource = VideoEditorVideoEncoderSource::Create(