OSDN Git Service

VideoEditor:Fix for Clear Surface API Bug of not able to create empty project
authorDheeraj Sharma <dheerajs@google.com>
Mon, 24 Jan 2011 23:02:18 +0000 (15:02 -0800)
committerDheeraj Sharma <dheerajs@google.com>
Tue, 25 Jan 2011 07:00:04 +0000 (23:00 -0800)
bug - 3370622

Change-Id: Icb18b3d8afbdb077a93dc5e599ccc20da64703f2

libvideoeditor/lvpp/VideoEditorPreviewController.cpp
libvideoeditor/lvpp/VideoEditorPreviewController.h

index c079898..52aa87e 100755 (executable)
@@ -672,6 +672,71 @@ M4OSA_ERR VideoEditorPreviewController::stopPreview() {
     return M4NO_ERROR;\r
 }\r
 \r
+M4OSA_ERR VideoEditorPreviewController::clearSurface(\r
+    const sp<Surface> &surface, VideoEditor_renderPreviewFrameStr* pFrameInfo) {\r
+\r
+    M4OSA_ERR err = M4NO_ERROR;\r
+    VideoEditor_renderPreviewFrameStr* pFrameStr = pFrameInfo;\r
+    M4OSA_UInt32 outputBufferWidth =0, outputBufferHeight=0;\r
+    M4VIFI_ImagePlane planeOut[3];\r
+    LOGV("Inside preview clear frame");\r
+\r
+    Mutex::Autolock autoLock(mLock);\r
+\r
+    // Get the Isurface to be passed to renderer\r
+    mISurface = surface->getISurface();\r
+\r
+    // Delete previous renderer instance\r
+    if(mTarget != NULL) {\r
+        delete mTarget;\r
+        mTarget = NULL;\r
+    }\r
+\r
+    if(mOutputVideoWidth == 0) {\r
+        mOutputVideoWidth = pFrameStr->uiFrameWidth;\r
+    }\r
+    if(mOutputVideoHeight == 0) {\r
+        mOutputVideoHeight = pFrameStr->uiFrameHeight;\r
+    }\r
+\r
+    // Initialize the renderer\r
+    if(mTarget == NULL) {\r
+        mTarget = new PreviewRenderer(\r
+            OMX_COLOR_FormatYUV420Planar, surface, mOutputVideoWidth, mOutputVideoHeight,\r
+            mOutputVideoWidth, mOutputVideoHeight, 0);\r
+        if(mTarget == NULL) {\r
+            LOGE("renderPreviewFrame: cannot create PreviewRenderer");\r
+            return M4ERR_ALLOC;\r
+        }\r
+    }\r
+\r
+    // Out plane\r
+    uint8_t* outBuffer;\r
+    size_t outBufferStride = 0;\r
+\r
+    LOGV("doMediaRendering CALL getBuffer()");\r
+    mTarget->getBufferYV12(&outBuffer, &outBufferStride);\r
+\r
+    // Set the output YUV420 plane to be compatible with YV12 format\r
+    //In YV12 format, sizes must be even\r
+    M4OSA_UInt32 yv12PlaneWidth = ((mOutputVideoWidth +1)>>1)<<1;\r
+    M4OSA_UInt32 yv12PlaneHeight = ((mOutputVideoHeight+1)>>1)<<1;\r
+\r
+    prepareYV12ImagePlane(planeOut, yv12PlaneWidth, yv12PlaneHeight,\r
+     (M4OSA_UInt32)outBufferStride, (M4VIFI_UInt8 *)outBuffer);\r
+\r
+    /* Fill the surface with black frame */\r
+    M4OSA_memset((M4OSA_MemAddr8)planeOut[0].pac_data,planeOut[0].u_width *\r
+                            planeOut[0].u_height * 1.5,0x00);\r
+    M4OSA_memset((M4OSA_MemAddr8)planeOut[1].pac_data,planeOut[1].u_width *\r
+                            planeOut[1].u_height,128);\r
+    M4OSA_memset((M4OSA_MemAddr8)planeOut[2].pac_data,planeOut[2].u_width *\r
+                             planeOut[2].u_height,128);\r
+\r
+    mTarget->renderYV12();\r
+    return err;\r
+}\r
+\r
 M4OSA_ERR VideoEditorPreviewController::renderPreviewFrame(\r
     const sp<Surface> &surface, VideoEditor_renderPreviewFrameStr* pFrameInfo) {\r
 \r
index 637ddb2..5828c5f 100755 (executable)
@@ -74,6 +74,9 @@ public:
     M4OSA_ERR renderPreviewFrame(const sp<Surface> &surface,\r
      VideoEditor_renderPreviewFrameStr* pFrameInfo);\r
 \r
+    M4OSA_ERR clearSurface(const sp<Surface> &surface,\r
+     VideoEditor_renderPreviewFrameStr* pFrameInfo);\r
+\r
     M4OSA_Void setJniCallback(void* cookie,\r
      jni_progress_callback_fct callbackFct);\r
 \r