Firefly开源社区

12
发表新贴
打印 上一主题 下一主题

[应用开发] ffmedia开发库中demo程序实现多窗口(叠加)出现闪烁,请问是什么原因

69

积分

0

威望

0

贡献

技术小白

积分
69

ffmedia开发库中demo程序实现多窗口(叠加)出现闪烁,请问是什么原因

发表于 2023-9-5 21:17:56      浏览:2087 | 回复:16        打印      只看该作者   [复制链接] 楼主
问题描述及复现步骤:
开发板:ROC-RK3568-PC
操作系统:官方Ubuntu20.04
ffmedia库版本:V2.1.2
ffmedia下载地址:https://gitlab.com/firefly-linux/ffmedia_release

应用程序:基于ffmedia代码/demo/demo_multi_window.cpp 修改实现两个window显示

关键代码:
rtsp_c = make_shared<ModuleRtspClient>("rtsp://192.168.110.140:5544/live/0");
    ret = rtsp_c->init();
    if (ret < 0) {
        ff_error("rtsp client init failed\n");
        return ret;
    }

    // 2. dec module
    input_para = rtsp_c->getOutputImagePara();
    dec = make_shared<ModuleMppDec>(input_para);
    dec->setProductor(rtsp_c);
    ret = dec->init();
    if (ret < 0) {
        ff_error("Dec init failed\n");
        return ret;
    }

    // 3. drm display module
    input_para = dec->getOutputImagePara();

    shared_ptr<DrmDisplayPlane> plane = make_shared<DrmDisplayPlane>(V4L2_PIX_FMT_NV12, 0);
    //plane->setRect(100, 100, 1600, 800);
    plane->setRect(0, 0, 1920, 1080);
    // plane->setWindowLayoutMode(DrmDisplayPlane::RELATIVE_LAYOUT);
    plane->setWindowLayoutMode(DrmDisplayPlane::ABSOLUTE_LAYOUT);
    //plane->splitPlane(3, 3);

    // for (int i = 0; i < 16; i++) {
    for (int i = 0; i < 2; i++) {
        windows[i] = make_shared<ModuleDrmDisplay>(input_para, plane);
        windows[i]->setProductor(dec);
        windows[i]->init();
    }

    windows[0]->setWindowRect(0, 0, 1920, 1080);
    windows[0]->setWindowVisibility(true);

    windows[1]->setWindowRect(100, 100, 960, 540);
    windows[1]->setWindowVisibility(true);



运行效果:




问题描述:
运行后叠加的画面会出现闪烁,麻烦大佬帮忙分析下原因,非常感谢!

log.zip

643 Bytes, 下载次数: 0, 下载积分: 灯泡 -1 , 经验 -1

回复

使用道具 举报

818

积分

0

威望

0

贡献

技术大神

Rank: 3Rank: 3

积分
818
发表于 2023-9-6 11:08:23        只看该作者  沙发
设置drm模块的z轴值(void setPlanePara(uint32_t fmt, uint32_t plane_zpos);),可参看demo.cpp或demo_multi_drmplane.cpp设置,谁要显示在前面谁的zpos就大,相同的zpos会相互覆盖显示区域,所以看起来就一闪一闪的
回复

使用道具 举报

69

积分

0

威望

0

贡献

技术小白

积分
69
发表于 2023-9-6 22:44:09        只看该作者  板凳
dengkx 发表于 2023-9-6 11:08
设置drm模块的z轴值(void setPlanePara(uint32_t fmt, uint32_t plane_zpos);),可参看demo.cpp或demo_multi ...

大佬,按照以上方法测试还是存在闪烁问题,麻烦再帮忙看下是什么原因

