From 1ac760afabeb19ced48a788c7b675baba47d4db3 Mon Sep 17 00:00:00 2001 From: Dheeraj Sharma Date: Mon, 24 Jan 2011 14:46:30 -0800 Subject: [PATCH] Issue no : 3370622 VideoEditor: Fix for Clear Surface API Change-Id: I8d4ad90dd2a0d37bd5363c36582a16f08b161bee --- .../media/videoeditor/MediaArtistNativeHelper.java | 6 +- .../android/media/videoeditor/VideoEditorImpl.java | 8 +-- media/jni/mediaeditor/VideoEditorMain.cpp | 82 +++------------------- 3 files changed, 12 insertions(+), 84 deletions(-) diff --git a/media/java/android/media/videoeditor/MediaArtistNativeHelper.java b/media/java/android/media/videoeditor/MediaArtistNativeHelper.java index 271e9dd0a0d4..8156439dc73c 100755 --- a/media/java/android/media/videoeditor/MediaArtistNativeHelper.java +++ b/media/java/android/media/videoeditor/MediaArtistNativeHelper.java @@ -4005,8 +4005,8 @@ class MediaArtistNativeHelper { } } - public void clearPreviewSurface(Surface surface, int width, int height) { - nativeClearSurface(surface,width,height); + public void clearPreviewSurface(Surface surface) { + nativeClearSurface(surface); } /** Native Methods */ native Properties getMediaProperties(String file) throws IllegalArgumentException, @@ -4053,7 +4053,7 @@ class MediaArtistNativeHelper { /* * Clear the preview surface */ - public native void nativeClearSurface(Surface surface, int width, int height); + private native void nativeClearSurface(Surface surface); /** diff --git a/media/java/android/media/videoeditor/VideoEditorImpl.java b/media/java/android/media/videoeditor/VideoEditorImpl.java index 5b87d162bc8d..c19725c8370f 100755 --- a/media/java/android/media/videoeditor/VideoEditorImpl.java +++ b/media/java/android/media/videoeditor/VideoEditorImpl.java @@ -1828,9 +1828,6 @@ public class VideoEditorImpl implements VideoEditor { if (surfaceHolder == null) { throw new IllegalArgumentException(); } - Rect frame; - int surfaceWidth; - int surfaceHeight; Surface surface = surfaceHolder.getSurface(); if (surface == null) { @@ -1838,10 +1835,7 @@ public class VideoEditorImpl implements VideoEditor { "Surface could not be retrieved from surface holder"); throw new RuntimeException(); } - frame = surfaceHolder.getSurfaceFrame(); - surfaceWidth = frame.width(); - surfaceHeight = frame.height(); - mMANativeHelper.clearPreviewSurface(surface,surfaceWidth,surfaceHeight); + mMANativeHelper.clearPreviewSurface(surface); } } diff --git a/media/jni/mediaeditor/VideoEditorMain.cpp b/media/jni/mediaeditor/VideoEditorMain.cpp index 1751396ccae8..8ce788b1a042 100755 --- a/media/jni/mediaeditor/VideoEditorMain.cpp +++ b/media/jni/mediaeditor/VideoEditorMain.cpp @@ -261,9 +261,7 @@ videoEditor_generateClip( static void videoEditor_clearSurface(JNIEnv* pEnv, jobject thiz, - jobject surface, - jint width, - jint height); + jobject surface); static JNINativeMethod gManualEditMethods[] = { {"getVersion", "()L"VERSION_CLASS_NAME";", @@ -300,7 +298,7 @@ static JNINativeMethod gManualEditMethods[] = { (int *)videoEditor_generateAudioRawFile }, {"nativeGenerateClip", "(L"EDIT_SETTINGS_CLASS_NAME";)I", (void *)videoEditor_generateClip }, - {"nativeClearSurface", "(Landroid/view/Surface;II)V", + {"nativeClearSurface", "(Landroid/view/Surface;)V", (void *)videoEditor_clearSurface }, }; @@ -428,16 +426,15 @@ static void videoEditor_stopPreview(JNIEnv* pEnv, static void videoEditor_clearSurface(JNIEnv* pEnv, jobject thiz, - jobject surface, - jint width, - jint height) + jobject surface) { bool needToBeLoaded = true; - M4OSA_UInt32 framesizeYuv =0; M4OSA_ERR result = M4NO_ERROR; VideoEditor_renderPreviewFrameStr frameStr; const char* pMessage = NULL; - M4VIFI_ImagePlane *yuvPlane; + // Let the size be QVGA + int width = 320; + int height = 240; ManualEditContext* pContext = M4OSA_NULL; // Get the context. @@ -474,62 +471,7 @@ static void videoEditor_clearSurface(JNIEnv* pEnv, Surface* const p = (Surface*)pEnv->GetIntField(surface, surface_native); sp previewSurface = sp(p); - /** - * Allocate output YUV planes - */ - yuvPlane = (M4VIFI_ImagePlane*)M4OSA_malloc(3*sizeof(M4VIFI_ImagePlane), M4VS, - (M4OSA_Char*)"videoEditor_clearSurface Output plane YUV"); - if (yuvPlane == M4OSA_NULL) { - VIDEOEDIT_LOG_FUNCTION(ANDROID_LOG_INFO, "VIDEO_EDITOR", - "videoEditor_clearSurface() malloc error for yuv plane"); - pMessage = videoEditJava_getErrorName(M4ERR_ALLOC); - jniThrowException(pEnv, "java/lang/RuntimeException", pMessage); - return ; - } - - framesizeYuv = width * height * 1.5; - yuvPlane[0].u_width = width; - yuvPlane[0].u_height = height; - yuvPlane[0].u_topleft = 0; - yuvPlane[0].u_stride = width; - yuvPlane[0].pac_data = (M4VIFI_UInt8 *)M4OSA_malloc(framesizeYuv, M4VS, - (M4OSA_Char*)"videoEditor pixelArray"); - if (yuvPlane[0].pac_data == M4OSA_NULL) { - VIDEOEDIT_LOG_FUNCTION(ANDROID_LOG_INFO, "VIDEO_EDITOR", - "videoEditor_renderPreviewFrame() malloc error"); - pMessage = videoEditJava_getErrorName(M4ERR_ALLOC); - jniThrowException(pEnv, "java/lang/RuntimeException", pMessage); - return; - } - - /* memset yuvPlane[0].pac_data with 0 for black frame */ - M4OSA_memset((M4OSA_MemAddr8)yuvPlane[0].pac_data,framesizeYuv,0x00); - FILE *p1 = fopen("/mnt/sdcard/black.raw","wb"); - fwrite(yuvPlane[0].pac_data,1,framesizeYuv,p1); - fclose(p1); - - yuvPlane[1].u_width = width>>1; - yuvPlane[1].u_height = height>>1; - yuvPlane[1].u_topleft = 0; - yuvPlane[1].u_stride = width>>1; - yuvPlane[1].pac_data = yuvPlane[0].pac_data - + yuvPlane[0].u_width * yuvPlane[0].u_height; - - M4OSA_memset((M4OSA_MemAddr8)yuvPlane[1].pac_data,yuvPlane[1].u_width * - yuvPlane[1].u_height,128); - yuvPlane[2].u_width = (width)>>1; - yuvPlane[2].u_height = (height)>>1; - yuvPlane[2].u_topleft = 0; - yuvPlane[2].u_stride = (width)>>1; - yuvPlane[2].pac_data = yuvPlane[1].pac_data - + yuvPlane[1].u_width * yuvPlane[1].u_height; - - M4OSA_memset((M4OSA_MemAddr8)yuvPlane[2].pac_data,yuvPlane[2].u_width * - yuvPlane[2].u_height,128); - - /* Fill up the render structure*/ - frameStr.pBuffer = (M4OSA_Void*)yuvPlane[0].pac_data; - + frameStr.pBuffer = M4OSA_NULL; frameStr.timeMs = 0; frameStr.uiSurfaceWidth = width; frameStr.uiSurfaceHeight = height; @@ -539,19 +481,11 @@ static void videoEditor_clearSurface(JNIEnv* pEnv, frameStr.clipBeginCutTime = 0; frameStr.clipEndCutTime = 0; - /*pContext->mPreviewController->setPreviewFrameRenderingMode( - pContext->pEditSettings->\ - pClipList[iCurrentClipIndex]->xVSS.MediaRendering, - pContext->pEditSettings->xVSS.outputVideoSize); - */ - - result = pContext->mPreviewController->renderPreviewFrame(previewSurface, + result = pContext->mPreviewController->clearSurface(previewSurface, &frameStr); videoEditJava_checkAndThrowRuntimeException(&needToBeLoaded, pEnv, (M4NO_ERROR != result), result); - M4OSA_free((M4OSA_MemAddr32)yuvPlane[0].pac_data); - M4OSA_free((M4OSA_MemAddr32)yuvPlane); } static int videoEditor_renderPreviewFrame(JNIEnv* pEnv, -- 2.11.0