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.

IPNC368 osd can't display my own icon image

Hi, erveryone

I try to display a custom icon in video, but it can't work.

My method is,

1. In videoswosd.h

#define SWOSD_WINDOW_20_CJK_TEST     11

change #define SWOSD_WINDOW_FR_ST     11  to          #define SWOSD_WINDOW_FR_ST     12,

2.

in static int swosdChangeXYParmDetail(int streamId,SWOSD_Hndl *osdHndl ) function last, add

  bmpWinPrm.enable    = SWOSD_RBOOLFALSE;
  bmpWinPrm.format     = SWOSD_FORMATYUV420p;
  bmpWinPrm.startX    = 0;
  bmpWinPrm.startY    = 0;
  bmpWinPrm.width     = SWOSD_CHARWIDTHTILOGO_80_32;
  bmpWinPrm.height    = SWOSD_CHARHEIGHTTILOGO_80_32;
  bmpWinPrm.lineOffset   = SWOSD_CHARWIDTHTILOGO_80_32;
  bmpWinPrm.transperencyVal  = SWOSD_OSDBLACKTRANSVAL;
  bmpWinPrm.transperencyRange  = SWOSD_OSDBLACKTRANSRANGE;
  bmpWinPrm.transperencyEnable    = SWOSD_BMPTRANSDISABLE;
  bmpWinPrm.resizeEnable   = 0;
  bmpWinPrm.bmpWinAddr   = iconBuff80_Y;
  bmpWinPrm.bmpWinAddrUV          = iconBuff80_UV;
  SWOSD_setBmpWinPrm(osdHndl, SWOSD_WINDOW_20_CJK_TEST, &bmpWinPrm);

3.
in static int swosdDisplay(int streamId, SWOSD_Hndl *osdHndl ) function last,

SWOSD_setBmpWinEnable(osdHndl, SWOSD_WINDOW_20_CJK_TEST, SWOSD_BMPWINENABLE);

