fix for issue  4142219
Don't hard code platform-specific limitations-jni/java part

Change-Id: Icde261b1caf29a8cf552884c97f3c9d0b41741a3
diff --git a/include/media/MediaProfiles.h b/include/media/MediaProfiles.h
index ed26e63..69d5001 100644
--- a/include/media/MediaProfiles.h
+++ b/include/media/MediaProfiles.h
@@ -45,6 +45,18 @@
     CAMCORDER_QUALITY_TIME_LAPSE_LIST_END = 1006,
 };
 
+/**
+ *Set CIF as default maximum import and export resolution of video editor.
+ *The maximum import and export resolutions are platform specific,
+ *which should be defined in media_profiles.xml.
+ */
+enum videoeditor_capability {
+    VIDEOEDITOR_DEFAULT_MAX_INPUT_FRAME_WIDTH = 352,
+    VIDEOEDITOR_DEFUALT_MAX_INPUT_FRAME_HEIGHT = 288,
+    VIDEOEDITOR_DEFAULT_MAX_OUTPUT_FRAME_WIDTH = 352,
+    VIDEOEDITOR_DEFUALT_MAX_OUTPUT_FRAME_HEIGHT = 288,
+};
+
 enum video_decoder {
     VIDEO_DECODER_WMV,
 };
@@ -117,6 +129,17 @@
     int getVideoEncoderParamByName(const char *name, video_encoder codec) const;
 
     /**
+     * Returns the value for the given param name for the video editor cap
+     * param or -1 if error.
+     * Supported param name are:
+     * videoeditor.input.width.max - max input video frame width
+     * videoeditor.input.height.max - max input video frame height
+     * videoeditor.output.width.max - max output video frame width
+     * videoeditor.output.height.max - max output video frame height
+     */
+    int getVideoEditorCapParamByName(const char *name) const;
+
+    /**
      * Returns the audio encoders supported.
      */
     Vector<audio_encoder> getAudioEncoders() const;
@@ -164,7 +187,7 @@
 
     MediaProfiles& operator=(const MediaProfiles&);  // Don't call me
     MediaProfiles(const MediaProfiles&);             // Don't call me
-    MediaProfiles() {}                               // Dummy default constructor
+    MediaProfiles() { mVideoEditorCap = NULL; }        // Dummy default constructor
     ~MediaProfiles();                                // Don't delete me
 
     struct VideoCodec {
@@ -310,6 +333,22 @@
         Vector<int> mLevels;
     };
 
+    struct VideoEditorCap {
+        VideoEditorCap(int inFrameWidth, int inFrameHeight,
+            int outFrameWidth, int outFrameHeight)
+            : mMaxInputFrameWidth(inFrameWidth),
+              mMaxInputFrameHeight(inFrameHeight),
+              mMaxOutputFrameWidth(outFrameWidth),
+              mMaxOutputFrameHeight(outFrameHeight) {}
+
+        ~VideoEditorCap() {}
+
+        int mMaxInputFrameWidth;
+        int mMaxInputFrameHeight;
+        int mMaxOutputFrameWidth;
+        int mMaxOutputFrameHeight;
+    };
+
     int getCamcorderProfileIndex(int cameraId, camcorder_quality quality) const;
     void initRequiredProfileRefs(const Vector<int>& cameraIds);
     int getRequiredProfileRefIndex(int cameraId);
@@ -321,6 +360,7 @@
     static void logAudioEncoderCap(const AudioEncoderCap& cap);
     static void logVideoDecoderCap(const VideoDecoderCap& cap);
     static void logAudioDecoderCap(const AudioDecoderCap& cap);
+    static void logVideoEditorCap(const VideoEditorCap& cap);
 
     // If the xml configuration file does exist, use the settings
     // from the xml
@@ -332,6 +372,8 @@
     static VideoDecoderCap* createVideoDecoderCap(const char **atts);
     static VideoEncoderCap* createVideoEncoderCap(const char **atts);
     static AudioEncoderCap* createAudioEncoderCap(const char **atts);
+    static VideoEditorCap* createVideoEditorCap(
+                const char **atts, MediaProfiles *profiles);
 
     static CamcorderProfile* createCamcorderProfile(
                 int cameraId, const char **atts, Vector<int>& cameraIds);
