Rotation is not working for YUV422 data.

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 

Rotation is not working for YUV422 data.

2,623 次查看
johnturnur
Contributor III

Hello All,

 

I need to rotate YUV422 data..I have applied rotation using Following code. My input image size is 1024*768 and it is non interleaved YUV 422 data.

I am applying rotation on this buffer. I am not getting correct output...IPU gives output with corruption. I am attaching both input and output YUV422 images for reference.

 

Please help me to get the correct if there are any mistake i made in DMA channel setup.

 

Following i s the code snap i am using for rotation...I am using Platform SDK as reference code and all my code for IPU driver is based on Platform SDK V1.1.0

 

Thanks

John.

=================================================================================================================

    

        // PP task.

         rot_chnl_in = MEM_TO_IC_PP_ROT_CH47;

         rot_chnl_out = IC_PP_ROT_TO_MEM_CH50

 

 

memset(&rot_info, 0x00, sizeof(ipu_rot_info_t));

                 rot_info.width_in = panel->width;

                 rot_info.height_in = panel->height;

                 rot_info.width_out = rot_info.height_in;

                 rot_info.height_out = rot_info.width_in;

                 rot_info.strideline_in = rot_info.width_in * 2;

                 rot_info.strideline_out = rot_info.width_out * 2;

                 rot_info.pixel_format_in = NON_INTERLEAVED_YUV422;

                 rot_info.pixel_format_out = NON_INTERLEAVED_YUV422;

                 rot_info.rot = 1;

                 rot_info.hf = 0;

                 rot_info.vf = 0;

                 rot_info.addr0_in =rot_in_mem;

                 rot_info.addr0_out = rot_out_mem;

 

                 ipu_rotate_idmac_config(ipu_index, rot_chnl_in, rot_chnl_out, rot_info);

                ipu_ic_rotation_config(ipu_index, taskType, 1, 0, 0);    

    

                 //enable ic task

                 ipu_ic_task_enable(ipu_index, taskType, IC_PP, 1);

                 ipu_ic_task_enable(ipu_index, taskType, IC_ROT, 1);

                 ipu_ic_enable(ipu_index, 1, 1);

 

 

                 //enable rotate idma channel

                 ipu_channel_buf_ready(ipu_index, rot_chnl_out, 0);

                 ipu_channel_buf_ready(ipu_index, rot_chnl_in, 0);

                 while (ipu_idmac_channel_busy(1, rot_chnl_in)) ;

                 while (ipu_idmac_channel_busy(1, rot_chnl_out))

Original Attachment has been moved to: input.yuv.zip

Original Attachment has been moved to: output.yuv.zip

0 项奖励
13 回复数

1,459 次查看
juangutierrez
NXP Employee
NXP Employee

The trick is to set the U offset. Since the image is planar (non_interleaved) we can see it as three separate buffers: Y buffer, U buffer and V buffer. However, we need to indicate how far (the offset) the U buffer and Y buffer  are from the Y buffer. Actually set the u offset is enough.

Check the next config I used to perform first re-sizing and then rotation

                memset(&res_info, 0x00, sizeof(ipu_res_info_t));

                res_info.width_in = panel->width;

                res_info.height_in = panel->height;

                res_info.height_out = panel->width;

                res_info.width_out = panel->height;

                res_info.strideline_in = res_info.width_in;

                res_info.strideline_out = res_info.width_out;

                res_info.pixel_format_in = NON_INTERLEAVED_YUV422; // INTERLEAVED_RGB565;

                res_info.pixel_format_out = NON_INTERLEAVED_YUV422; // INTERLEAVED_RGB565;                                                                                     

                res_info.addr0_in = res_in_mem;

                res_info.addr0_out = res_out_mem;

                res_info.u_offset_in = 0xc0000;   // hardcoded for a 1024 x 768 image

                res_info.u_offset_out = 0xc0000;                                                                                                                               

                ipu_resize_idmac_config(ipu_index, res_chnl_in, res_chnl_out, res_info);                                                                                       

                //set rotate idma            

                memset(&rot_info, 0x00, sizeof(ipu_rot_info_t));

                rot_info.width_in = panel->height;

                rot_info.height_in = panel->width;

                rot_info.width_out = panel->width;

                rot_info.height_out = panel->height;

                rot_info.strideline_in = rot_info.width_in;

                rot_info.strideline_out = rot_info.width_out;

                rot_info.pixel_format_in = NON_INTERLEAVED_YUV422; //INTERLEAVED_RGB565;

                rot_info.pixel_format_out = NON_INTERLEAVED_YUV422; //INTERLEAVED_RGB565;                                                                                      

                rot_info.rot = 1;            

                rot_info.hf = 0;             

                rot_info.vf = 0;             

                rot_info.addr0_in = res_out_mem;

                rot_info.addr0_out = rot_out_mem;

                rot_info.ubo_in = 0xc0000;   

                rot_info.ubo_out = 0xc0000;

                ipu_rotate_idmac_config(ipu_index, rot_chnl_in, rot_chnl_out, rot_info);

