AnsweredAssumed Answered

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

Question asked by yong tang on Sep 7, 2015
Latest reply on Sep 9, 2015 by igorpadykov

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;

  }

Outcomes