JeffyCN / rockchip_mirrors

Mirrors of a few Rockchip BSP repositories, some others in https://github.com/JeffyCN/mirrors.
Other
10 stars 2 forks source link

修复gst和mpp的layout不同导致rga对目标内存大小计算错误 #33

Closed zylo117 closed 1 year ago

zylo117 commented 1 year ago

假如640x480的nv12帧需要转换颜色空间到rgb,因为rga所用的是类似[640, 480, 3]的layout,而gst则认为是应该是[640x3, 480],然后gst又在这里gst_mpp_set_rga_info,把hstride: 640x3传给了rga的info。

https://github.com/JeffyCN/rockchip_mirrors/blob/b654ce25b062efebc0cb1107acd02cc811aab55a/gst/rockchipmpp/gstmpp.c#L186

rga_set_rect (&info->rect, 0, 0, width, height, hstride, vstride, rga_format);

导致rga以为目标内存有[640*3, 480, 3]那么大,也就是申请的内存的3倍大小。所以在gst中用mppvideodec转换到非nv12,nv21之外的颜色空间必然导致rga出错,比如rgb/bgr,rgba/bgra等等

修复办法就是在传给rga之前,gst把hstride除以目标颜色空间的pixel_stride,刚好gst_mpp_get_pixel_stride这个函数就是做这个的

JeffyCN commented 1 year ago

Hi, Thanks for the patch. It's a knowing issue that has been fixed in other packages that the RGA accepts pixel stride, i forgot to fix it here too.

I've uploaded the fix, the reason not using your version is: 1/ This is just a mirror repo, the patch needs to go through RK's internal gerrit 2/ There're other caller needs to be fixed 3/ We need to use English in commit message with a proper change-id and signed-off