0

I am using an independent hardware development board to perform computer vision operations. This was one example, in order to store and YUV frame in to the DDR memory. But I was bit confused with YUV frame buffer code which is declared as below :

extern U8 inputFrame
void InitTestBuffers(int width, int height)
{
    testFrameSpec.width = width;
    testFrameSpec.height = height;
    testFrameSpec.stride = width;
    testFrameSpec.type = YUV420p;
    testFrameSpec.bytesPP = 1;

    inBuffer.spec = testFrameSpec;
   //******************NEED TO KNOW THE BELOW PART***************
    inBuffer.p1 = (u8*)(&inputFrame);
    inBuffer.p2 = (u8*)((u32)(&inputFrame) + width * height);
    inBuffer.p3 = (u8*)((u32)(&inputFrame) + width * height + width * height / 4);
    //p1,p2,p3 are pointers to 1,2 and 3 image plane
   //*************************************************************
    return;
}

And even in some places it states the below for a buffer frame

static u8 FRAMES outputFrame[FRAME_WIDTH * FRAME_HEIGHT * 3 / 2];

Below is one example where they use these concepts but in different way :

YUV

My question is not about the code understanding but I did not understand why is this computation needed(conceptually).

Community
  • 1
  • 1
MBT
  • 1
  • 5
  • 2
    Search for the definition of YUV420P format and you should understand why the storage is as it is. – Sami Kuhmonen Apr 19 '17 at 10:52
  • Yup, I searched for it and found bit different computation. Which is what I am confused about. One example I have provided the link that mentions YUV. – MBT Apr 19 '17 at 10:59

1 Answers1

0

In this case you seem to deal with planar YCbCr. Planar means that each colour component is stored in the separate array (aka plane). This is opposite of packed format where colour components are all stored in one array (Y Y Y Y Cb Cr or similar patters). So inBuffer.p1 will contain a pointer to array containing width x height of Y values. inBuffer.p2 and inBuffer.p3 will contain a pointer to array containing width x height / 4 Cb and Cr values respectively. / 4 is because one Cb and Cr value is used per 4 Y values.

user7860670
  • 35,849
  • 4
  • 58
  • 84