@@ -375,6 +417,7 @@
     static void createDefaultEncoderOutputFileFormats(MediaProfiles *profiles);
     static void createDefaultImageEncodingQualityLevels(MediaProfiles *profiles);
     static void createDefaultImageDecodingMaxMemory(MediaProfiles *profiles);
+    static void createDefaultVideoEditorCap(MediaProfiles *profiles);
     static VideoEncoderCap* createDefaultH263VideoEncoderCap();
     static VideoEncoderCap* createDefaultM4vVideoEncoderCap();
     static AudioEncoderCap* createDefaultAmrNBEncoderCap();
@@ -431,6 +474,7 @@
 
     RequiredProfiles *mRequiredProfileRefs;
     Vector<int>              mCameraIds;
+    VideoEditorCap* mVideoEditorCap;
 };
 
 }; // namespace android
diff --git a/media/java/android/media/videoeditor/MediaArtistNativeHelper.java b/media/java/android/media/videoeditor/MediaArtistNativeHelper.java
index 0d2bcd5..6b0fb12 100644
--- a/media/java/android/media/videoeditor/MediaArtistNativeHelper.java
+++ b/media/java/android/media/videoeditor/MediaArtistNativeHelper.java
@@ -912,11 +912,14 @@
         /** 720p 1280 X 720 */
         public static final int V720p = 10;
 
-        /** 1080 x 720 */
+        /** W720p 1080 x 720 */
         public static final int W720p = 11;
 
-        /** 1080 960 x 720 */
+        /** S720p 960 x 720 */
         public static final int S720p = 12;