0 项奖励

1,459 次查看
weidong_sun
NXP TechSupport
NXP TechSupport

Hello,John,

      Hope this message could help you ! I have tested it !  See following :

OV5640-MIRROR.png

Regards,

Weidong

0 项奖励

1,459 次查看
letan
Contributor III

Hello Weidong,

Could you please tell me how we can rotate 180?

I did as below but it doesn't work

{0x3820, 0x47, 0, 0}, {0x3821, 0x01, 0, 0}, {0x3814, 0x31, 0, 0},

Thanks,

Tan

0 项奖励

1,459 次查看
john_ortega
Contributor I

hi weidong,

i think this is not the one i need since i need to rotate the video (by 90 degrees) and not flip or mirror.

thanks,

john

0 项奖励

1,459 次查看
rogerio_silva
NXP Employee
NXP Employee

If you want to try on Linux, you can execute the overlay unit test:

root@freescale /unit_tests$ ./mxc_v4l2_overlay.out -r 4

The -r parameter makes the camera rotate according to the rotate mode number. I have just tried and it works.

Rgds

Rogerio

0 项奖励

1,459 次查看
john_ortega
Contributor I

hi rogerio,

can you give the link on where to download this unit test?

thanks,

john

0 项奖励

1,459 次查看
rogerio_silva
NXP Employee
NXP Employee

Hi John,

The unit tests comes with the BSP (LTIB or YOCTO). The binaries are located at rootfs/unit_tests and the source code you can get with the LTIB command:

./ltib -p imx-test -m prep

the source will be located at <ltib folder>/rpm/BUILD/imx-test-<version>

I don't know how to extract the source using YOCTO, but it should be something like this: bitbake imx-test

Rgds

Rogerio

0 项奖励

1,459 次查看
rogerio_silva
NXP Employee
NXP Employee

Hi John,

The IPU driver set DMA channel setup. Is it possible for you to use the ready driver? Or it has any constraint for your use case? 

Rgds

Rogerio

1,459 次查看
johnturnur
Contributor III

HI Rogerio

Thanks for your reply. Are you referring to which ready driver? Are you referring to V4l2 driver? Actually  we are building system around Platform SDK and that's why we are using IPU source code from SDK.

Can you guide me on the line of platform SDK IPU source code? can we rotate YUV422 data using above mentioned code?

Thanks again....

John.

0 项奖励

1,459 次查看
rogerio_silva
NXP Employee
NXP Employee

Hi John,

I'm so sorry for my lack of attention. I thought you were using Linux.

I'm focused on Linux. Maybe someone else can help on this thread.

Rgds,

Rogerio

0 项奖励

1,459 次查看
john_ortega
Contributor I

hi rogerio,

appreciate if you could advice on how to rotate a video recorded by ov5640_mipi camera sensor on the Linux driver or camera hal layer?

my h/w platform is imx6q-based custom board with freescale r13.4.1 BSP.

Thanks!


0 项奖励

1,459 次查看
rogerio_silva
NXP Employee
NXP Employee

Hi john_ortega,

What rotation do you need? 90? 180? Flip? all of them?

I'm asking because if you only need flip, it´s possible to do simply changing the IDMAC config and I guess even the current framebuffer driver supports it, if you need other rotations, you will need to involve Image Converter block to do it.

Rgds

Rogerio

0 项奖励

1,459 次查看
john_ortega
Contributor I

hi rogerio,

I need to rotate 90 degrees. can you  please give sample code or a guide on how to implement it using image converter block?

thanks,

john

0 项奖励