@@ -295,7 +295,8 @@ static PyObject* NvJpeg_decode(NvJpeg* Self, PyObject* Argvs)
295295 unsigned char * data = NvJpegPythonImage2HostMemory (img );
296296 npy_intp dims [1 ] = {(npy_intp )((img -> width )* (img -> height ))* 3 };
297297 PyObject * temp = PyArray_SimpleNewFromData (1 , dims , NPY_UINT8 , data );
298- free (data );
298+ PyArray_ENABLEFLAGS ((PyArrayObject * ) temp , NPY_ARRAY_OWNDATA );
299+ // free(data);
299300
300301 PyObject * shape = Py_BuildValue ("(i,i,i)" , 3 , img -> height , img -> width );
301302 NvJpegPython_destoryImage (& img );
@@ -310,7 +311,7 @@ static PyObject* NvJpeg_decode(NvJpeg* Self, PyObject* Argvs)
310311
311312 rtn = PyArray_SwapAxes ((PyArrayObject * )temp , 0 , 1 );
312313 Py_DECREF (temp );
313-
314+ // Py_INCREF(rtn);
314315 return rtn ;
315316}
316317
@@ -338,11 +339,14 @@ static PyObject* NvJpeg_encode(NvJpeg* Self, PyObject* Argvs)
338339 }
339340
340341 NvJpegPythonHandle * m_handle = (NvJpegPythonHandle * )Self -> m_handle ;
341- NvJpegPythonImage * img = NvJpegPython_createImageFromHost (PyArray_DIM (vecin , 0 ), PyArray_DIM (vecin , 1 ), (const unsigned char * )PyArray_BYTES (vecin ), 3 );
342+ NvJpegPythonImage * img = NvJpegPython_createImageFromHost (PyArray_DIM (vecin , 1 ), PyArray_DIM (vecin , 0 ), (const unsigned char * )PyArray_BYTES (vecin ), 3 );
342343 NvJpegJpegData * data = NvJpegPython_encode (m_handle , img , quality );
343344
344345 PyObject * rtn = PyByteArray_FromStringAndSize ((const char * )data -> data , data -> size );
346+
347+ NvJpegPython_destoryJpegData (& data );
345348 NvJpegPython_destoryImage (& img );
349+
346350 return rtn ;
347351}
348352
0 commit comments