AnsweredAssumed Answered

使用ipu做alpha融合的问题

Question asked by 克祥 黄 on Apr 16, 2019
Latest reply on Apr 18, 2019 by 克祥 黄

  在使用ip的动态库做alpha融合时,发现colorkey这个功能不能正常工作:

       1 .顶层图片的格式是IPU_PIX_FMT_UYVY,底层图片的格式也是IPU_PIX_FMT_RGB565 input.format   = IPU_PIX_FMT_RGB565 overlay.format   =IPU_PIX_FMT_RGB565 输出的格式也是IPU_PIX_FMT_RGB565

  1. colorkeyenable设置为1colorkey.enable=1colorkey.value=0x00

      

      按照上述配置, overlay层的RGB值为0的像素会被替换为底层的图片。 但是测试结果是RGB值为0的像素没有替换,而是半透明的。请问这个是什么原因导致的?

 

 

下面是我的部分关键代码。红色部分是alpha融合的代码。

 

int mxc_ipu_alpha_blend_main (void *arg)

{

       struct ipu_task task;

       struct timeval begin, end;

       util_List *ev7250_cameraIn_que_node, *ev7250_cameraIn_que_node_last=NULL;

       util_List *alpha_blend_out_que_node;

       util_List *ipu_resize_out_que_node,*ipu_resize_out_que_node_last=NULL;

       struct timeval tv_start, tv_current;

       int ret;

       util_IPU_buff  ipu_buff_tmp;

 

 

       if(arg) {;}

       prctl(PR_SET_NAME,"blend_main");

       fprintf( stdout,"\n\r *****mxc_ipu_alpha_blend_main task start *****\n\r"); fflush(stdout);

 

      

      

      

       // Clear &task      

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

 

       // Input image size and format

       task.input.width    =1920;

       task.input.height=1024;

       task.input.format   = IPU_PIX_FMT_RGB565;

 

       // Overlay image size and format

       task.overlay.width    = 1920;

       task.overlay.height   =1024;

       task.overlay.format   =IPU_PIX_FMT_RGB565;

       task.overlay_en = 1;

       task.overlay.alpha.mode = 0; //0 - Global alpha blending

       task.overlay.alpha.gvalue = 128;

       task.overlay.colorkey.enable=1;

       task.overlay.colorkey.value=0x00;

 

       // Output image size and format

       task.output.width   =1920;

       task.output.height  =1023;      

       task.output.format=IPU_PIX_FMT_RGB565;

 

             

 

       while (1) 

       {

 

             

              task.input.paddr=((util_IPU_buff* )ev7250_cameraIn_que_node_last->data)->paddr;

              task.overlay.paddr=((util_IPU_buff* )ipu_resize_out_que_node_last->data)->paddr;

              //task.output.paddr=ipu_buff_tmp.paddr;

              task.output.paddr=((util_IPU_buff* )alpha_blend_out_que_node->data)->paddr;

 

             

             

              module_dprintf(DEBUG_IPU_ALPHA_BLEND,4,"\n\r");

              // Perform combining 

              ret = ioctl(util_ipu_fd, IPU_CHECK_TASK, &task);

              if (ret < 0) {

                     //ret=ipu_check_task(&task);

                     err_msg("ioct IPU_CHECK_TASK fail %d %s\n", ret,strerror(errno));

                     //goto done;

              }

              else

              {

      

                     module_dprintf(DEBUG_IPU_ALPHA_BLEND,4,"\n\r");

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

                     if (ret < 0) {

                            //ret=ipu_check_task(&task);

                            err_msg("ioct IPU_QUEUE_TASK fail %d %s\n", ret,strerror(errno));

                            //goto done;

                     }

 

                    

              }

              module_dprintf(DEBUG_IPU_ALPHA_BLEND,4,"\n\r");

             

      

              module_dprintf(DEBUG_IPU_ALPHA_BLEND,4,"\n\r");

             

              gettimeofday(&tv_current, NULL);

              if(((tv_current.tv_sec*1000000+tv_current.tv_usec)-(tv_start.tv_sec*1000000+tv_start.tv_usec))<40000)

              {

                     usleep(40000-((tv_current.tv_sec*1000000+tv_current.tv_usec)-(tv_start.tv_sec*1000000+tv_start.tv_usec)));

              }

             

       }

 

done:

      

 

       return ret;

}

 

Outcomes