This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

questions of VLIB_packMask32 and VLIB_unpackMask32

 

My video frame size is 320*320, it is grayscale.

code:

------------------------------------------------------

VLIB_packMask32(frame,frame32,320*320);

VLIB_unpackMask32(frame32,frame,320*320);   //VLIB_unpackMask32(frame32,frame,0);   I make some change. But I get the 8-bit Y data display.

 display(frame);

------------------------------------------------------ 

refer to the examples of VLIB, but I cannnot get the  8-bit Y data display.

 

 where the question?

 

 

 

  • Can you fill in what device you are using, and what version of the various software tools and components you are using as well?

  • sorry!

    I using DM6446 and vlib2.1,

    Dubeg under Linux.

  •  

    Hello,

     

    Your syntax seems right.

    I am assuming you are using the right data-types too - frame should be unsigned char and frame32 should be unsigned int.

    I am also assuming you have linearly arranged the input image as a 1D array.

    VLIB_unpackMask32(frame32,frame,0); works because the loop counter is zero and nothing is written in frame and frame already has the data.

     

    There are two assumptions used in these VLIB functions: (from documentation)

    • The buffer maskImage need to be double-word aligned in memory.
    • The pixelCount must be a multiple of 8.

    The second criteria is satisfied as 320*320 is a multiple of 8.

    Sometimes alignment may be a problem. You can use the pragma #DATA_ALIGN to explicitly make the array double-word aligned.

     

    If you can share the input image and the output image, I might be able to to help you better.

     

    Regards,

    Senthil

     

  • Senthil, Thanks!

    -----------------------------

    VLIB_unpackMask32(frame32,frame,0); works because the loop counter is zero and nothing is written in frame and frame already has the data.

    -----------------------------

    Yes, I think the reason is right. I rewrite the pragram code:

    --------------------------------------------------------------------------------

    void bpack(void)
    {
     char sprintBuffer[200]; 
     int i=0,j=0,k=0;


     int *inputImage;

     Uint8 *y;


     int sHEI=320,sWID=320;
     y=(Uint8*)malloc(sHEI*sWID); 

    inputImage=(int *)malloc(sizeof(int)*sHEI*sWID/32); // I try define the inputImage as unsigned int, the result is same.


     memset(y,0,sHEI*sWID);
     

    //make a Y image
     for(i=4;i<8;i++)
     {
          for(j=15;j<18;j++)
        {
               *(y+i*sWID+j)=1;
         }
     }
     for(i=10;i<15;i++)
     {
               for(j=5;j<18;j++)
                  {
                *(y+i*sWID+j)=1;
                }
     }

     memset(inputImage,0,sizeof(int)*sHEI*sWID/32);
     VLIB_packMask32(y,inputImage,sHEI*sWID);

     VLIB_unpackMask32(inputImage,y,0);


     free(inputImage);
     free(y);
     
    }

     

    --------------------------------------------------------------------------------

     

  •  

    Hello,

     

    This seems to be wrong. Use the appropriate array size instead of 0.

    VLIB_unpackMask32(inputImage,y,0);

     

    Please try to debug step by step. It is difficult to debug several functions at a time.

    Run VLIB_packMask32 and see if the output is correct by inspect. Only after fixing this, you should move to the unpack function.


    Regards,

    Senthil