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

When i use class CJPEGencoder from jpegview.......

tkx007
Beginner
966 Views
Hi
When I use class CJPEGencoder from jpegview,I successed in compressing a RGB24(900k) pictuer to a gray JPEG picture(10k).But when i choose the JC_YCBCR (or any other color mode)destination JPEG clore mode, the picture becomes very bad,although the quality is choosed 100,sampling 444.The face in it becomes green.
Wheremay be the problom from?
Thank U.
0 Kudos
7 Replies
Vladimir_Dudnik
Employee
966 Views

Hi,

could you please provide more info about your issue? What IPP version, OS, platform did you use? Might be you can provide us simple test case?

You also can take a look on CJPGViewDoc::SaveAsJPEG() function, which is able to encode RGB24 picture to YCBCR JPEG.

Regards,
Vladimir

0 Kudos
tkx007
Beginner
966 Views
Hi
I use CJPEGEncoder like this:
CFile fp;
Ipp8u* pRGBbuf;
int readnum,rst;
pRGBbuf=ippiMalloc_8u_C3(640, 480, &stepC3);
if(!fp.Open("f:picture",CFile::modeRead,NULL))
printf("wrong:can't open primitive picture! ");
readnum=fp.Read(pRGBbuf,PicLen);
fp.Close();
if(readnum!=PicLen)
printf("wrong:read %d bytes from the primitive picture! ",readnum);
CJPEGEncoder encoder;
IppiSize roi={640,480};
encoder.SetSource(pRGBbuf,640*3,roi,3,JC_RGB);
int JPEGSize=640*480*3;
Ipp8u* pJPEG;
pJPEG = (Ipp8u*)ippMalloc(JPEGSize);
JSS sampling=JS_444;
encoder.SetDestinatio(pJPEG,JPEGSize,
50,sampling,JC_YCBCR,JPEG_BASELINE,0);
encoder.WriteHeader();
JPEGSize = encoder.m_dst.currPos;
cout<<"head length:"<< encoder.WriteData();
JPEGSize = encoder.m_dst.currPos;
cout<<"data length:"<<fp.Open("f:fff.jpeg",CFile::modeWrite|CFile::modeRead|CFile::modeCreate,NULL);
fp.Write (pJPEG,JPEGSize);
fp.Close ();
P.S:VC++6.0 windows XP intel Pentium
0 Kudos
Vladimir_Dudnik
Employee
966 Views

Hi,

note that ippiMalloc aligns memory on 32 byte bondary and return you line stepfor further reference. But you use your own line step value (640*3) in SetSource which does not match the actual line step returned by ippiMalloc. I think when you correct this (just use stepC3 returned by ippiMalloc) program should work correctly.

Regards,
Vladimir

0 Kudos
tkx007
Beginner
966 Views
Hi:
I have tried stepC3 instead of 640*3,but just the same result.
There is no problem with the shape in the picture,but the colour.
I choose YCbCr,but the result is almost gray. Face becomes blue,just like ghost. :mansad:
0 Kudos
Vladimir_Dudnik
Employee
966 Views

Hi,

you removed geometrical artifacts, you have before, so it actually means that not the same result, right?

Second, when you specify input image color space are you sure it is RGB? If you got data from BMP file - color spaceshould beBGR, so could you please try to change?

Finally, I recommend you to take a lookat existing IPP sample,JPEGView, it was speciallydeveloped to help people to understand how to use IPP functions to build JPEG codec

Regards,
Vladimir

0 Kudos
tkx007
Beginner
966 Views
Thank you very very much.
The picture comes from usb camera.Information from the driver says the
color mode is RGB,while it really is,as you say BGR.
Best wishes to you !
Intel forever!
0 Kudos
Vladimir_Dudnik
Employee
966 Views

Wow, that's great! We are glad to help.

By the way, in the next version of IPP (v5.1 which is cooming soon, sometime in Q2) we will add threading into JPEG encoder, so if you use dual core processor, you will be able to compress more for the same time. Stay tuned with IPP :)

Regards,
Vladimir

0 Kudos
Reply