Can G2D resize the image? Such as downsize an image 1920X1080 to 800X600 using the i.MX6.

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Can G2D resize the image? Such as downsize an image 1920X1080 to 800X600 using the i.MX6.

Jump to solution
2,142 Views
yongtang
Contributor I

I find G2D can rotate the image, but not find it can resize the image.

I found it can resize by IPU low level function as below,but i want some high level API to implement,such as G2D:

// Open IPU device

  fd_ipu = open("/dev/mxc_ipu", O_RDWR, 0);

  if (fd_ipu < 0) {

  printf("open ipu dev fail\n");

  ret = -1;

  goto done;

  }

  // Calculate input size from image dimensions and bits-per-pixel

  // according to format

  isize = task.input.paddr =

  task.input.width * task.input.height

  * fmt_to_bpp(task.input.format)/8;

  // Allocate contingous physical memory for input image

  // input.paddr contains the amount needed

  // this value will be replaced with physical address on success

  ret = ioctl(fd_ipu, IPU_ALLOC, &task.input.paddr);

  if (ret < 0) {

  printf("ioctl IPU_ALLOC fail: (errno = %d)\n", errno);

  goto done;

  }

  // Create memory map and obtain the allocated memory virtual address

  inbuf = mmap(0, isize, PROT_READ | PROT_WRITE,

  MAP_SHARED, fd_ipu, task.input.paddr);

  if (!inbuf) {

  printf("mmap fail\n");

  ret = -1;

  goto done;

  }

 

  // Allocate memory for output image

  osize = task.output.paddr =

  task.output.width * task.output.height

  * fmt_to_bpp(task.output.format)/8;

  ret = ioctl(fd_ipu, IPU_ALLOC, &task.output.paddr);

  if (ret < 0) {

  printf("ioctl IPU_ALLOC fail\n");

  goto done;

  }

  // Create memory map for output image

  outbuf = mmap(0, osize, PROT_READ | PROT_WRITE,

  MAP_SHARED, fd_ipu, task.output.paddr);

  if (!outbuf) {

  printf("mmap fail\n");

  ret = -1;

  goto done;

  }

  // Open output file for writing

  if ((file_out = fopen("output_file.raw", "wb")) < 0) {

  printf("Cannot open output file");

  ret = -1;

  goto done;

  }

  // Read input image

  ret = fread(inbuf, 1, isize, file_in);

  if (ret < isize) {

  ret = 0;

  printf("Cannot read enough data from input file\n");

  goto done;

  }

  gettimeofday(&begin, NULL);

  // Perform the rotation

  ret = ioctl(fd_ipu, IPU_QUEUE_TASK, &task);

  if (ret < 0) {

  printf("ioct IPU_QUEUE_TASK fail\n");

  goto done;

  }

Labels (1)
0 Kudos
1 Solution
1,136 Views
igorpadykov
NXP Employee
NXP Employee

Hi yong

one can look at sect.7.5.3 Video conversion attached Linux Guide,

check g2d_test test

https://lists.yoctoproject.org/pipermail/meta-freescale/2015-February/012610.html

JPEG hardware decode and resize in i.MX6

For resizing one can also use xrandr, described in sect.6.2 XRandR Graphics Guide.

Best regards

igor

-----------------------------------------------------------------------------------------------------------------------

Note: If this post answers your question, please click the Correct Answer button. Thank you!

-----------------------------------------------------------------------------------------------------------------------

View solution in original post

0 Kudos
3 Replies
1,137 Views
igorpadykov
NXP Employee
NXP Employee

Hi yong

one can look at sect.7.5.3 Video conversion attached Linux Guide,

check g2d_test test

https://lists.yoctoproject.org/pipermail/meta-freescale/2015-February/012610.html

JPEG hardware decode and resize in i.MX6

For resizing one can also use xrandr, described in sect.6.2 XRandR Graphics Guide.

Best regards

igor

-----------------------------------------------------------------------------------------------------------------------

Note: If this post answers your question, please click the Correct Answer button. Thank you!

-----------------------------------------------------------------------------------------------------------------------

0 Kudos
1,136 Views
yongtang
Contributor I

Hi,igor

  Thanks for your reply.With your help,I find a gstreamer plugin "imxvideoconvert_g2d" as below,but where i can get the G2D SDK?

7.5.3 Video conversion

Resize

gst-launch-1.0 videotestsrc ! video/x-raw,format=NV12,width=800,height=600 !

imxvideoconvert_ipu ! video/x-raw, width=640, height=480 ! ximagesink display=:0

0 Kudos
1,136 Views
igorpadykov
NXP Employee
NXP Employee

please look at

Snippets, Boot Code, Headers, Monitors, etc. (1)

i.MX6 Graphics SDK – Includes sample, demo code, and documentation

http://www.freescale.com/webapp/sps/site/prod_summary.jsp?code=RDIMX6SABREBRD&fpsp=1&tab=Design_Tool...

~igor

0 Kudos