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.

Found bug in DM812X_DRAW_line function for OSD

Hi all,

I'm trying to figure out how to get the characters and rectangles in the OSD to be specific colors. Any help with this would be appreciated.

In my research I came across the DM812X_DRAW_line function (in ipnc_rdk\ipnc_mcfw\mcfw\src_bios6\links_m3vpss\alg\common\ti_draw.c) which is called 4 times when drawing a rectangle in the video frame to the specific color requested. The DRAW_line function calls DM81XX_EDMA3_memset to color the lines in the video frame.

The first line is drawn after the following statements:

lineInfo.thickness = pRectInfo->thickness;
lineInfo.colorY = pRectInfo->colorY;
lineInfo.colorC = pRectInfo->colorC;

lineInfo.startX = pRectInfo->startX;
lineInfo.startY = pRectInfo->startY;
lineInfo.length = pRectInfo->width;
lineInfo.vertLine = FALSE;

DM812X_DRAW_line(pInFrameInfo, &lineInfo);

In the DM812X_DRAW_line function, when setting the color before calling EDMA:

 if ((pInFrameInfo->videoDataFormat == FVID2_DF_YUV420SP_VU) ||
        (pInFrameInfo->videoDataFormat == FVID2_DF_YUV420SP_UV))
    {
        incAddr = pInFrameInfo->videoOffsetH;
        startAddr =
            pInFrameInfo->videoInOutAddrY + pLineInfo->startY * incAddr +
            pLineInfo->startX;
        color =
            (pLineInfo->colorY << 24) + (pLineInfo->colorY << 16) +
            (pLineInfo->colorY << 8) + pLineInfo->colorY;
    }

Only the Y component is copied, not the C. In the YUV420 color scheme, there is YYYYCbCr. From what I understand here, only the black/grey component is used. Is this a bug or just an oversight?

How do I color the rectangles red or blue? Will I need another EDMA transfer with the color component?

Thanks,

Mechi

  • Hello,

    I will notify the IPNC team for help.

    Best Regards,
    Margarita
  • Hello,

    I decided to figure this out myself...

    It seems that what I though was an oversight was actually just the copying of the Y component (gray-scale) and not the UV (color) component.

    So I wrote code to copy the color in the DM812x_DRAW_line function (in \ipnc_rdk\ipnc_mcfw\mcfw\src_bios6\links_m3vpss\alg\common\ti_draw.c). The code below is placed at the end of the function.

    // if YUV frame, draw UV (color) part of line
        if ((pInFrameInfo->videoDataFormat == FVID2_DF_YUV420SP_VU) ||
            (pInFrameInfo->videoDataFormat == FVID2_DF_YUV420SP_UV))
        {
            incAddr = pInFrameInfo->videoOffsetH / 2;
    
            startAddr =
                pInFrameInfo->videoInOutAddrUV + (pLineInfo->startY * incAddr +
                pLineInfo->startX);
    
            color =
                (pLineInfo->colorC << 24) + (pLineInfo->colorC << 16) +
                (pLineInfo->colorC << 8) + pLineInfo->colorC;
    
            DM81XX_EDMA3_memset(gDrawEdmaHndl.dmaHndl.chId,                 // chId
                                DRAW_EDMA_QUEUEID_DRAW,              		// dmaQueue
                                color,                             			// setValue
                                (UInt32) startAddr,                			// dstAddr
                                hlen,                              			// setWidth
                                vlen,                              			// setHeight
                                incAddr);                          			// lineOffset
        }

    The results were VERY surprising - instead of just coloring the rectangles, 3 extra rectangles, copies of the original, are shown equidistant from the original 3 rectangles! The extra 3 rectangles are just the UV factor (the Y changes according to the background).

    The 1st attached frame is without the code above, and the second is when the above code is added in.

    Any help with this issue would be appreciated.

    Thanks,

    Mechi

  • I figured out the problem with the rectangles. The following code works. Color is 16-bit, with 8 bytes for U and 8 bytes for V.

    RED: y = 82, u = 90, v = 240

    BLUE: y = 41, u = 240, v = 110

    At the end of the DM812x_DRAW_line function (in \ipnc_rdk\ipnc_mcfw\mcfw\src_bios6\links_m3vpss\alg\common\ti_draw.c):

        // if YUV frame, draw UV (color) part of line
        if ((pInFrameInfo->videoDataFormat == FVID2_DF_YUV420SP_VU) ||
            (pInFrameInfo->videoDataFormat == FVID2_DF_YUV420SP_UV))
        {
            incAddr = pInFrameInfo->videoOffsetH / 2;
    
            startAddr =
                pInFrameInfo->videoInOutAddrUV + (pLineInfo->startY * incAddr +
                pLineInfo->startX);
    
            // color is UV - 2 bytes
            color = (pLineInfo->colorC << 16) + pLineInfo->colorC;
    
            for (j=0; j < (vlen>>1); j++)
            {
    			for (i = 0; i < (hlen >> 2); i++)
    			{
    				*((unsigned int *) startAddr + j*(incAddr>>1) + i) = color;
    			}
            }
        }