+
+        /** 1080p 1920 x 1080 */
+        public static final int V1080p = 13;
     }
 
     /**
@@ -3548,6 +3551,8 @@
                     retValue = VideoFrameSize.WVGA16x9;
                 else if (height == MediaProperties.HEIGHT_720)
                     retValue = VideoFrameSize.V720p;
+                else if (height == MediaProperties.HEIGHT_1080)
+                    retValue = VideoFrameSize.V1080p;
                 break;
             case MediaProperties.ASPECT_RATIO_4_3:
                 if (height == MediaProperties.HEIGHT_480)
diff --git a/media/java/android/media/videoeditor/MediaImageItem.java b/media/java/android/media/videoeditor/MediaImageItem.java
index 4faa83a..73cc7e2 100755
--- a/media/java/android/media/videoeditor/MediaImageItem.java
+++ b/media/java/android/media/videoeditor/MediaImageItem.java
@@ -503,7 +503,60 @@
 
         return adjustedOverlays;
     }
+    /**
+     * This function get the proper width by given aspect ratio
+     * and height.
+     *
+     * @param aspectRatio  Given aspect ratio
+     * @param height  Given height
+     */
+    private int getWidthByAspectRatioAndHeight(int aspectRatio, int height) {
+        int width = 0;
 
+        switch (aspectRatio) {
+            case MediaProperties.ASPECT_RATIO_3_2:
+                if (height == MediaProperties.HEIGHT_480)
+                    width = 720;
+                else if (height == MediaProperties.HEIGHT_720)
+                    width = 1080;
+                break;
+
+            case MediaProperties.ASPECT_RATIO_16_9:
+                if (height == MediaProperties.HEIGHT_360)
+                    width = 640;
+                else if (height == MediaProperties.HEIGHT_480)
+                    width = 854;
+                else if (height == MediaProperties.HEIGHT_720)
+                    width = 1280;
+                else if (height == MediaProperties.HEIGHT_1080)
+                    width = 1920;
+                break;
+
+            case MediaProperties.ASPECT_RATIO_4_3:
+                if (height == MediaProperties.HEIGHT_480)
+                    width = 640;
+                if (height == MediaProperties.HEIGHT_720)
+                    width = 960;
+                break;
+
+            case MediaProperties.ASPECT_RATIO_5_3:
+                if (height == MediaProperties.HEIGHT_480)
+                    width = 800;
+                break;
+
+            case MediaProperties.ASPECT_RATIO_11_9:
+                if (height == MediaProperties.HEIGHT_144)
+                    width = 176;
+                break;
+
+            default : {
+                throw new IllegalArgumentException(
+                    "Illegal arguments for aspectRatio");
+            }
+        }
+
+        return width;
+    }
 
     /**
      * This function sets the Ken Burn effect generated clip
@@ -515,39 +568,10 @@
     void setGeneratedImageClip(String generatedFilePath) {
         super.setGeneratedImageClip(generatedFilePath);
 
-
         // set the Kenburns clip width and height
         mGeneratedClipHeight = getScaledHeight();
-        switch (mVideoEditor.getAspectRatio()) {
-            case MediaProperties.ASPECT_RATIO_3_2:
-                if (mGeneratedClipHeight == MediaProperties.HEIGHT_480)
-                    mGeneratedClipWidth = 720;
-                else if (mGeneratedClipHeight == MediaProperties.HEIGHT_720)
-                    mGeneratedClipWidth = 1080;
-                break;
-            case MediaProperties.ASPECT_RATIO_16_9:
-                if (mGeneratedClipHeight == MediaProperties.HEIGHT_360)
-                    mGeneratedClipWidth = 640;
-                else if (mGeneratedClipHeight == MediaProperties.HEIGHT_480)
-                    mGeneratedClipWidth = 854;
-                else if (mGeneratedClipHeight == MediaProperties.HEIGHT_720)
-                    mGeneratedClipWidth = 1280;
-                break;
-            case MediaProperties.ASPECT_RATIO_4_3:
-                if (mGeneratedClipHeight == MediaProperties.HEIGHT_480)
-                    mGeneratedClipWidth = 640;
-                if (mGeneratedClipHeight == MediaProperties.HEIGHT_720)
-                    mGeneratedClipWidth = 960;
-                break;
-            case MediaProperties.ASPECT_RATIO_5_3:
-                if (mGeneratedClipHeight == MediaProperties.HEIGHT_480)
-                    mGeneratedClipWidth = 800;
-                break;
-            case MediaProperties.ASPECT_RATIO_11_9:
-                if (mGeneratedClipHeight == MediaProperties.HEIGHT_144)
-                    mGeneratedClipWidth = 176;
-                break;
-        }
+        mGeneratedClipWidth = getWidthByAspectRatioAndHeight(
+                mVideoEditor.getAspectRatio(), mGeneratedClipHeight);
     }
 
     /**
@@ -841,37 +865,8 @@
             clipSettings.fileType = FileType.THREE_GPP;
 
             mGeneratedClipHeight = getScaledHeight();
-            switch (mVideoEditor.getAspectRatio()) {
-                case MediaProperties.ASPECT_RATIO_3_2:
-                    if (mGeneratedClipHeight == MediaProperties.HEIGHT_480)
-                        mGeneratedClipWidth = 720;
-                    else if (mGeneratedClipHeight == MediaProperties.HEIGHT_720)
-                        mGeneratedClipWidth = 1080;
-                    break;
-                case MediaProperties.ASPECT_RATIO_16_9:
-                    if (mGeneratedClipHeight == MediaProperties.HEIGHT_360)
-                        mGeneratedClipWidth = 640;
-                    else if (mGeneratedClipHeight == MediaProperties.HEIGHT_480)
-                        mGeneratedClipWidth = 854;
-                    else if (mGeneratedClipHeight == MediaProperties.HEIGHT_720)
-                        mGeneratedClipWidth = 1280;
-                    break;
-                case MediaProperties.ASPECT_RATIO_4_3:
-                    if (mGeneratedClipHeight == MediaProperties.HEIGHT_480)
-                        mGeneratedClipWidth = 640;
-                    if (mGeneratedClipHeight == MediaProperties.HEIGHT_720)
-                        mGeneratedClipWidth = 960;
-                    break;
-                case MediaProperties.ASPECT_RATIO_5_3:
-                    if (mGeneratedClipHeight == MediaProperties.HEIGHT_480)
-                        mGeneratedClipWidth = 800;
-                    break;
-                case MediaProperties.ASPECT_RATIO_11_9:
-                    if (mGeneratedClipHeight == MediaProperties.HEIGHT_144)
-                        mGeneratedClipWidth = 176;
-                    break;
-            }
-
+            mGeneratedClipWidth = getWidthByAspectRatioAndHeight(
+                    mVideoEditor.getAspectRatio(), mGeneratedClipHeight);
         } else {
             if (getGeneratedImageClip() == null) {
                 clipSettings.clipPath = getDecodedImageFileName();
diff --git a/media/java/android/media/videoeditor/MediaProperties.java b/media/java/android/media/videoeditor/MediaProperties.java
index 0225807..ff13e5d 100755
--- a/media/java/android/media/videoeditor/MediaProperties.java
+++ b/media/java/android/media/videoeditor/MediaProperties.java
@@ -17,8 +17,9 @@
 
 package android.media.videoeditor;
 
+import android.media.videoeditor.VideoEditorProfile;
 import android.util.Pair;
-
+import java.lang.System;
 /**
  * This class defines all properties of a media file such as supported height,
  * aspect ratio, bitrate for export function.
@@ -33,7 +34,7 @@
     public static final int HEIGHT_360 = 360;
     public static final int HEIGHT_480 = 480;
     public static final int HEIGHT_720 = 720;
-    public static final int HEIGHT_1088 = 1088;
+    public static final int HEIGHT_1080 = 1080;
 
     /**
      *  Supported aspect ratios
@@ -63,8 +64,7 @@
     private static final Pair<Integer, Integer>[] ASPECT_RATIO_3_2_RESOLUTIONS =
         new Pair[] {
         new Pair<Integer, Integer>(720, HEIGHT_480),
-//*tmpLSA*/        new Pair<Integer, Integer>(1080, HEIGHT_720)
-/*tmpLSA*/        new Pair<Integer, Integer>(1088, HEIGHT_720)
+        new Pair<Integer, Integer>(1080, HEIGHT_720)
     };
 
     @SuppressWarnings({"unchecked"})
