Merge "Issue no : 3370622" into honeycomb

This commit is contained in:
Dheeraj Sharma
2011-01-24 23:04:54 -08:00
committed by Android (Google) Code Review
3 changed files with 12 additions and 84 deletions

View File

@@ -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);
/**

View File

@@ -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);
}
}

View File

@@ -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<Surface> previewSurface = sp<Surface>(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,