]> Gitweb @ Texas Instruments - Open Source Git Repositories - git.TI.com/gitweb - processor-sdk/gst-plugin-dsp66.git/commitdiff
allocate canny variables from stack master
authorVivek Chengalvala <vchengalvala@ti.com>
Wed, 1 Mar 2017 21:02:05 +0000 (16:02 -0500)
committerHongmei Gou <h-gou@ti.com>
Thu, 2 Mar 2017 16:25:34 +0000 (11:25 -0500)
The file scope of canny_ctx(CL_DEVICE_TYPE_ACCELERATOR) OpenCL context object
resulted in constructor for Context called during g_module_open (g_plugin.c) of
"/usr/lib/gstreamer-1.0/libgstdsp66.so", leading to OpenCL device initialization
and subsequent CMEM error (when CMEM is not installed). The fix is to create the
Context object on the stack, along the lines of oclconv_imgproc

src/kernels/oclconv/oclconv.cpp

index 2c99bf33519a5560ac04c941bbd8abc9aeb87338..05f884c1e44bedd9fcaf7b7bd3adb46f24dfa4ca 100644 (file)
@@ -93,13 +93,6 @@ static int oclconv_imgproc(char *kernelName, unsigned char *data_in, unsigned ch
 #endif
    return 0;
 }
-/*----------------------------------------------------------------------------------------------------------------------*/
-static bool          canny_first_call = true;
-static Context       canny_ctx(CL_DEVICE_TYPE_ACCELERATOR);
-static CommandQueue *canny_Q;
-static Buffer       *canny_gradX, *canny_gradY, *canny_mag, *canny_scratch, *canny_numItems;
-static Kernel       *canny_K;
-static Buffer       *canny_input, *canny_output;
 
 /******************************************************************************
  * Canny Edge Detection - called on ARM, but algorithm dispatched to 1 DSP
@@ -113,9 +106,16 @@ static Buffer       *canny_input, *canny_output;
  *****************************************************************************/
 static int ocl_canny(unsigned char *data_in, unsigned char *data_out, unsigned short height, unsigned short width)
 {
-    int numelem = (int)height*(int)width;
+    int          numelem = (int)height*(int)width;
+    static bool  canny_first_call = true;
+    CommandQueue *canny_Q;
+    Buffer       *canny_gradX, *canny_gradY, *canny_mag, *canny_scratch, *canny_numItems;
+    Kernel       *canny_K;
+    Buffer       *canny_input, *canny_output;
+
     try 
     {
+        Context canny_ctx(CL_DEVICE_TYPE_ACCELERATOR);
         Event canny_ev, canny_ev1, canny_ev2;
         /*---------------------------------------------------------------------
         * Cache as much OpenCL plumbing on the first call, so the cost is not