@@ -92,6 +92,7 @@
         new Pair[] {
         new Pair<Integer, Integer>(848, HEIGHT_480),
         new Pair<Integer, Integer>(1280, HEIGHT_720),
+        new Pair<Integer, Integer>(1920, HEIGHT_1080),
     };
 
     /**
@@ -345,7 +346,31 @@
             }
         }
 
-        return resolutions;
+        /** Check the platform specific maximum export resolution */
+        VideoEditorProfile veProfile = VideoEditorProfile.get();
+        if (veProfile == null) {
+            throw new RuntimeException("Can't get the video editor profile");
+        }
+        final int maxWidth = veProfile.maxOutputVideoFrameWidth;
+        final int maxHeight = veProfile.maxOutputVideoFrameHeight;
+        Pair<Integer, Integer>[] tmpResolutions = new Pair[resolutions.length];
+        int numSupportedResolution = 0;
+        int i = 0;
+
+        /** Get supported resolution list */
+        for (i = 0; i < resolutions.length; i++) {
+            if ((resolutions[i].first <= maxWidth) &&
+                (resolutions[i].second <= maxHeight)) {
+                tmpResolutions[numSupportedResolution] = resolutions[i];
+                numSupportedResolution++;
+            }
+        }
+        final Pair<Integer, Integer>[] supportedResolutions =
+            new Pair[numSupportedResolution];
+        System.arraycopy(tmpResolutions, 0,
+            supportedResolutions, 0, numSupportedResolution);
+
+        return supportedResolutions;
     }
 
     /**
diff --git a/media/java/android/media/videoeditor/MediaVideoItem.java b/media/java/android/media/videoeditor/MediaVideoItem.java
index 4758de6..6248651 100755
--- a/media/java/android/media/videoeditor/MediaVideoItem.java
+++ b/media/java/android/media/videoeditor/MediaVideoItem.java
@@ -23,6 +23,7 @@
 import android.graphics.Bitmap;
 import android.media.videoeditor.MediaArtistNativeHelper.ClipSettings;
 import android.media.videoeditor.MediaArtistNativeHelper.Properties;
+import android.media.videoeditor.VideoEditorProfile;
 import android.view.Surface;
 import android.view.SurfaceHolder;
 
@@ -118,6 +119,21 @@
             throw new IllegalArgumentException(e.getMessage() + " : " + filename);
         }
 
+        /** Check the platform specific maximum import resolution */
+        VideoEditorProfile veProfile = VideoEditorProfile.get();
+        if (veProfile == null) {
+            throw new RuntimeException("Can't get the video editor profile");
+        }
+        final int maxInputWidth = veProfile.maxInputVideoFrameWidth;
+        final int maxInputHeight = veProfile.maxInputVideoFrameHeight;
+        if ((properties.width > maxInputWidth) ||
+            (properties.height > maxInputHeight)) {
+            throw new IllegalArgumentException(
+                "Unsupported import resolution. Supported maximum width:" +
+                maxInputWidth + " height:" + maxInputHeight +
+                ", current width:" + properties.width +
+                " height:" + properties.height);
+        }
         switch (mMANativeHelper.getFileType(properties.fileType)) {
             case MediaProperties.FILE_3GP:
             case MediaProperties.FILE_MP4:
diff --git a/media/java/android/media/videoeditor/VideoEditor.java b/media/java/android/media/videoeditor/VideoEditor.java
index 59e4540..720e8022 100755
--- a/media/java/android/media/videoeditor/VideoEditor.java
+++ b/media/java/android/media/videoeditor/VideoEditor.java
@@ -370,7 +370,7 @@
      */
     public void export(String filename, int height, int bitrate,
                        ExportProgressListener listener)
-    throws IOException;
+                       throws IOException;
 
     /**
      * Create the output movie based on all media items added and the applied
@@ -413,7 +413,7 @@
      */
     public void export(String filename, int height, int bitrate, int audioCodec,
                        int videoCodec, ExportProgressListener listener)
-                           throws IOException;
+                       throws IOException;
 
     /**
      * Cancel the running export operation. This method blocks until the export
diff --git a/media/java/android/media/videoeditor/VideoEditorImpl.java b/media/java/android/media/videoeditor/VideoEditorImpl.java
index 649b98a..ea7fe63 100755
--- a/media/java/android/media/videoeditor/VideoEditorImpl.java
+++ b/media/java/android/media/videoeditor/VideoEditorImpl.java
@@ -337,7 +337,8 @@
      */
     public void export(String filename, int height, int bitrate,
                        int audioCodec, int videoCodec,
-                       ExportProgressListener listener) throws IOException {
+                       ExportProgressListener listener)
+                       throws IOException {
 
         switch (audioCodec) {
             case MediaProperties.ACODEC_AAC_LC:
@@ -372,7 +373,8 @@
      * {@inheritDoc}
      */
     public void export(String filename, int height, int bitrate,
-                       ExportProgressListener listener) throws IOException {
+                       ExportProgressListener listener)
+                       throws IOException {
         if (filename == null) {
             throw new IllegalArgumentException("export: filename is null");
         }
@@ -386,6 +388,20 @@
             throw new IllegalStateException("No MediaItems added");
         }
 
+        /** Check the platform specific maximum export resolution */
+        VideoEditorProfile veProfile = VideoEditorProfile.get();
+        if (veProfile == null) {
+            throw new RuntimeException("Can't get the video editor profile");
+        }
+        final int maxOutputHeight = veProfile.maxOutputVideoFrameHeight;
+        final int maxOutputWidth = veProfile.maxOutputVideoFrameWidth;
+        if (height > maxOutputHeight) {
+            throw new IllegalArgumentException(
+                    "Unsupported export resolution. Supported maximum width:" +
+                    maxOutputWidth + " height:" + maxOutputHeight +
+                    " current height:" + height);
+        }
+
         switch (height) {
             case MediaProperties.HEIGHT_144:
                 break;
@@ -397,6 +413,8 @@
                 break;
             case MediaProperties.HEIGHT_720:
                 break;
+            case MediaProperties.HEIGHT_1080:
+                break;
 
             default: {
                 String message = "Unsupported height value " + height;
diff --git a/media/java/android/media/videoeditor/VideoEditorProfile.java b/media/java/android/media/videoeditor/VideoEditorProfile.java
new file mode 100755
index 0000000..7d9fc8f
--- /dev/null
+++ b/media/java/android/media/videoeditor/VideoEditorProfile.java
@@ -0,0 +1,82 @@
+/*
+ * Copyright (C) 2011 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package android.media.videoeditor;
+
+/**
+ * The VideoEditorProfile class is used to retrieve the
+ * predefined videoeditor profile settings for videoeditor applications.
+ * These settings are read-only.
+ *
+ * <p>The videoeditor profile specifies the following set of parameters:
+ * <ul>
+ * <li> max input video frame width
+ * <li> max input video frame height
+ * <li> max output video frame width
+ * <li> max output video frame height
+ * </ul>
+ * {@hide}
+ */
+public class VideoEditorProfile
+{
+    /**
+     * The max input video frame width
+     */
+    public int maxInputVideoFrameWidth;
+
+    /**
+     * The max input video frame height
+     */
+    public int maxInputVideoFrameHeight;
+
+    /**
+     * The max ouput video frame width
+     */
+    public int maxOutputVideoFrameWidth;
+
+    /**
+     * The max ouput video frame height
+     */
+    public int maxOutputVideoFrameHeight;
+
+    /**
+     * Returns the videoeditor profile
+     */
+    public static VideoEditorProfile get() {
+        return native_get_videoeditor_profile();
+    }
+
+    static {
+        System.loadLibrary("media_jni");
+        native_init();
+    }
+
+    // Private constructor called by JNI
+    private VideoEditorProfile(int inputWidth,
+                             int inputHeight,
+                             int outputWidth,
+                             int outputHeight) {
+
+        this.maxInputVideoFrameWidth = inputWidth;
+        this.maxInputVideoFrameHeight = inputHeight;
+        this.maxOutputVideoFrameWidth = outputWidth;
+        this.maxOutputVideoFrameHeight = outputHeight;
+    }
+
+    // Methods implemented by JNI
+    private static native final void native_init();
+    private static native final VideoEditorProfile
+	    native_get_videoeditor_profile();
+}
diff --git a/media/jni/android_media_MediaProfiles.cpp b/media/jni/android_media_MediaProfiles.cpp
index 08a6de1..2b8dfe4 100644
--- a/media/jni/android_media_MediaProfiles.cpp
+++ b/media/jni/android_media_MediaProfiles.cpp
@@ -286,6 +286,44 @@
     }
     return static_cast<jint>(levels[index]);
 }
+static jobject
+android_media_MediaProfiles_native_get_videoeditor_profile(JNIEnv *env, jobject thiz)
+{
+    LOGV("native_get_videoeditor_profile");
+
+    int maxInputFrameWidth =
+            sProfiles->getVideoEditorCapParamByName("videoeditor.input.width.max");
+    int maxInputFrameHeight =
+            sProfiles->getVideoEditorCapParamByName("videoeditor.input.height.max");
+    int maxOutputFrameWidth =
+            sProfiles->getVideoEditorCapParamByName("videoeditor.output.width.max");
+    int maxOutputFrameHeight =
+            sProfiles->getVideoEditorCapParamByName("videoeditor.output.height.max");
+
+    // Check on the values retrieved
+    if (maxInputFrameWidth == -1 || maxInputFrameHeight == -1 ||
+        maxOutputFrameWidth == -1 || maxOutputFrameHeight == -1) {
+
+        jniThrowException(env, "java/lang/RuntimeException",\
+            "Error retrieving videoeditor profile params");
+        return NULL;
+    }
+    LOGV("native_get_videoeditor_profile \
+        inWidth:%d inHeight:%d,outWidth:%d, outHeight:%d",\
+        maxInputFrameWidth,maxInputFrameHeight,\
+        maxOutputFrameWidth,maxOutputFrameHeight);
+
+    jclass VideoEditorProfileClazz =
+        env->FindClass("android/media/videoeditor/VideoEditorProfile");
+    jmethodID VideoEditorProfileConstructorMethodID =
+        env->GetMethodID(VideoEditorProfileClazz, "<init>", "(IIII)V");
+    return env->NewObject(VideoEditorProfileClazz,
+                          VideoEditorProfileConstructorMethodID,
+                          maxInputFrameWidth,
+                          maxInputFrameHeight,
+                          maxOutputFrameWidth,
+                          maxOutputFrameHeight);
+}
 
 static JNINativeMethod gMethodsForEncoderCapabilitiesClass[] = {
     {"native_init",                            "()V",                    (void *)android_media_MediaProfiles_native_init},
@@ -324,10 +362,17 @@
     {"native_get_image_encoding_quality_level","(II)I",                   (void *)android_media_MediaProfiles_native_get_image_encoding_quality_level},
 };
 
+static JNINativeMethod gMethodsForVideoEditorProfileClass[] = {
+    {"native_init",                            "()V",                    (void *)android_media_MediaProfiles_native_init},
+    {"native_get_videoeditor_profile",           "()Landroid/media/videoeditor/VideoEditorProfile;",
+                                                                         (void *)android_media_MediaProfiles_native_get_videoeditor_profile},
+};
+
 static const char* const kEncoderCapabilitiesClassPathName = "android/media/EncoderCapabilities";
 static const char* const kDecoderCapabilitiesClassPathName = "android/media/DecoderCapabilities";
 static const char* const kCamcorderProfileClassPathName = "android/media/CamcorderProfile";
 static const char* const kCameraProfileClassPathName = "android/media/CameraProfile";
+static const char* const kVideoEditorProfileClassPathName = "android/media/videoeditor/VideoEditorProfile";
 
 // This function only registers the native methods, and is called from
 // JNI_OnLoad in android_media_MediaPlayer.cpp
@@ -353,6 +398,11 @@
                gMethodsForCameraProfileClass,
                NELEM(gMethodsForCameraProfileClass));
 
+    int ret5 = AndroidRuntime::registerNativeMethods(env,
+               kVideoEditorProfileClassPathName,
+               gMethodsForVideoEditorProfileClass,
+               NELEM(gMethodsForVideoEditorProfileClass));
+
     // Success if all return values from above are 0
-    return (ret1 || ret2 || ret3 || ret4);
+    return (ret1 || ret2 || ret3 || ret4 || ret5);
 }
diff --git a/media/jni/mediaeditor/VideoEditorClasses.cpp b/media/jni/mediaeditor/VideoEditorClasses.cpp
index 277e16c..4c0e731 100755
--- a/media/jni/mediaeditor/VideoEditorClasses.cpp
+++ b/media/jni/mediaeditor/VideoEditorClasses.cpp
@@ -439,9 +439,10 @@
     VIDEOEDIT_JAVA_CONSTANT_INIT("NTSC", M4VIDEOEDITING_kNTSC),
     VIDEOEDIT_JAVA_CONSTANT_INIT("nHD", M4VIDEOEDITING_k640_360),
     VIDEOEDIT_JAVA_CONSTANT_INIT("WVGA16x9", M4VIDEOEDITING_k854_480),
-    VIDEOEDIT_JAVA_CONSTANT_INIT("V720p", M4VIDEOEDITING_kHD1280),
-    VIDEOEDIT_JAVA_CONSTANT_INIT("W720p", M4VIDEOEDITING_kHD1080),
-    VIDEOEDIT_JAVA_CONSTANT_INIT("S720p", M4VIDEOEDITING_kHD960)
+    VIDEOEDIT_JAVA_CONSTANT_INIT("V720p", M4VIDEOEDITING_k1280_720),
+    VIDEOEDIT_JAVA_CONSTANT_INIT("W720p", M4VIDEOEDITING_k1080_720),
+    VIDEOEDIT_JAVA_CONSTANT_INIT("S720p", M4VIDEOEDITING_k960_720),
+    VIDEOEDIT_JAVA_CONSTANT_INIT("V1080p", M4VIDEOEDITING_k1920_1080)
 };
 
 VIDEOEDIT_JAVA_DEFINE_CONSTANT_CLASS(VideoFrameSize, VIDEO_FRAME_SIZE_CLASS_NAME,
diff --git a/media/jni/mediaeditor/VideoEditorPropertiesMain.cpp b/media/jni/mediaeditor/VideoEditorPropertiesMain.cpp
index 9de7207..93fe702 100755
--- a/media/jni/mediaeditor/VideoEditorPropertiesMain.cpp
+++ b/media/jni/mediaeditor/VideoEditorPropertiesMain.cpp
@@ -214,18 +214,6 @@
                             "Invalid File or File not found ");
                 }
 
