AnsweredAssumed Answered

Deinterlacing fields, resizing AND applying overlay - using the VDIC, IC etc...

Question asked by fcs on Oct 14, 2012
Latest reply on Jan 16, 2013 by Yossi Shukron
Branched to a new discussion

I am looking at sections 45.3.1.5.2 and 45.3.1.5.4 of iMX53RM.pdf, relating to the VDIC and IC.

 

Presently I have a demo app running which previews live PAL video at full screen, with an overlay, and h264 encodes this to a USB stick. It is exactly what we want but for one thing, the two PAL fields appear one above the other, squashed to half their proper height, on the screen and in the encoded video. So we need to deinterlace into a progressive stream.

 

The demo app that came with our capture card has an example of full screen live video preview but with the two fields deinterlaced.

 

I am a little concerned that the hardware may not be capable of what we want: Can we set up the VDIC to do the deinterlacing, and the IC to do resizing and combining? Ideally we would also like the IC to be able to write the result to both the display and an area in RAM (is that possible, and where is RAM is that?)

 

However at this point I am not sure what ioctl calls I should be doing to accomplish the above, I don’t have much idea how the ioctl calls relate to these hardware components. I presume it is mostly done by activating DMA channels using drivers/dma/ipu/ipu_idmac.c

 

At the moment my demo uses the gstreamer plugins with a small executable I run to set up the alpha colour key settings to combine the graphics and live video.

 

I use the following command line to get gstreamer running:

 

gst-launch-0.10 -e mfw_v4lsrc sensor-width=720 sensor-height=576 capture-width=720 capture-height=576 preview=true preview-width=1024 preview-height=768 fps-n=25 bg=true ! mfw_vpuencoder ! avimux name=mux ! filesink location=/mnt/usb1/PALfps25g.avi

Note “bg=true” is required for the overlay to work.

 

Then I run the executable to effect the overlay, essentially this is:

 

          struct mxcfb_color_key alpha;

          int parsed;

          if ( argc >= 4 && sscanf( argv[ 3 ], "%d", &parsed ) )

            {

            alpha.color_key = parsed;

            }

          else

            {

            alpha.color_key = 128;

            }

          printf( "Setting key colour to %d\n", alpha.color_key );

          alpha.enable = 1;

          if (ioctl(fd_fb, MXCFB_SET_CLR_KEY, &alpha) < 0)

          {

            fprintf( stderr, "Set alpha color key failed\n");

          }

          close(fd_fb );

 

where fd_fb is the file descriptor for /dev/fb0

 

But I am not sure what I do to get deinterlacing happening, is it something like this:

 

      memset(&fmt, 0, sizeof(fmt));

 

          fmt.type = V4L2_BUF_TYPE_VIDEO_OVERLAY;

 

      printf( "Querying buffer type %d\n", fmt.type );

 

        if (ioctl(fd_output_v4l, VIDIOC_G_FMT, &fmt) < 0)

        {

        perror( "get format failed\n");

                return -2;

        }

 

            fmt.fmt.win.w.width= width;

            fmt.fmt.win.w.height= height;

            fmt.fmt.win.field = field;

 

          printf( "Setting format %dx%d, field %d\n", fmt.fmt.win.w.width, fmt.fmt.win.w.height, fmt.fmt.win.field );

         

          if (ioctl(fd_output_v4l, VIDIOC_S_FMT, &fmt) < 0)

            {

            perror( "set format failed\n");

                return -1;

            }

           

 

The above doesn’t have any effect on live video, I am not sure if I should be during VIDIOC_STREAMOFF and VIDIOC_STREAMON before and after, but that seems to cause a hang.

Outcomes