Intel® Integrated Performance Primitives
Deliberate problems developing high-performance vision, signal, security, and storage applications.

introducing myself + JPEG question

jmuffat
Beginner
412 Views
Hi everybody,

I am Jrme Muffat-Mridol and am currently writing a photo browser that aims at being to photos what Google Earth is to maps. If you want to check it out, a tech preview is available for download at www.gpuviewer.com

I have switched to IPP yesterday, so it's all a bit new to me and I might not have picked the best approach but I chose the IJL sample as the basis for JPG coding/decoding. This went smoothly and works quite fast, but...

When targetting a 4 bytes/pixel output, the IJL seems to require RGBA order and this isn't ideal when it comes to filling in a texture (BGRA wanted).

I 'd rather avoid adding a shuffling phase, or inserting shuffling through interrupted decoding: there shouldn't be a need for overhead.

My guess is that I should be using another sample as my starting point. So, I wonder, what's the best way to use IPP for JPEG support?
0 Kudos
4 Replies
Vladimir_Dudnik
Employee
412 Views

Hi Jerom,

The IPP IJL sample is demostrate how to implement Intel JPEG Library API with new Intel Integrated Performance Primitives library. That old API has some limitations, we do not plan to extend it in future. I'd rather recommend you to take a look on IPP JPEG codec which is part of JPEGView sample.

This codec is implemented as a C++ class, available in source code and supports some new features which is not implemented in IJG (libjpeg) or IJL versions of JPEG codecs. For example, it supports lossy coding for 12-bit images, lossless coding for images with 2..16-bit per color channel data and it utilizes additional cpu cores through OpenMP threading.

In the current implementation it also do not provide convertion to BGRA, but it is easy to add such capability by modification ColorConvert() method CJPEGDecoder class. Basically you need to add appropriate case into switch statement.

Regards,
Vladimir

0 Kudos
jmuffat
Beginner
412 Views
Thanks a lot Vladimir,

I guess I started with IJL because we used it in the past and were quite happy with it. Old habbits die hard... I'm glad I asked here as I was going to dive into the UMC (Unified Media Classes) sample instead and it was a bit scary.
0 Kudos
jmuffat
Beginner
412 Views
I have now implemented the solution you suggested and am happy to report it works brilliantly, it also has let me deal with cases where I tile a number of thumbnails into one bigger texture much more easily. This is all good.

In case this can help someone else, here is the snipped of code to add in CJPEGDecoder::ColorConvert to enable BGRA output :

// YCbCr to BGRA
if(m_jpeg_color == JC_YCBCR && m_dst.color == JC_BGRA)
{
int srcStep;
const Ipp8u* pSrc8u[3];

srcStep = m_ccomp[0].m_cc_step;

pSrc8u[0] = m_ccomp[0].GetCCBufferPtr(thread_id);
pSrc8u[1] = m_ccomp[1].GetCCBufferPtr(thread_id);
pSrc8u[2] = m_ccomp[2].GetCCBufferPtr(thread_id);

status = ippiYCbCrToBGR_8u_P3C4R(pSrc8u,srcStep,pDst8u,dstStep,roi,0xFF);

if(ippStsNoErr != status)
{
LOG1("IPP Error: ippiYCbCrToBGR_8u_P3C4R() failed - ",status);
return JPEG_ERR_INTERNAL;
}
}

Which I've added just after the code for "YCbCr to BGR" (although the order doesn't matter)

Hoping this can help somebody.
0 Kudos
Vladimir_Dudnik
Employee
412 Views

Thanks, I'm glad that it works for you

Regards,
Vladimir

0 Kudos
Reply