代码1:可运行,但图像闪烁
  1.    /////程序1
  2.        
  3.         input_para = dec->getOutputImagePara();

  4.     shared_ptr<DrmDisplayPlane> plane = make_shared<DrmDisplayPlane>();
  5.     shared_ptr<DrmDisplayPlane> plane2 =make_shared<DrmDisplayPlane>();

  6.     windows[0] = make_shared<ModuleDrmDisplay>(input_para, plane);
  7.     windows[0]->setPlanePara(V4L2_PIX_FMT_NV12, 0xff);
  8.     windows[0]->setPlaneRect(0, 0, 1200, 800);
  9.     windows[0]->setProductor(dec);
  10.     windows[0]->init();

  11.     windows[1] = make_shared<ModuleDrmDisplay>(input_para, plane2);
  12.     windows[1]->setPlanePara(V4L2_PIX_FMT_NV12, 0xf0);
  13.     windows[1]->setPlaneRect(0, 0, 1920, 1080);
  14.     windows[1]->setProductor(dec);
  15.     windows[1]->init();

  16.     windows[0]->setWindowRect(0, 0, 960, 540);
  17.     windows[0]->setWindowVisibility(true);

  18.     windows[1]->setWindowRect(0, 0, 1920, 1080);
  19.     windows[1]->setWindowVisibility(true);

  20.        
复制代码


代码2:运行报错
错误信息:
  1. root@firefly:/home/firefly/code/ffmedia_release/build# ./demo_multi_window
  2. Firefly FFMedia: v2.1.2
  3. INFO: ff_media: connectToServer: connected to server 192.168.110.140:5544
  4. INFO: ff_media: RTPSource: RTPSock current buffer size is(425984)
  5. INFO: 16ModuleRtspClient: init: rtsp para w h: 1920 1080, ws hs: 1920 1080, format: H265
  6. INFO: 15DrmDisplayPlane: setupDisplayDevice: 0 0
  7. INFO: 15DrmDisplayPlane: setupDisplayDevice: conn_id = 149 enc_id = 150 crtc_id = 71
  8. INFO: 15DrmDisplayPlane: setup: plane_id = 101
  9. INFO: 15DrmDisplayPlane: setup: plane_id = -1
  10. ERROR: 15DrmDisplayPlane: setup: drmModeSetPlane failed, ret -2
  11. rga_api version 1.3.0_[0] (RGA is compiling with meson base: $PRODUCT_BASE)
  12. INFO: 16ModuleDrmDisplay: setupWindow: input NV12 0 0 1920 1080 2304 1088
  13. INFO: 16ModuleDrmDisplay: setupWindow: INFO: 16ModuleDrmDisplay: setupWindow: input NV12 0 0 1920 1080 2304 1088
  14. INFO: 16ModuleDrmDisplay: setupWindow: output Unknow V4L2 Format 0 0 1920 1080 1920 1080
  15. output NV12 0 0 960 540 1920 1080
  16. INFO: 10MppDecoder: getTimeoutSample: 0x555e1de040 frame info changed 1 error 0 discard 0
  17. Segmentation fault
复制代码
  1. /////程序2
  2.         input_para = dec->getOutputImagePara();

  3.     shared_ptr<DrmDisplayPlane> plane = make_shared<DrmDisplayPlane>();

  4.     windows[0] = make_shared<ModuleDrmDisplay>(input_para, plane);
  5.     windows[0]->setPlanePara(V4L2_PIX_FMT_NV12, 0xff);
  6.     windows[0]->setPlaneRect(0, 0, 1200, 800);
  7.     windows[0]->setProductor(dec);
  8.     windows[0]->init();

  9.     windows[1] = make_shared<ModuleDrmDisplay>(input_para, plane);
  10.     windows[1]->setPlanePara(V4L2_PIX_FMT_NV12, 0xf0);
  11.     windows[1]->setPlaneRect(0, 0, 1920, 1080);
  12.     windows[1]->setProductor(dec);
  13.     windows[1]->init();

  14.     windows[0]->setWindowRect(0, 0, 960, 540);
  15.     windows[0]->setWindowVisibility(true);

  16.     windows[1]->setWindowRect(0, 0, 1920, 1080);
  17.     windows[1]->setWindowVisibility(true);
复制代码

回复

使用道具 举报

818

积分

0

威望

0

贡献

技术大神

Rank: 3Rank: 3

积分
818
发表于 2023-9-7 09:36:54        只看该作者  地板
Valerian0 发表于 2023-9-6 22:44
大佬,按照以上方法测试还是存在闪烁问题,麻烦再帮忙看下是什么原因

