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

Jpeg U-V swapping

atvan
Beginner
673 Views
TheIPP jpeg decoder works very well in most cases. But whendecodingimage froma certain type of encoder, red and blue are swapped in the output images.

Please refer to the attached two files.

I use the ipp decoder decode the jpeg image to YV12, then use the color space converter convert to RGB24 and save as a bmp file. And you can see the red and blue are swapped in the bmp image.

I hope some one can tell me why. Thx.
0 Kudos
1 Solution
jon_shadforth
Novice
673 Views
Quoting - 360360
TheIPP jpeg decoder works very well in most cases. But whendecodingimage froma certain type of encoder, red and blue are swapped in the output images.

Please refer to the attached two files.

I use the ipp decoder decode the jpeg image to YV12, then use the color space converter convert to RGB24 and save as a bmp file. And you can see the red and blue are swapped in the bmp image.

I hope some one can tell me why. Thx.

I found this thread because I had the same or a similar problem. I have written a .net library that uses the sample JPEG codec, but found that red and blue channels were incorrect. I found a link on this site to help build the IPPI sample code (at bottom of this post), and once I'd build the jpegview sample I could then debug it. I was suprised to find the following call in FileOpenDlg.cpp: m_frame.SwapChannels(dstOrder);. This fixes the problem of red and blue channels being in the wrong order.

What suprised me was that this call is made inside a file open dialog class, and is not part of the codec library! I've probably missed something re JPEGs. It is also a shame that the another, possibly important, function call (RGBA_FPX_to_BGRA) is used in this class, but doesn't have any comments/documentation.

My only remaining concern is that I have an additional step involved, which I'd assumed could have been done during decoding.

Feedback appreciated.

Regards,
Jon.

Link for generated Microsoft Studio 2005 solution files from IPPI sample code:

http://software.intel.com/en-us/articles/creating-microsoft-visual-studio-net-2005-project-files/

View solution in original post

0 Kudos
5 Replies
robertd
Beginner
673 Views
Quoting - 360360
TheIPP jpeg decoder works very well in most cases. But whendecodingimage froma certain type of encoder, red and blue are swapped in the output images.

Please refer to the attached two files.

I use the ipp decoder decode the jpeg image to YV12, then use the color space converter convert to RGB24 and save as a bmp file. And you can see the red and blue are swapped in the bmp image.

I hope some one can tell me why. Thx.

I noticed a change in IPP samples umc_color_space_conversion.cpp line 255 of the w_ipp-samples_p_6.0.0.127.

status = ippiYCbCr422ToYCrCb420_8u_C2P3R(pSrc[0], pSrcStep[0], pDst, pDstStep, srcSize);

This change results in our application in exchanging the colors Red and Blue.

In the past it was working correct.
status = ippiYCbCr422ToYCrCb420_8u_C2P3R(pSrc[0], pSrcStep[0], pDstYVU, pDstStepYVU, srcSize);

0 Kudos
atvan
Beginner
673 Views
Quoting - robertd
Quoting - 360360
TheIPP jpeg decoder works very well in most cases. But whendecodingimage froma certain type of encoder, red and blue are swapped in the output images.

Please refer to the attached two files.

I use the ipp decoder decode the jpeg image to YV12, then use the color space converter convert to RGB24 and save as a bmp file. And you can see the red and blue are swapped in the bmp image.

I hope some one can tell me why. Thx.

I noticed a change in IPP samples umc_color_space_conversion.cpp line 255 of the w_ipp-samples_p_6.0.0.127.

status = ippiYCbCr422ToYCrCb420_8u_C2P3R(pSrc[0], pSrcStep[0], pDst, pDstStep, srcSize);

This change results in our application in exchanging the colors Red and Blue.

In the past it was working correct.
status = ippiYCbCr422ToYCrCb420_8u_C2P3R(pSrc[0], pSrcStep[0], pDstYVU, pDstStepYVU, srcSize);


Yes, the change makes the YV12 output correct. Output colors are still not correctwhile usingother YUV formats.

0 Kudos
Vladimir_Dudnik
Employee
673 Views
Hello,

I was not able to reproduce that issue with UIC picnic application.

Regards,
Vladimir

0 Kudos
jon_shadforth
Novice
674 Views
Quoting - 360360
TheIPP jpeg decoder works very well in most cases. But whendecodingimage froma certain type of encoder, red and blue are swapped in the output images.

Please refer to the attached two files.

I use the ipp decoder decode the jpeg image to YV12, then use the color space converter convert to RGB24 and save as a bmp file. And you can see the red and blue are swapped in the bmp image.

I hope some one can tell me why. Thx.

I found this thread because I had the same or a similar problem. I have written a .net library that uses the sample JPEG codec, but found that red and blue channels were incorrect. I found a link on this site to help build the IPPI sample code (at bottom of this post), and once I'd build the jpegview sample I could then debug it. I was suprised to find the following call in FileOpenDlg.cpp: m_frame.SwapChannels(dstOrder);. This fixes the problem of red and blue channels being in the wrong order.

What suprised me was that this call is made inside a file open dialog class, and is not part of the codec library! I've probably missed something re JPEGs. It is also a shame that the another, possibly important, function call (RGBA_FPX_to_BGRA) is used in this class, but doesn't have any comments/documentation.

My only remaining concern is that I have an additional step involved, which I'd assumed could have been done during decoding.

Feedback appreciated.

Regards,
Jon.

Link for generated Microsoft Studio 2005 solution files from IPPI sample code:

http://software.intel.com/en-us/articles/creating-microsoft-visual-studio-net-2005-project-files/
0 Kudos
Vladimir_Dudnik
Employee
673 Views
Please check how do you call IPP JPEG decoder. If you set output color space as JC_RGB then codec will provide you with RGB data which in turn have to be swapped to be correctly displayed on Windows. Note, you may instruct IPP JPEG codec to produce BGR data by specifying JC_BGR as output color space.

Regards,
Vladimir

0 Kudos
Reply