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

How to compress 411 three plane image to JPEG?

yaybblfh
Beginner
592 Views
I use IPP version 5.3
My code based on c:\Program Files\Intel\IPP\5.3\ia32\ipp-samples\image-codecs\jpegview,
CJPEGEncoder class.

parameters:
m_RestartInterval(0),m_HuffmanOpt(0),m_Mode(JPEG_BASELINE),m_Color(JC_YCBCR),
m_Sampling(JS_411),m_Precision(8),m_Channels(3)

My calls:
Ipp8u* ppSrc[4];
ppSrc[0] = pSrc;
ppSrc[1] = ppSrc[0] + m_Size.width * m_Size.height;
ppSrc[2] = ppSrc[1] + m_Size.width * m_Size.height / 4;

int pSrcStep[4];
pSrcStep[0] = m_Size.width;
pSrcStep[1] = m_Size.width / 4;
pSrcStep[2] = m_Size.width / 4;

JERRCODE jerr = SetSource(ppSrc, pSrcStep, m_Size, m_Channels, m_Color, m_Sampling, m_Precision);
jerr = m_MemBuffOutput.Open(m_pBuf, m_Size.width * m_Size.height);
jerr = SetParams(m_Mode, m_Color, m_Sampling, m_RestartInterval, m_HuffmanOpt, m_Quality);
jerr = WriteHeader();
jerr = WriteData();

All results are OK. But JPG image is incorrect:

My
0 Kudos
8 Replies
Vladimir_Dudnik
Employee
592 Views
We will check this. By the way, I do not see attached image (please review 'How to attach file to the forum post' message)


Vladimir
0 Kudos
Sergey_Ryadno
New Contributor I
592 Views
first of all, why you determine source image steps such as

pSrcStep[1] = m_Size.width / 4;
pSrcStep[2] = m_Size.width / 4;

i think it must be

pSrcStep[1] = m_Size.width / 2;
pSrcStep[2] = m_Size.width / 2;


Can you also attach source image file?
0 Kudos
yaybblfh
Beginner
592 Views
Quoting - sryadno
first of all, why you determine source image steps such as

pSrcStep[1] = m_Size.width / 4;
pSrcStep[2] = m_Size.width / 4;

i think it must be

pSrcStep[1] = m_Size.width / 2;
pSrcStep[2] = m_Size.width / 2;


Can you also attach source image file?


Because my image is:



And result JPG for
pSrcStep[1] = m_Size.width / 2;
pSrcStep[2] = m_Size.width / 2;
is incorrect!



Seesource y411_planar.dat
File format:
DWORD Width;
DWORD Height;
BYTE Y[Wight * Height];
BYTE Cr[Width * Height / 4];
BYTE Cb[Width * Height / 4];
0 Kudos
Vladimir_Dudnik
Employee
592 Views

Thanks for clear pictures! It's really helpful. There might be misunderstanding in sampling factors term we use. By historical reason in JPEGwe call 4:1:1 sampling those where chroma planes are downsampled by factor 2 in both horizontal and vertical direction. In video processing world this called as 4:2:0.

We do not support encoding with sampling factors you use.

Vladimir
0 Kudos
yaybblfh
Beginner
592 Views

Thanks for clear pictures! It's really helpful. There might be misunderstanding in sampling factors term we use. By historical reason in JPEGwe call 4:1:1 sampling those where chroma planes are downsampled by factor 2 in both horizontal and vertical direction. In video processing world this called as 4:2:0.

We do not support encoding with sampling factors you use.

Vladimir

Realy! If convert 411 to 420 JPG correct! But why _JPEG_SAMPLING consist 411?

typedef enum _JPEG_SAMPLING
{
JS_444 = 0,
JS_422 = 1,
JS_244 = 2,
JS_411 = 3,
JS_OTHER = 4
} JSS;

0 Kudos
Vladimir_Dudnik
Employee
592 Views
As I said, by historical reasons we still use 4:1:1 name for sampling which frequently called as 4:2:0

Consider this as IPP JPEG specifics.

Vladimir
0 Kudos
yaybblfh
Beginner
592 Views
As I said, by historical reasons we still use 4:1:1 name for sampling which frequently called as 4:2:0

Consider this as IPP JPEG specifics.

Vladimir

And last question. I have 411 pixel format image from videocapture device. But i not found in IPP color convert functions kind of 411 pixel to 420 planar or to 411 planar. What i do?

Many thanks.
! .
0 Kudos
Vladimir_Dudnik
Employee
592 Views

Please check through IPP 6.0 ippcc.h and ippiman.pdf files. There are lot of combinations which look like what you expect:

ippiYCbCr420ToYCbCr420_8u_P3P2R
ippiYCbCr420_8u_P3P2R
ippiYCbCr420ToYCbCr411_8u_P3P2R
ippiYCrCb420ToYCbCr411_8u_P3P2R
ippiYCbCr420ToYCbCr411_8u_P2P3R

ippiYCbCr411ToYCbCr420_8u_P3R
ippiYCbCr411ToYCbCr420_8u_P3P2R
ippiYCbCr411ToYCrCb420_8u_P2P3R
ippiYCbCr411ToYCbCr420_8u_P2P3R

, - ...

Regards,
Vladimir
0 Kudos
Reply