代码1:可运行,但图像闪烁

z轴好像是有限制的,你设置一个4,另一个设置5 看看
回复

使用道具 举报

69

积分

0

威望

0

贡献

技术小白

积分
69
发表于 2023-9-7 23:23:33        只看该作者  5#
dengkx 发表于 2023-9-7 09:36
z轴好像是有限制的,你设置一个4,另一个设置5 看看

改成4和5程序会报错,只有设置成0xff这种才行,但就是会闪烁,换了一个新版的固件也是报错,是不是哪里没有配置对?

报错信息:
  1. Firefly FFMedia: v2.1.2
  2. INFO: ff_media: connectToServer: connected to server 192.168.110.140:5544
  3. INFO: ff_media: RTPSource: RTPSock current buffer size is(425984)
  4. INFO: 16ModuleRtspClient: init: rtsp para w h: 1920 1080, ws hs: 1920 1080, format: H265
  5. INFO: 15DrmDisplayPlane: setupDisplayDevice: 0 0
  6. INFO: 15DrmDisplayPlane: setupDisplayDevice: conn_id = 149 enc_id = 150 crtc_id = 71
  7. INFO: 15DrmDisplayPlane: setup: plane_id = -1
  8. ERROR: 15DrmDisplayPlane: setup: drmModeSetPlane failed, ret -2
  9. INFO: 15DrmDisplayPlane: setupDisplayDevice: 0 0
  10. INFO: 15DrmDisplayPlane: setupDisplayDevice: conn_id = 149 enc_id = 150 crtc_id = 71
  11. INFO: 15DrmDisplayPlane: setup: plane_id = 101
  12. rga_api version 1.3.0_[0] (RGA is compiling with meson base: $PRODUCT_BASE)
  13. INFO: 16ModuleDrmDisplay: setupWindow: input NV12 0 0 1920 1080 2304 1088
  14. INFO: 16ModuleDrmDisplay: setupWindow: output Unknow V4L2 Format 0 0 960 540 1216 800
  15. INFO: 16ModuleDrmDisplay: setupWindow: input NV12 0 0 1920 1080 2304 1088
  16. INFO: 16ModuleDrmDisplay: setupWindow: output NV12 0 0 1920 1080 1920 1080
  17. INFO: 10MppDecoder: getTimeoutSample: 0x5594e6a040 frame info changed 1 error 0 discard 0
  18. Segmentation fault
复制代码
回复

使用道具 举报

818

积分

0

威望

0

贡献

技术大神

Rank: 3Rank: 3

积分
818
发表于 2023-9-8 09:12:13        只看该作者  6#
Valerian0 发表于 2023-9-7 23:23
改成4和5程序会报错,只有设置成0xff这种才行,但就是会闪烁,换了一个新版的固件也是报错,是不是哪里没 ...

用demo 的-z 选项设置看看行不行?
回复

使用道具 举报

69

积分

0

威望

0

贡献

技术小白

积分
69
发表于 2023-9-9 17:13:49        只看该作者  7#
dengkx 发表于 2023-9-8 09:12
用demo 的-z 选项设置看看行不行?

-z 值为255可以运行,跟之前代码一样,但其他值就会报错了
能运行命令:
./demo rtsp://192.168.110.140:5544/live/0 -o 1920x1080 -d 0 -z 255
报错的命令:
./demo rtsp://192.168.110.140:5544/live/0 -o 1920x1080 -d 0 -z 5
报错信息:
  1. root@firefly:/home/firefly/code/ffmedia_release/build# ./demo rtsp://192.168.110.140:5544/live/0 -o 1920x1080 -d 0 -z 5
  2. Firefly FFMedia: v2.1.2
  3. INFO: ff_media: start_instance:

  4. ==========================================
  5. INFO: ff_media: start_instance: enable rtsp client
  6. INFO: ff_media: connectToServer: connected to server 192.168.110.140:5544
  7. INFO: ff_media: RTPSource: RTPSock current buffer size is(425984)
  8. INFO: 16ModuleRtspClient: init: rtsp para w h: 1920 1080, ws hs: 1920 1080, format: H265
  9. INFO: 15DrmDisplayPlane: setupDisplayDevice: 0 0
  10. INFO: 15DrmDisplayPlane: setupDisplayDevice: conn_id = 149 enc_id = 150 crtc_id = 71
  11. INFO: 15DrmDisplayPlane: setup: plane_id = -1
  12. ERROR: 15DrmDisplayPlane: setup: drmModeSetPlane failed, ret -2
  13. ERROR: ff_media: start_instance: drm display init failed
  14. ==================Summary================
  15. ModuleRtspClient (In Full: 0, Out Empty: 0)
  16.    |--->ModuleMppDec (In Full: 0, Out Empty: 0)
  17.            |--->ModuleDrmDisplay (In Full: 0, Out Empty: 0)
