Community
cancel
Showing results for 
Search instead for 
Did you mean: 
vetroxl
Beginner
92 Views

Confused with planar images

Jump to solution
Hi,
I have searched the forums and docs but I'm still confused with planar images. My specific question is about a 3 plane 4:1:1 image construct. How is this layed out in memory? Is the Y plane 4 bytes long? Is it y1, y2 , y3, y4?
I am usingippiYCbCr422ToYCbCr411_8u_C2P3R to convert.
this is how i'm creating my 4:1:1 image;
[cpp] m_numChannels = 3; IppiSize chromaSize = { m_size.width/4, m_size.height }; m_channels[0] = ippiMalloc_8u_C4( m_size.width, m_size.height, &(m_stepBytes[0]) ); m_channelSize[0] = m_size; m_channels[1] = ippiMalloc_8u_C1( chromaSize.width, chromaSize.height, &(m_stepBytes[1]) ); m_channelSize[1] = chromaSize; m_channels[2] = ippiMalloc_8u_C1( chromaSize.width, chromaSize.height, &(m_stepBytes[2]) ); m_channelSize[2] = chromaSize;[/cpp]
Thanks!
0 Kudos
1 Solution
Ying_H_Intel
Employee
92 Views

Hello,

The Planar (P)and channel (C) descriptors inippiYCbCr422ToYCbCr411_8u_C2P3R means covert 2 channeldata to 3 planar data, which
Y planar , which is a matrix withm_size.widthx m_size.height
Cb planar, which is a matrix with m_size.width/4 x m_size.height
Cr planar, which is a matrix with m_size.width/4 x m_size.height.

If consider tomalloc continousmemory , then 1 planar (widthxheight) image = 1 channel (widthxheigh) image. So if you use ippiMalloc, you can use

m_numChannels = 3;
IppiSize chromaSize = { m_size.width, m_size.height };
m_channels[0] = ippiMalloc_8u_C1( m_size.width, m_size.height, &(m_stepBytes[0]) ); m_channels[1] = ippiMalloc_8u_C1( m_size.width/4, m_size.height, &(m_stepBytes]));
m_channels[2] = ippiMalloc_8u_C1( m_size.width/4, m_size.height, &(m_stepBytes[2]) );

Best Regards,
Ying

A similiar example are under ippiMallocin ipp Reference manual.

The function ippiMalloc is declared in the ippi.h file. This function allocates a memory block aligned to a 32-byte boundary for elements of different data types. Every line of the image is aligned in accordance with the pStepBytes parameter, which is calculated by the ippiMalloc function and returned for further use.

The function ippiMalloc allocates one continuous memory block, whereas functions that operate on planar images require an array of separate pointers (IppType* plane[3]) to each plane as input. The ippiMalloc function should be called three times in this case. The code ExampleSetting Values to Pointers to Image Planes demonstrates how to construct such an array and set correct values to the pointers to use the allocated memory block with the Intel IPP functions operating on planar images. Note that pStepBytes should be specified for each plane. The example is given for 8u data type.

Setting Values to Pointers to Image Planes

int stepBytes[3];
Ipp8u* plane[3];
   plane[0] = ippiMalloc_8u_C1(widthPixels, heightPixels,
                               &(stepBytes [0]));
   plane[1] = ippiMalloc_8u_C1(widthPixels/2, heightPixels/2,
                               &(stepBytes [1]));
   plane[2] = ippiMalloc_8u_C1(widthPixels/2, heightPixels/2,
                               &(stepBytes [2]));

View solution in original post

5 Replies
vetroxl
Beginner
92 Views
Hi!
Thanks for the reply. I have already seen the top link. However, it did not answer my question and I can't see the second link. Is possible to repost the second link please?
Thanks,
vetroxl
Beginner
92 Views
Hi, ok, thanks, I found it in the help and I have already read it. My question remains. Should I be allocting this way?
[bash]m_numChannels = 3; IppiSize chromaSize = { m_size.width, m_size.height }; m_channels[0] = ippiMalloc_8u_C4( m_size.width, m_size.height, &(m_stepBytes[0]) ); m_channelSize[0] = m_size; m_channels[1] = ippiMalloc_8u_C2( m_size.width/4, m_size.height, &(m_stepBytes[1]) ); m_channelSize[1] = chromaSize; m_channels[2] = ippiMalloc_8u_C2( m_size.width/4, m_size.height, &(m_stepBytes[2]) ); m_channelSize[2] = chromaSize;[/bash]
Ying_H_Intel
Employee
93 Views

Hello,

The Planar (P)and channel (C) descriptors inippiYCbCr422ToYCbCr411_8u_C2P3R means covert 2 channeldata to 3 planar data, which
Y planar , which is a matrix withm_size.widthx m_size.height
Cb planar, which is a matrix with m_size.width/4 x m_size.height
Cr planar, which is a matrix with m_size.width/4 x m_size.height.

If consider tomalloc continousmemory , then 1 planar (widthxheight) image = 1 channel (widthxheigh) image. So if you use ippiMalloc, you can use

m_numChannels = 3;
IppiSize chromaSize = { m_size.width, m_size.height };
m_channels[0] = ippiMalloc_8u_C1( m_size.width, m_size.height, &(m_stepBytes[0]) ); m_channels[1] = ippiMalloc_8u_C1( m_size.width/4, m_size.height, &(m_stepBytes]));
m_channels[2] = ippiMalloc_8u_C1( m_size.width/4, m_size.height, &(m_stepBytes[2]) );

Best Regards,
Ying

A similiar example are under ippiMallocin ipp Reference manual.

The function ippiMalloc is declared in the ippi.h file. This function allocates a memory block aligned to a 32-byte boundary for elements of different data types. Every line of the image is aligned in accordance with the pStepBytes parameter, which is calculated by the ippiMalloc function and returned for further use.

The function ippiMalloc allocates one continuous memory block, whereas functions that operate on planar images require an array of separate pointers (IppType* plane[3]) to each plane as input. The ippiMalloc function should be called three times in this case. The code ExampleSetting Values to Pointers to Image Planes demonstrates how to construct such an array and set correct values to the pointers to use the allocated memory block with the Intel IPP functions operating on planar images. Note that pStepBytes should be specified for each plane. The example is given for 8u data type.

Setting Values to Pointers to Image Planes

int stepBytes[3];
Ipp8u* plane[3];
   plane[0] = ippiMalloc_8u_C1(widthPixels, heightPixels,
                               &(stepBytes [0]));
   plane[1] = ippiMalloc_8u_C1(widthPixels/2, heightPixels/2,
                               &(stepBytes [1]));
   plane[2] = ippiMalloc_8u_C1(widthPixels/2, heightPixels/2,
                               &(stepBytes [2]));

View solution in original post

vetroxl
Beginner
92 Views
Thanks for the clarification!
Reply