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.

DM365 resizer and ColorSpace_YUV420PSEMI input format

Hi,

I would like to raise the problem related to DM365 resizer issue.

I want to resize image located in SDRAM and put it back to SDRAM. The resizer works fine as long as input format is IPIPE_UYVY.

But when I am trying to resize image in ColorSpace_YUV420PSEMI format I am getting a very odd output. Output image after resizing contains 2 images one after another squeezed in horizontal direction (refer to image below).

 

According to section "4.7.15 4:2:0 Input Mode" from Video Processing Front End Users Guide the resizer actually can process 420 image data. Unfortunately, source code provided with DVSDK (dvsdk_2_10_01_18\dmai_1_21_00_10\packages\ti\sdo\dmai\linux\dm365\Resize.c) does not support ColorSpace_YUV420PSEMI directly. Therefore, I have modified the corresponding function in Resize.c by adding IPIPE_420SP_Y input format in order to achieve at least luma-component resizing. But without any success. Could you please tell me where have I made a mistake ?

This problem was previously discussed in Video upscaling on DM365, but no solution was provided.

I can provide sample source code, thought it looks like it is impossible to attach it to the message. Please excuse me for providing links to filehosting services.

This is a resizer source code.

This is an input image.

Usage example: ./resizer ./dreamtime720x480.yuv ./test.yuv 1 1

 

  • Hi,

    I assume you want to use resizer for converting YUV420SP input resized to another YUV420SP output. The problem might be coming due to the unavailable support in LSP driver for YUV420SP input to resizer. I am attaching the patch which i had used to implement the required data path. The attachment also has the sample code to call the resizer for YUV420SP input.

     

    Regards,

    Anshuman

    YUV420_420_Resize.zip
  • Hi Anshuman Saxena,

    Thank you very much for the quick reply and provided patch. It was exactly what I was looking for.

  • Hi Anshuman,

    I use dvsdk_2_10_01_18 and PSP_02_10_00_14 on the DM365 EVM board.

    Using your patch and app, I obtain:

    doing preview & resize on in_file = yuv420sp_D1.yuv and writing out to out_file = t.yuv
    starting
    davinci_resizer davinci_resizer.2: Operation mode doesn't match with current hw mode
    Configuring resizer in the chain mode
    Opening resizer device, /dev/davinci_resizer
    Can't get operation mode RSZ_S_OPER_MODE
    : Invalid argument

    Please help to get this to work. 

    do_resize_420_420.zip
  • You just set your bootargs dm365_imp.oper_mode=1

    Resize_Handle hResize;

    hResize =  Resize_create(&rszAttrs);

    BufferGfx_setColorSpace(hcifBuf,ColorSpace_UYVY);

     BufferGfx_setColorSpace(hD1Buf,ColorSpace_UYVY);

    if(Resize_config(hResize,hcifBuf, hD1Buf)<0)

     {

                    printf("Failed to config resizer\n");

                    exit(-1);

    }

    Resize_execute(hResize, hcifBuf, hD1Buf);

    BufferGfx_setColorSpace(hcifBuf,ColorSpace_YUV420PSEMI);

    BufferGfx_setColorSpace(hD1Buf,ColorSpace_YUV420PSEMI);

    .........................................................................................................................................................

    It can work perfect.

  • Hi weidong,

    Thank you!  dm365_imp.oper_mode=1 makes this app to output the message with a wrong output image in the attachment.

    Actually, I work on a RTOS instead of Linux/DVSDK. What I concern is the the right combination of dozens of registers.

    I very likely make a lot of mistakes starting from the above code slices.

    Could you please provide more complete source code ?    Does your code rely on Anshuman's patch ?

    out.zip
  • No,I use original DVSDK resize.c NOT patch above.

    I sure that it can work.

  • Hi weidong,

    Attached code follows your hint and DMAI guide but doesn't work.
    ============================================================================
    root@168:/opt/dvsdk/dm365# ./rsz_420_420 yuv420sp_D1.yuv 720 480 t.yuv 360 240
    BufI.dim (x,y,w,h,l) = 0,0,720,480,736
    BufI.ColorSpace=0
    davinci_resizer davinci_resizer.2: RSZ_G_CONFIG:1:0:176
    davinci_resizer davinci_resizer.2: rsz_validate_out_pix_formatspix format not supported, 9
    davinci_resizer davinci_resizer.2: set resizer config failed
    BufO.dim (x,y,w,h,l) = 0,0,360,240,384
    BufO.ColorSpace=0
    @0x000af367:[T:0x4001ed40] ti.sdo.dmai - [Resize] Error in setting default configuration for single shot mode
    Failed to configure resize job
    ============================================================================

    In my point, apparently it is not supported since:
    In Resize.c,
    static enum ipipe_pix_formats pixFormatConversion(ColorSpace_Type cs)
    {
        switch(cs) {
            case ColorSpace_YUV420PSEMI:
                return IPIPE_YUV420SP;
        ...
    }
    And in dm365_ipipe.c,
    static inline int rsz_validate_input_image_format(struct device *dev, enum ipipe_pix_formats pix, int width, int height, int *line_len)
    {
     int temp;
     if (pix != IPIPE_UYVY && pix != IPIPE_420SP_Y && pix != IPIPE_420SP_C) {
      dev_err(dev, "rsz_validate_out_pix_formats" "pix format not supported, %d\n", pix);
      return -EINVAL;
     }
     ...
    }

    appMain.c.zip
  • Hi, Yulin,

    Some days ago ,I meet some error the same with you. You should do something as bleow:

    The log "davinci_resizer davinci_resizer.2: rsz_validate_out_pix_formatspix format not supported, 9" created as your bootargs is not correct.

     Set your bootargs "dm365_imp.oper_mode=1" in Uboot.

    Moreover, transfer your colorspace into UYVY which is sport by resize.c in Dmai before your Resize_config fucntion is called.

    BufferGfx_setColorSpace(hcifBuf,ColorSpace_UYVY);

     BufferGfx_setColorSpace(hD1Buf,ColorSpace_UYVY);

    Then you can do the Resize_execute normally.

    After resize_execute ,you should transfer your ColorSpace to Original one.

    That is all.

    If you need more help,pls feel free to send your info to me.

     

    Regards,

    Weidong.Shi

     

     

  • Hi weidong,

    Thank you!
    bootarg is setenv bootargs mem=76M console=ttyS0,115200n8 ip=192.168.15.228:192.168.15.254:255.255.255.0:192.168.15.11:168.95.1.1::off root=/dev/nfs nfsroot=192.168.15.27:/home/yulin/nfs video=davincifb:vid0=OFF:vid1=OFF:osd0=720x576x16,4050K dm365_imp.oper_mode=1 davinci_capture.device_type=4 davinci_enc_mngr.ch0_mode=ntsc

    I am not sure if the attached code follow your idea totally.
    No error/warning message but the output (out.yuv) is wrong.

    rsz_420_420.zip
  • You can contact me via swd5956052@163.com

     

  • Thanks to all of you !!

     

    it just work greatly as long as you don't use DVSDK 3.10.0016 that has bugs

    I patched LSP and DVSDK with given files and used the trick given above.

     

    for sure it works with YUV420 plannar.. I am now verifying that it works also with YUV 420 Semi Plannar format. :)

  • 8182.input_output.rarHi,Anshuman

    I download the YUV420_420_Resize.zip ,copy it to the /drivers/char,recompile the kernel.

    The program do_resize_420_420 ran successfully,and I got the output YUV data.But the output seems wrong.(./do_resize_420_420 -i input.yuv -o out.yuv)

    Here is my input file and output file.

    And here is my bootargs :

    mem=80M console=ttyS0,115200n8 noinitrd rw ip=192.168.245.111:255.255.255.0:192.168.245.1 root=/dev/nfs nfsroot=192.168.245.137:/opt/nfs dm365_imp.oper_mode=1 davinci_capture.device_type=4

     

    Is anything I didn't notice?Please give me some advise.

    Thank you```

    Xiang

  • Hi,

    What is the resolution of the YUV input and output data?

    Regards,

    Anshuman

  • Hi,

    My input YUV data resolution is 1280 * 720 ,output resolution is 640 * 360.

    I saw through the source code.It requires the resolution,so I set the resolution as above.

    And I have another problem,I want to resize the 420sp YUV data from 1280*720 to 720*240 ,can resizer do it?

    Xiang

  • hi,Anshuman

            I encountered a more simple question.That is,when I tried the resize  founctions of Dmai  on dm365, the Resize_create() return NULL.

    The debug output is

     @0x000841a8:[T:0x411af490] ti.sdo.dmai - [Resize] Resizer can't set operation mode.

           here is my code:

           Resize_Handle          hResize = NULL;
           Resize_Attrs               rszAttrs = Resize_Attrs_DEFAULT;

              hResize =  Resize_create (&rszAttrs);
            if (hResize == NULL) {
               printf("Failed to create resize job\n");
               goto cleanup;
           }

    It is simple,but it doesn't work.

    this is my bootarg:

    setenv bootargs mem=80M console=ttyS0,115200n8 noinitrd rw ip=59.64.141.99:59.64.141.13:255.255.255.0 root=/dev/nfs nfsroot=59.64.141.13:/usr/local/nfs davinci_enc_mngr.ch0_output=TV davinci_capture.device_type=4 dm365_imp.oper_mode=0

    when I set the dm365_imp.oper_mode=1 ,besides the resizer doesnt work,so does the capture device. The debug outPut is

    @0x00172a32:[T:0x42de3490] ti.sdo.dmai - [Resize] Cannot open resize device
    @0x00172b09:[T:0x42de3490] ti.sdo.dmai - [Capture] Unable to configure Resizer
    Error: Failed to create capture device

    How to make the resize object be created successfully?

  • Hi,

    ID Jia said:

    this is my bootarg:

    setenv bootargs mem=80M console=ttyS0,115200n8 noinitrd rw ip=59.64.141.99:59.64.141.13:255.255.255.0 root=/dev/nfs nfsroot=59.64.141.13:/usr/local/nfs davinci_enc_mngr.ch0_output=TV davinci_capture.device_type=4 dm365_imp.oper_mode=0

    You have set the oper_mode to 0 in the bootargs. This means the resizer is configured in the continuous mode in the kernel.

    When you try to create the resizer driver using RESIZE_create(), it wont allow as the capture driver would have already created the resizer driver.

    ID Jia said:

    when I set the dm365_imp.oper_mode=1 ,besides the resizer doesnt work,so does the capture device. The debug outPut is

    @0x00172a32:[T:0x42de3490] ti.sdo.dmai - [Resize] Cannot open resize device
    @0x00172b09:[T:0x42de3490] ti.sdo.dmai - [Capture] Unable to configure Resizer
    Error: Failed to create capture device

    After changing bootargs for oper_mode=1, did you change the attributes input to the capture? There is a ontheFly variable in attributes which is by default set to 1.

    Regards,

    Anshuman

    PS: Please mark this post as verified, if you think it has answered your question. Thanks.

     

  • hi,Anshuman

         Thank you for your reply! I will try next week. I did not find the "verify"  button in your reply message  or in the Ti Forum,how to make this post as verified? Excuse me,I am a novice.

  • I have encountered the same problem and solved it after using dm365_imp.oper_mode=1

     

    Anshuman Saxena said:

    Hi,

    this is my bootarg:

    setenv bootargs mem=80M console=ttyS0,115200n8 noinitrd rw ip=59.64.141.99:59.64.141.13:255.255.255.0 root=/dev/nfs nfsroot=59.64.141.13:/usr/local/nfs davinci_enc_mngr.ch0_output=TV davinci_capture.device_type=4 dm365_imp.oper_mode=0

     

    You have set the oper_mode to 0 in the bootargs. This means the resizer is configured in the continuous mode in the kernel.

    When you try to create the resizer driver using RESIZE_create(), it wont allow as the capture driver would have already created the resizer driver.

    ID Jia said:

    when I set the dm365_imp.oper_mode=1 ,besides the resizer doesnt work,so does the capture device. The debug outPut is

    @0x00172a32:[T:0x42de3490] ti.sdo.dmai - [Resize] Cannot open resize device
    @0x00172b09:[T:0x42de3490] ti.sdo.dmai - [Capture] Unable to configure Resizer
    Error: Failed to create capture device

     

    After changing bootargs for oper_mode=1, did you change the attributes input to the capture? There is a ontheFly variable in attributes which is by default set to 1.

    Regards,

    Anshuman

    PS: Please mark this post as verified, if you think it has answered your question. Thanks.

     

    [/quote]

  • Hi, Anshuman

    using your code , I can resize an 720P YUV420SP image to 640x360,

    but can not resize a image 720x480 to 1280x720. the program does not give any errors. but the result image is incorrect.

    Can you help me?

    Thanks.

    Xiaoguang

  • How incorrect is your output image? Can you provide a snapshot?

  • hi, Nagabhushana

    we are facing the same problem as incorrect image. it's just incorrect resolution, looks like it doesnot process the resize function.

    we've done many tests use dm365 resize, such as d1, vga, cif, qvga, qcif   to 800x480, all is ok except qcif failed with timeout error.

    if we change m=10, n=240 as we have done on the other resolutions , the timeout error gone.but the dist yuv is not ok.

    we'd like to ask for advices.

    thanks.

    regards, Mike

  • Hi,Weidong,

        Recently I have a problem about DM365 Resizer.The function  capture_create has called Resize_continous_config in which  the user_mode  has been set  to  IMP_MODE_CONTINUOUS.Now I want to use Resizer functions to convert the resolution of the picture from the capture_get  to another resolution, but Resize_config is to  set the user_mode to IMP_MODE_SINGLE_SHOT.So here is the problem that if I set my bootargs dm365_imp.oper_mode=1,the capture_create function goes wrong,but if the bootargs dm365_imp.oper_mode=0,in my Resize_config function the ioctl(hResize->fd, RSZ_S_CONFIG, &rsz_chan_config) will go wrong.

        it is very grateful if you can give me some suggestions about my problems.

        Thank you very much.

  •     Hi, Weidong,

        I have a problem that if i set the bootargs dm365_imp.oper_mode=1 in uboot,my capture_create function will go wrong ,I wonder if you ever have the problems i have?

        Thank you very much.

         Regards,

        Wen Zhang