复制代码
回复

使用道具 举报

818

积分

0

威望

0

贡献

技术大神

Rank: 3Rank: 3

积分
818
发表于 2023-9-12 16:27:00        只看该作者  8#
Valerian0 发表于 2023-9-9 17:13
-z 值为255可以运行,跟之前代码一样,但其他值就会报错了
能运行命令:
./demo rtsp://192.168.110.14 ...

代码先不设置。直接在外部设置图层的zpos值看看行不行:
modetest -M rockchip -aw 105:zpos:0 // <plane-id>:zpos:<zpos value>

# 图层 id 可以使用下面命令查看
root@firefly:/home/firefly# cat /sys/kernel/debug/dri/0/state  | grep plane
plane[54]: Esmart0-win0
plane[71]: Esmart1-win0
plane[88]: Esmart2-win0
plane[105]: Esmart3-win0
plane[122]: Cluster0-win0
plane[136]: Cluster1-win0
plane[150]: Cluster2-win0
plane[164]: Cluster3-win0
回复

使用道具 举报

69

积分

0

威望

0

贡献

技术小白

积分
69
发表于 2023-9-12 23:14:28        只看该作者  9#
本帖最后由 Valerian0 于 2023-9-12 23:52 编辑
dengkx 发表于 2023-9-12 16:27
代码先不设置。直接在外部设置图层的zpos值看看行不行:
modetest -M rockchip -aw 105:zpos:0 // :zpos ...

感谢大佬指点,现在可以实现图像叠加了,但有个小问题,需要传不同的plane值才能叠加,没法使用同一个plane_id不同plane_zpos值进行叠加,麻烦再帮忙分析一下,多谢!
可叠加代码(plane_id不同):


不能叠加的代码(plane_id相同):




补充信息:
  1. root@firefly:/sys/kernel/debug/dri/0# cat state | grep plane
  2. plane[57]: Smart0-win0
  3. plane[73]: Smart1-win0
  4. plane[87]: Esmart1-win0
  5. plane[101]: Esmart0-win0
  6. plane[115]: Cluster0-win0
  7. plane[129]: Cluster1-win0
  8.         planes_changed=1
  9.         plane_mask=21
复制代码
  1. root@firefly:/home/firefly/code/ffmedia_release/build# modetest -M rockchip -aw 87:zpos:0
  2. failed to set PLANE 87 property zpos to 0: Success
  3. root@firefly:/home/firefly/code/ffmedia_release/build# modetest -M rockchip -aw 87:zpos:1
  4. failed to set PLANE 87 property zpos to 1: Success
  5. root@firefly:/home/firefly/code/ffmedia_release/build# modetest -M rockchip -aw 87:zpos:5
  6. failed to set PLANE 87 property zpos to 5: Success
复制代码




回复

使用道具 举报

69

积分

0

威望

0

贡献

技术小白

积分
69
发表于 2023-9-17 19:35:58        只看该作者  10#
dengkx 发表于 2023-9-12 16:27
代码先不设置。直接在外部设置图层的zpos值看看行不行:
modetest -M rockchip -aw 105:zpos:0 // :zpos ...

大佬,麻烦看下上个回复,这个zpos是暂时不支持么?目前我们这边需要实现多个窗口叠加
回复

使用道具 举报

返回列表
12
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

友情链接 : 爱板网 电子发烧友论坛 云汉电子社区 粤ICP备14022046号-2
快速回复 返回顶部 返回列表