Forum Jump

Select Group :
Select Forum :
Sorted By :
Sort Order :
From The :
 
Thread Tools  Search this thread 
normanholz
Total Points:
165
Status Points:
115
Green Belt
November 4, 2009 9:29 AM PST
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<Byte> 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
Ying H (Intel)
Total Points:
5,217
Status Points:
4,717
Brown Belt
November 5, 2009 12:00 AM PST
Rate
 
#1
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<Byte> 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/intel-integrated-performance-primitives/topic/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)
<<http://registrationcenter.intel.com/irc_nas/1621/w_ipp_em64t_p_6.1.2.041.exe>>
<<http://registrationcenter.intel.com/irc_nas/1621/w_ipp-uic_p_6.1.2.051.zip>>

Regards
Ying

normanholz
Total Points:
165
Status Points:
115
Green Belt
November 5, 2009 6:47 AM PST
Rate
 
#2 Reply to #1
Quoting - Ying H (Intel)

Hi Norman

I'm updating the thread: http://software.intel.com/en-us/forums/intel-integrated-performance-primitives/topic/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)
<<http://registrationcenter.intel.com/irc_nas/1621/w_ipp_em64t_p_6.1.2.041.exe>>
<<http://registrationcenter.intel.com/irc_nas/1621/w_ipp-uic_p_6.1.2.051.zip>>

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 (Intel)
Total Points:
26,500
Status Points:
26,500
Black Belt
November 6, 2009 10:48 AM PST
Rate
 
#3 Reply to #2

Norman,

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

Regards,
  Vladimir

normanholz
Total Points:
165
Status Points:
115
Green Belt
November 9, 2009 5:58 AM PST
Rate
 
#4 Reply to #3

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<Byte>^ 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 (Intel)
Total Points:
26,500
Status Points:
26,500
Black Belt
November 11, 2009 10:48 PM PST
Rate
 
#5 Reply to #3

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
Total Points:
165
Status Points:
115
Green Belt
November 12, 2009 9:02 AM PST
Rate
 
#6 Reply to #5

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




Intel Software Network Forums Statistics

8493 users have contributed to 31630 threads and 100780 posts to date.
In the past 24 hours, we have 25 new thread(s) 126 new posts(s), and 162 new user(s).

In the past 3 days, the most popular thread for everyone has been Implicite multithreading ??? The most posts were made to Crash when loading skeleton The post with the most views is Dear Steve, excuse me for a d

Please welcome our newest member mdward