From 9ec356a232336f80a048c71554ce79474ae1a784 Mon Sep 17 00:00:00 2001 From: Dheeraj Sharma Date: Mon, 24 Jan 2011 15:02:18 -0800 Subject: [PATCH] VideoEditor:Fix for Clear Surface API Bug of not able to create empty project bug - 3370622 Change-Id: Icb18b3d8afbdb077a93dc5e599ccc20da64703f2 --- .../lvpp/VideoEditorPreviewController.cpp | 65 ++++++++++++++++++++++ libvideoeditor/lvpp/VideoEditorPreviewController.h | 3 + 2 files changed, 68 insertions(+) diff --git a/libvideoeditor/lvpp/VideoEditorPreviewController.cpp b/libvideoeditor/lvpp/VideoEditorPreviewController.cpp index c079898f4c..52aa87e333 100755 --- a/libvideoeditor/lvpp/VideoEditorPreviewController.cpp +++ b/libvideoeditor/lvpp/VideoEditorPreviewController.cpp @@ -672,6 +672,71 @@ M4OSA_ERR VideoEditorPreviewController::stopPreview() { return M4NO_ERROR; } +M4OSA_ERR VideoEditorPreviewController::clearSurface( + const sp &surface, VideoEditor_renderPreviewFrameStr* pFrameInfo) { + + M4OSA_ERR err = M4NO_ERROR; + VideoEditor_renderPreviewFrameStr* pFrameStr = pFrameInfo; + M4OSA_UInt32 outputBufferWidth =0, outputBufferHeight=0; + M4VIFI_ImagePlane planeOut[3]; + LOGV("Inside preview clear frame"); + + Mutex::Autolock autoLock(mLock); + + // Get the Isurface to be passed to renderer + mISurface = surface->getISurface(); + + // Delete previous renderer instance + if(mTarget != NULL) { + delete mTarget; + mTarget = NULL; + } + + if(mOutputVideoWidth == 0) { + mOutputVideoWidth = pFrameStr->uiFrameWidth; + } + if(mOutputVideoHeight == 0) { + mOutputVideoHeight = pFrameStr->uiFrameHeight; + } + + // Initialize the renderer + if(mTarget == NULL) { + mTarget = new PreviewRenderer( + OMX_COLOR_FormatYUV420Planar, surface, mOutputVideoWidth, mOutputVideoHeight, + mOutputVideoWidth, mOutputVideoHeight, 0); + if(mTarget == NULL) { + LOGE("renderPreviewFrame: cannot create PreviewRenderer"); + return M4ERR_ALLOC; + } + } + + // Out plane + uint8_t* outBuffer; + size_t outBufferStride = 0; + + LOGV("doMediaRendering CALL getBuffer()"); + mTarget->getBufferYV12(&outBuffer, &outBufferStride); + + // Set the output YUV420 plane to be compatible with YV12 format + //In YV12 format, sizes must be even + M4OSA_UInt32 yv12PlaneWidth = ((mOutputVideoWidth +1)>>1)<<1; + M4OSA_UInt32 yv12PlaneHeight = ((mOutputVideoHeight+1)>>1)<<1; + + prepareYV12ImagePlane(planeOut, yv12PlaneWidth, yv12PlaneHeight, + (M4OSA_UInt32)outBufferStride, (M4VIFI_UInt8 *)outBuffer); + + /* Fill the surface with black frame */ + M4OSA_memset((M4OSA_MemAddr8)planeOut[0].pac_data,planeOut[0].u_width * + planeOut[0].u_height * 1.5,0x00); + M4OSA_memset((M4OSA_MemAddr8)planeOut[1].pac_data,planeOut[1].u_width * + planeOut[1].u_height,128); + M4OSA_memset((M4OSA_MemAddr8)planeOut[2].pac_data,planeOut[2].u_width * + planeOut[2].u_height,128); + + mTarget->renderYV12(); + return err; +} + M4OSA_ERR VideoEditorPreviewController::renderPreviewFrame( const sp &surface, VideoEditor_renderPreviewFrameStr* pFrameInfo) { diff --git a/libvideoeditor/lvpp/VideoEditorPreviewController.h b/libvideoeditor/lvpp/VideoEditorPreviewController.h index 637ddb2a1e..5828c5f63b 100755 --- a/libvideoeditor/lvpp/VideoEditorPreviewController.h +++ b/libvideoeditor/lvpp/VideoEditorPreviewController.h @@ -74,6 +74,9 @@ public: M4OSA_ERR renderPreviewFrame(const sp &surface, VideoEditor_renderPreviewFrameStr* pFrameInfo); + M4OSA_ERR clearSurface(const sp &surface, + VideoEditor_renderPreviewFrameStr* pFrameInfo); + M4OSA_Void setJniCallback(void* cookie, jni_progress_callback_fct callbackFct); -- 2.11.0