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.

Compiler/TDA2EVM5777: How can i shift the data of frame from camera sensor?

Part Number: TDA2EVM5777

Tool/software: TI C/C++ Compiler

Hi,

I'm working with custom board. It is based on TDA2x EVM board.

The lvds camera that i'm using sends data in format of YVYU.

So, i want to shift 2 bytes of data to make it as YUYV format in ProcessData function of Capture Link.

I reffered http://processors.wiki.ti.com/index.php/PDK/PDK_VPS_FVID2_User_Guide to know the data format of YUV422 interleaved and add the below source code in ProcessData function of Capture Link.

pFrame->addr[0][0] = pFrame->addr[0][2];
pFrame->addr[1][0] = pFrame->addr[1][2];
However, it doesn't work well.
Could you let me know how can i reformat the data of frame? (I mean the way how can i access the data of frame)
Thanks and Regards,
Yoo
  • Hi Yoo,

    What do you mean by shift? 

    For YUV422, driver will always output frame in addr[0][0] location..

    Regards,

    Brijesh

  • Hi Brijesh,

    I mean i want to move back 2bytes of data received from camera sensor.

    For example, 

    If the data from camera is arranged as Y U Y V Y U Y V, i want to remove the first Y U data from the buffer.

    In this case, i want to access to addr of FVID2_frame.

    Could you let me know whether this way is possible or acceptable?

    Regards,

    Yoo

  • Hi,

    I checked from comment in source code and documentation that the data is arranged in single plane when the data format is YUV422 interleaved and progressive.

    The remain thing what i to do is make the data to start from Y V not Y U.

    To do this, i added this below line in CaptureLink_drvProcessData function of captureLink_drv.c .

    ((System_VideoFrameBuffer*)(sysBuf->payload))->bufAddr[0] += 2; 
    I think if i add this line, the data which starts from Y U Y V Y U Y V will be reformated as Y V Y U Y V Y U.
    Please let me know this way is acceptable.
    Thanks and Regards,
    Yoo
  • Yoo,

    it cannot be done in VIP. VIP cannot just shift 2 bytes. 

    Instead of VIP doing it, can you ask sensor/decoder to drop, or shift start position?

    Rgds,

    Brijesh

  • Hi Brijesh,

    Thanks for your help.

    Could you tell me more about where to modify the sensor to postpone the starting point two bytes behind?

    Is that part in ti_components/drivers/pdk_01_10_03_07/packages/ti/drv/vps path?

    Regards,

    Yoo

  • Yoo,

    No, it depends on the sensor that you are using. If sensor supports it, you could shift in sensor. 

    In VIP, you could swap the bytes, but cannot shift.

    Rgds,

    Brijesh

  • Hi Brijesh,

    If i want to swap U data with V data, how could i access to data?

    In VIP, there are addr element of FVID2_frame and ((System_VideoFrameBuffer*)(sysBuf->payload))->bufAddr[0].

    Which one that i need to use?

    Also, i really appreciate if you guide me to swap those data efficiently.

    Thanks again.

    Regards,

    Yoo

  • Hi Yoo,

    FVID2_Frame address is what driver uses..

    If you set the output frame format to YVYU from YUYV, then chroma is swapped. 

    Regards,

    Brijesh

  • Hi Brijesh,

    I wonder how the UV channel data is arranged in second plane of frame when the data format is YUV420_SP.

    I tried to set some value of output frame as 0 and checked that values were changed.

    At first, i thought it organized as order of U V U V U V.

    However, when i swapped the value of U with value of V, the output was not changed.

    The below line is what i used to set some value of frame as 0.

    memset(((System_VideoFrameBuffer*)(sysBuf->payload))->bufAddr[1], 0, sizeof(unsigned char) * 115200);
    And this is what i used to swap the U data with V data.
    for (i = 0; i < 102400; i+=2)
                    {
                        unsigned char tmp = (unsigned char)(*((unsigned char*)pFrame->addr[0][1] + i));
                        *((unsigned char*)pFrame->addr[0][1] + i) = (unsigned char)(*((unsigned char*)pFrame->addr[0][1] + i + 1));
                        *((unsigned char*)pFrame->addr[0][1] + i + 1) = tmp;
                    }
    I think the data is not arranged as i assumed.
    Could you please let me know the order of U/V data in second plane?
    Thanks and Regards,
    Yoo
  • Hi Yoo,

    Yes, for YUV420 output, chroma plane would have U followed by V and so on.

    When you say, it is not working, what does it mean? You don't see bytes swapped in memory?

    Is your buffer cached/ In that case, you would require to invalidate cache before updating buffer and then write back cache after updating.

  • Hi Brijesh,

    Yes, i didn't see any bytes swapped. 

    The frames that are shown in display were all same with before i apply swap the data.

    I applied swap in capture link of vip_capture directory.

    What i can't understand, if the cause of my problem is not invalidating/updating cache, why memset function works well...

    Anyway, I'm going to try to use cache function and reply in this thread.

    Thanks and Regards,

    Yoo

  • Hi Byeongheon Yoo,

    Any further update on this question? Is it resolved?

    Rgds,

    Brijesh