but this can't work, I don't know why?

  • I found problem is window number limitation(max 15 windows).  I see macro definition #define SWOSD_WINMAX     20  in alg_ti_swosd.h file, but I can't find where is it used in source code, It seems no effect.

    who know where to enlarge the  window number limitation?

     

    I found a new problem is yuv420 color format.  I get only green color, dispite I change the yuv data to different color. like this

    unsigned char CJKTest_Y[64*128] = {255}, CJKTest_UV[32*64][2] = {{{0,0}}};

      bmpWinPrm.enable    = SWOSD_RBOOLFALSE;
      bmpWinPrm.format     = SWOSD_FORMATYUV420p;
      bmpWinPrm.startX    = 200;
      bmpWinPrm.startY    = 300;
      bmpWinPrm.width     = 64;
      bmpWinPrm.height    = 64;
      bmpWinPrm.lineOffset   = 64;
      bmpWinPrm.transperencyVal  = 0;
      bmpWinPrm.transperencyRange  = 0;
      bmpWinPrm.transperencyEnable    = 0;
      bmpWinPrm.resizeEnable   = 0;
      bmpWinPrm.userTransparancy      = 0;
      bmpWinPrm.bmpWinAddr   = CJKTest_Y;
      bmpWinPrm.bmpWinAddrUV          = CJKTest_UV;
      SWOSD_setBmpWinPrm(osdHndl, SWOSD_WINDOW_TWO, &bmpWinPrm);

    I don't know what problem is, anyone can get help?

     

  • Hi Won,

       Can you please tell what is the exact error or output you are getting?

     

    As you have told that you are trying to display custom icon in video what is the height, width and line offset?

    Is it same as set below??

      bmpWinPrm.width     = SWOSD_CHARWIDTHTILOGO_80_32;
      bmpWinPrm.height    = SWOSD_CHARHEIGHTTILOGO_80_32;
      bmpWinPrm.lineOffset   = SWOSD_CHARWIDTHTILOGO_80_32

     

     

    Regards,

    Rajiv

  • Hi Won,

    The macro definition  #define SWOSD_WINMAX  in alg_ti_swosd.h is used by the osd library only to check no. of osd window should not exceed then defined. Here there is no One can set max no. of window supported, but have to build swosd library again.

     

    Answer to next question:

     

    Can you please tell where you are finding green color?? I mean when you are applying swosd in live video or simply viewing the image in some image viewer??

     

    Can you please varify below

      bmpWinPrm.width     = 64;
      bmpWinPrm.height    = 64;
      bmpWinPrm.lineOffset   = 64

    whether these are set correct or not???

     

    Regards,

    Rajiv

  • Thanks rajiv!

    The rectangle's position and size are both correct, but color is abnormal. It should be white color, but I got green.

    my code is

    unsigned char CJKTest_Y[102*77*4] = {255}, CJKTest_UV[102*77*4] = {128};  // white color, (255, 128, 128)

    #if 1
      bmpWinPrm.enable    = SWOSD_RBOOLFALSE;
      bmpWinPrm.format     = SWOSD_FORMATYUV420p;
      bmpWinPrm.startX    = 800;
      bmpWinPrm.startY    = 600;
      bmpWinPrm.width     = 100;
      bmpWinPrm.height    = 50;
      bmpWinPrm.lineOffset   = 0;
      bmpWinPrm.transperencyVal  = SWOSD_OSDBLACKTRANSVAL;
      bmpWinPrm.transperencyRange  = SWOSD_OSDBLACKTRANSRANGE;
      bmpWinPrm.transperencyEnable    = 0;
      bmpWinPrm.resizeEnable   = 0;
      bmpWinPrm.userTransparancy      = 1;
      bmpWinPrm.bmpWinAddr   = CJKTest_Y;
      bmpWinPrm.bmpWinAddrUV          = CJKTest_UV;
      SWOSD_setBmpWinPrm(osdHndl, 1, &bmpWinPrm);
      SWOSD_setBmpWinEnable(osdHndl, 1, SWOSD_BMPWINENABLE);//TEXT
    #endif

    then I get following snapshot picture,

    I try much many vary different setting combination for bmpWinPrm.xxxx(such as all the possible transparecy setting, different lineOffset  value, etc), but it got green always.

    An another strange thing is that there are several pixles(light dots)' color different with neighor area in the green recatangle, note, It is not relations with my PC''s LCD.

    and there are some additional problem,

    1. I can't understand what meaning bmpWinPrm.lineOffset stand for, what is it effect when setting for vary value?

    2.  If I don't call SWOSD_setBmpWinEnable(osdHndl, id, SWOSD_BMPWINENABLE), It can't display the green rectangle. Although I set the bmpWinPrm.enable    = SWOSD_RBOOLTRUE. So, what meaning for bmpWinPrm.enable?

    3. About transparecy.  I read the "SoftwareOSD_UserGuide_IPNC36X.pdf",  but I can't understand [transperencyVal - transperencyRange, transperencyVal + transperencyRange]  control what transparency? Is for Y, for U, or for V?  I think we should seperate control the three color components.

    as following macro definition

    #define SWOSD_OSDWHITETRANSVAL       0x80FF
    #define SWOSD_OSDWHITETRANSRANGE      0x48
    #define SWOSD_OSDBLACKTRANSVAL       0x00
    #define SWOSD_OSDBLACKTRANSRANGE      0x48

    [0x00-0x48, 0x00+0x48] is transparency range, how understand the negtive value -0x48?

     

  • so, I give up the previous method, I try to write my own osd function for draw dot matrix for chinese string. I read the function int ALG_swosdDrawLine(ALG_SwosdRunPrm *bufInfo, ALG_SwosdLineInfo *lineInfo) in Alg_swosd.c file. Unfortunly, I found I can't undersand again.

    for follwing code segment, my question is in comment,

      if(bufInfo->videoDataFormat==DRV_DATA_FORMAT_YUV422) {

        incAddr    = bufInfo->videoOffsetH*2;
      /* 

    why not incAddr = (bufInfo->videoOffsetH + bufInfo->videoWidth) * 2???

    I think it should be a pixel line length(bufInfo->videoOffsetH + bufInfo->videoWidth) multiply the bytes per pixel(2).

    */

        startAddr  = bufInfo->videoInOutAddr + lineInfo->startY * incAddr + lineInfo->startX*2; 

        /* why not  startAddr  = bufInfo->videoInOutAddr + (lineInfo->startY -1)* incAddr + lineInfo->startX * 2;  ? */


        hlen      *= 2;
        color      = (lineInfo->colorY << 24) + (lineInfo->colorC << 16) + (lineInfo->colorY << 8) + lineInfo->colorC; /* this is yuyv   yuv422 ??? */
      } else {
        incAddr   = bufInfo->videoOffsetH;
        startAddr = bufInfo->videoInOutAddr + lineInfo->startY * incAddr + lineInfo->startX;
        color     = (lineInfo->colorY << 24) + (lineInfo->colorY << 16) + (lineInfo->colorY << 8 )+ lineInfo->colorY;
      }

      hlen = OSA_floor(hlen, 4);

      while(vlen) {
        curAddr = (Uint32*)startAddr;

        for(i=0; i<hlen/4; i++)
          *curAddr++ = color;

        startAddr+=incAddr;
        vlen--;
      }

      #if 1
      if(bufInfo->videoDataFormat==DRV_DATA_FORMAT_YUV420) {

        startAddr  = bufInfo->videoInOutAddr + bufInfo->videoOffsetH*bufInfo->videoOffsetV;

    /* bufInfo->videoOffsetH*bufInfo->videoOffsetV stand for what ???, */


        startAddr += lineInfo->startY/2 * incAddr + lineInfo->startX;
        color      = (lineInfo->colorC << 24) + (lineInfo->colorC << 16) + (lineInfo->colorC << 8) + lineInfo->colorC;

    /* for yuv420, 2*2 y, corresponding a uv, But there use 2 uv */


        vlen      /= 2;

        while(vlen) {
          curAddr = (Uint32*)startAddr;

          for(i=0; i<hlen/4; i++)
            *curAddr++ = color;

          startAddr+=incAddr;
          vlen--;
        }
      }
      #endif

  • Won,

    1.Please dump bitmap image and view it. As you are setting Luma  0xFF and Chroma 0x00 it is green color. Basicaly 8 bit is used for luma and 8 bit for chroma. Chroma is signed signed value. Thats why Chroma value of white color is 0x80 and luma is 0xFF and combined both White color is 0x80FF.

     

    2. bmpWinPrm.enable enable the bmp window and bitmap image only get displayed when window is enable. I don't know what the problem but definitely somewhere before calling SWOSD_setBmpWinEnable(osdHndl, id, SWOSD_BMPWINENABLE) bmpWinPrm.enable is getting disabled.

    3.  transperencyVal we are only setting for luma.

     

    Regards,

    Rajiv

     

     

     

     

  • Thanks rajiv very much.

    I have give up the string draw method in VideoSwosdThr.c. Because I can't use it correctly encountered many times try and failure.

    So, I write my own string draw function like ALG_swosdDrawLine(), but I found a strange display problem. It seems the Chroma of my char's dot matrix data impact adjacent pixel's color. My english is pool, I don't know how to discript the phenomenon, maybe call it blur or vignette. The snapshot picture is following,

     

    To expose problem, I streched out the picture. Note, In the surrounding of the green characters, have some blur, its color different with backgound.

    I don't why. I just only modify chroma data for character's display dot. In fact, I treat a yuv macro pixel (in yuv420,  2X2 Y, 1 UV) as a display dot, that is to say, I zoom out the character size 2 times in horizonal and vertical direction.

    can anyone get some help? thanks!