-                /**
-                 * Max resolution supported is 1280 x 720.
-                 */
-                if ( (pClipProperties->uiVideoWidth > 1280)
-                    || (pClipProperties->uiVideoHeight > 720) )
-                {
-                    result = M4MCS_ERR_INVALID_INPUT_VIDEO_FRAME_SIZE;
-                    videoEditJava_checkAndThrowIllegalArgumentException(
-                            &gotten, pEnv, (M4NO_ERROR != result),
-                            "Unsupported input video frame size");
-                }
-
 #ifdef USE_SOFTWARE_DECODER
                 /**
                  * Input clip with non-multiples of 16 is not supported.
diff --git a/media/libmedia/MediaProfiles.cpp b/media/libmedia/MediaProfiles.cpp
index 069bbb7..f0f07a2 100644
--- a/media/libmedia/MediaProfiles.cpp
+++ b/media/libmedia/MediaProfiles.cpp
@@ -132,6 +132,16 @@
     LOGV("codec = %d", cap.mCodec);
 }
 
+/*static*/ void
+MediaProfiles::logVideoEditorCap(const MediaProfiles::VideoEditorCap& cap)
+{
+    LOGV("videoeditor cap:");
+    LOGV("mMaxInputFrameWidth = %d", cap.mMaxInputFrameWidth);
+    LOGV("mMaxInputFrameHeight = %d", cap.mMaxInputFrameHeight);
+    LOGV("mMaxOutputFrameWidth = %d", cap.mMaxOutputFrameWidth);
+    LOGV("mMaxOutputFrameHeight = %d", cap.mMaxOutputFrameHeight);
+}
+
 /*static*/ int
 MediaProfiles::findTagForName(const MediaProfiles::NameToTagMap *map, size_t nMappings, const char *name)
 {
@@ -368,6 +378,24 @@
     mStartTimeOffsets.replaceValueFor(cameraId, offsetTimeMs);
 }
 
