Community
cancel
Showing results for 
Search instead for 
Did you mean: 
normanholz
Beginner
86 Views

Problems encoding image data in a managed (.Net) byte array via UIC

Hi everyone,

I am trying to encode image data from a managed byte array (.Net) via the UIC Samples / the "image" classes from the sample applications (picnic and transcoder).

I thought about this:

// execution status
ExcStatus res, resOut;

// image class --> after reading the raw data this holds the image information
// image is param to 2. encoding step
CIppImage img;

// Parameter for the raw data reading step
PARAMS_RAW param;

// buffer in which the raw bytes are copied:(
Ipp8u* buf;

int len = imageData->Length;

// 1. put data in CMemBuffInput (unmanaged code)
CMemBuffInput cmi;

buf = (Ipp8u*)ippMalloc(len);

// use pinpointer to prevent data from being garbage collected
pin_ptr p = &imageData[0];

cmi.Open(p,len);

//set raw params
param.height = height;
param.width = width;
param.nchannels = 3;
param.precision = 8;
param.offset = 0;
param.color = JC_RGB;

// 2. use Raw::ReadImageRaw(
res = ReadImageRAW(cmi, param, img);

bool rawSuccess = IsOk(res);

img.Color(JC_RGB);

// 4. define output stream
CMemBuffOutput mo;
Ipp8u* bufOut;

bufOut = (Ipp8u*)ippMalloc(len);
mo.Open(bufOut, len);

resOut = SaveImageRAW(img, param, mo);

bool rawWriteSuccess = IsOk(resOut);

PARAMS_BMP params_bmp;

resOut = SaveImageBMP(img, params_bmp, mo);

bool bmpWriteSuccess = IsOk(resOut);

Question: Is this the way the UIC usage is intended? Unfortunately, the Saving as BMP returns no error code but crashes with Visual Studio complaining about a corrupted Heap with this message:

HEAP[appname.exe]: Invalid Address specified to RtlFreeHeap( 00170000,
10015988 )
Windows has triggered a breakpoint in appname.exe.

This may be due to a corruption of the heap, and indicates a bug in
appname.exe or any of the DLLs it has loaded.


Any hint on how to solve this problem or to tackle my encoding task would be highly appreciated,

Many thanks in advance and kind regards,

Norman
0 Kudos
6 Replies
Ying_H_Intel
Employee
86 Views

Quoting - normanholz
Hi everyone,

I am trying to encode image data from a managed byte array (.Net) via the UIC Samples / the "image" classes from the sample applications (picnic and transcoder).

I thought about this:

// execution status
ExcStatus res, resOut;

// image class --> after reading the raw data this holds the image information
// image is param to 2. encoding step
CIppImage img;

// Parameter for the raw data reading step
PARAMS_RAW param;

// buffer in which the raw bytes are copied:(
Ipp8u* buf;

int len = imageData->Length;

// 1. put data in CMemBuffInput (unmanaged code)
CMemBuffInput cmi;

buf = (Ipp8u*)ippMalloc(len);

// use pinpointer to prevent data from being garbage collected
pin_ptr p = &imageData[0];

cmi.Open(p,len);

//set raw params
param.height = height;
param.width = width;
param.nchannels = 3;
param.precision = 8;
param.offset = 0;
param.color = JC_RGB;

// 2. use Raw::ReadImageRaw(
res = ReadImageRAW(cmi, param, img);

bool rawSuccess = IsOk(res);

img.Color(JC_RGB);

// 4. define output stream
CMemBuffOutput mo;
Ipp8u* bufOut;

bufOut = (Ipp8u*)ippMalloc(len);
mo.Open(bufOut, len);

resOut = SaveImageRAW(img, param, mo);

bool rawWriteSuccess = IsOk(resOut);

PARAMS_BMP params_bmp;

resOut = SaveImageBMP(img, params_bmp, mo);

bool bmpWriteSuccess = IsOk(resOut);

Question: Is this the way the UIC usage is intended? Unfortunately, the Saving as BMP returns no error code but crashes with Visual Studio complaining about a corrupted Heap with this message:

HEAP[appname.exe]: Invalid Address specified to RtlFreeHeap( 00170000,
10015988 )
Windows has triggered a breakpoint in appname.exe.

This may be due to a corruption of the heap, and indicates a bug in
appname.exe or any of the DLLs it has loaded.


Any hint on how to solve this problem or to tackle my encoding task would be highly appreciated,

Many thanks in advance and kind regards,

Norman

Hi Norman

I'm updating the thread: http://software.intel.com/en-us/forums/showthread.php?t=63658. It looks similiar as your's.

Which IPP and UIC version are you using? We release a new version IPP 6.1 update 2 in the two days, which fix the issue in 63658. You may try the new version and let me know if any result.

All of install package and uic sample are available in Intel register center. You may go there to download.
or from the below URL (if you are building windows 64bit application)
<<>>
<<>>

Regards
Ying
normanholz
Beginner
86 Views

Quoting - Ying H (Intel)

Hi Norman

I'm updating the thread: http://software.intel.com/en-us/forums/showthread.php?t=63658. It looks similiar as your's.

Which IPP and UIC version are you using? We release a new version IPP 6.1 update 2 in the two days, which fix the issue in 63658. You may try the new version and let me know if any result.

All of install package and uic sample are available in Intel register center. You may go there to download.
or from the below URL (if you are building windows 64bit application)
<<>>
<<>>

Regards
Ying

Hi Ying,

thanks for the quick reply.

I am using IPP 6.1.1.035 and UIC 6.1.1.044 and I am looking forward to test the update.

Am I right, using the UIC samples in this way to solve my encoding tasks? Are there any examples on how to manage the data "marshalling" from managed code to unmanaged code for UIC/Ipp and back?

Many thanks and kind regards
Norman



Vladimir_Dudnik
Employee
86 Views


Norman,

did you notice .NET wrappers for UIC ? Would it help you to solve your task?

Regards,
Vladimir
normanholz
Beginner
86 Views


Norman,

did you notice .NET wrappers for UIC ? Would it help you to solve your task?

Regards,
Vladimir

Hi Vladimir,

I found the .Net Wrapper for the Inputstream or more specific the CMemBuffInput.

I understand that the class holds a C - World MemoryBufferInput stream and does pinning the managed data pointer via a pin_ptr operation, to prevent it from being garbage collected, in the Open Method, it then calls Open() on the wrapped CMemBuffInput.

But I am puzzled about the Read method of this wrapper that does nothing, apparently.

"void Read(array^ buf, int offset, int count) { return;/* UIC::BaseStream::StatusOk;*/ }"

Is this the intended behavior? Currently I am "pinning" the pointer by myself and work on the CMemBuffInput itself.

Any further insights or comments would be highly appreciated.

Kind regards,
Norman






Vladimir_Dudnik
Employee
86 Views


Hello,

in order to simplify the things we keep C CMemBuffInput object pointer in managed class wrapper MemBuffInput. When you call AttachStream method of managed class JPEG decoder it make copy of this pointer in its internal C CJPEGDecoder class and so method Read of managed class MemBuffInput not used.

Regards,
Vladimir
normanholz
Beginner
86 Views


Hello,

in order to simplify the things we keep C CMemBuffInput object pointer in managed class wrapper MemBuffInput. When you call AttachStream method of managed class JPEG decoder it make copy of this pointer in its internal C CJPEGDecoder class and so method Read of managed class MemBuffInput not used.

Regards,
Vladimir


Thanks for your help. I got it:)

Kind regards,
Norman
Reply