+/*static*/ MediaProfiles::VideoEditorCap*
+MediaProfiles::createVideoEditorCap(const char **atts, MediaProfiles *profiles)
+{
+    CHECK(!strcmp("maxInputFrameWidth", atts[0]) &&
+          !strcmp("maxInputFrameHeight", atts[2])  &&
+          !strcmp("maxOutputFrameWidth", atts[4]) &&
+          !strcmp("maxOutputFrameHeight", atts[6]));
+
+    MediaProfiles::VideoEditorCap *pVideoEditorCap =
+        new MediaProfiles::VideoEditorCap(atoi(atts[1]), atoi(atts[3]),
+                atoi(atts[5]), atoi(atts[7]));
+
+    logVideoEditorCap(*pVideoEditorCap);
+    profiles->mVideoEditorCap = pVideoEditorCap;
+
+    return pVideoEditorCap;
+}
+
 /*static*/ void
 MediaProfiles::startElementHandler(void *userData, const char *name, const char **atts)
 {
@@ -398,6 +426,8 @@
             createCamcorderProfile(profiles->mCurrentCameraId, atts, profiles->mCameraIds));
     } else if (strcmp("ImageEncoding", name) == 0) {
         profiles->addImageEncodingQualityLevel(profiles->mCurrentCameraId, atts);
+    } else if (strcmp("VideoEditorCap", name) == 0) {
+        createVideoEditorCap(atts, profiles);
     }
 }
 
@@ -790,6 +820,17 @@
     profiles->mImageEncodingQualityLevels.add(levels);
 }
 
+/*static*/ void
+MediaProfiles::createDefaultVideoEditorCap(MediaProfiles *profiles)
+{
+    profiles->mVideoEditorCap =
+        new MediaProfiles::VideoEditorCap(
+                VIDEOEDITOR_DEFAULT_MAX_INPUT_FRAME_WIDTH,
+                VIDEOEDITOR_DEFUALT_MAX_INPUT_FRAME_HEIGHT,
+                VIDEOEDITOR_DEFAULT_MAX_OUTPUT_FRAME_WIDTH,
+                VIDEOEDITOR_DEFUALT_MAX_OUTPUT_FRAME_HEIGHT);
+}
+
 /*static*/ MediaProfiles*
 MediaProfiles::createDefaultInstance()
 {
@@ -801,6 +842,7 @@
     createDefaultAudioDecoders(profiles);
     createDefaultEncoderOutputFileFormats(profiles);
     createDefaultImageEncodingQualityLevels(profiles);
+    createDefaultVideoEditorCap(profiles);
     return profiles;
 }
 
@@ -899,6 +941,28 @@
     return -1;
 }
 
+int MediaProfiles::getVideoEditorCapParamByName(const char *name) const
+{
+    LOGV("getVideoEditorCapParamByName: %s", name);
+
+    if (mVideoEditorCap == NULL) {
+        LOGE("The mVideoEditorCap is not created, then create default cap.");
+        createDefaultVideoEditorCap(sInstance);
+    }
+
+    if (!strcmp("videoeditor.input.width.max", name))
+        return mVideoEditorCap->mMaxInputFrameWidth;
+    if (!strcmp("videoeditor.input.height.max", name))
+        return mVideoEditorCap->mMaxInputFrameHeight;
+    if (!strcmp("videoeditor.output.width.max", name))
+        return mVideoEditorCap->mMaxOutputFrameWidth;
+    if (!strcmp("videoeditor.output.height.max", name))
+        return mVideoEditorCap->mMaxOutputFrameHeight;
+
+    LOGE("The given video editor param name %s is not found", name);
+    return -1;
+}
+
 Vector<audio_encoder> MediaProfiles::getAudioEncoders() const
 {
     Vector<audio_encoder> encoders;