从hello_pi / hello_video / video.c中删除Video Scheduler和Clock元素以改善延迟

时间:2019-04-01 22:14:04

标签: c++ raspberry-pi raspberry-pi3 raspbian openmax

我正在编写一个以树莓派PI作为解码器的h264流应用程序。我注意到,在60fps的速度下,该设备具有巨大的解码延迟,仅在hello_pi / hello_video / video.c中提供了默认代码。我在这里https://www.raspberrypi.org/forums/viewtopic.php?t=41584和这里https://www.raspberrypi.org/forums/viewtopic.php?f=67&t=235825中阅读到一种改善延迟的方法是从代码中删除视频调度程序和时钟组件。我已尽力尝试删除这些元素,但无法克服以下错误:“断言失败:ilclient.c:554:ilclient_disable_tunnel():error == OMX_ErrorNone”。

decoder->port_settings_changed = 0;
  decoder->first_packet          = 1;
  decoder->Buffer = NULL;
  memset(decoder->List,    0, sizeof(decoder->List));
  memset(decoder->Tunnel,  0, sizeof(decoder->Tunnel));
  memset(&decoder->Format, 0, sizeof(OMX_VIDEO_PARAM_PORTFORMATTYPE));

  bcm_host_init();

  decoder->Display = vc_dispmanx_display_open(0); //why is this zero? who knows...

  if (vc_dispmanx_display_get_info(decoder->Display, &decoder->Info)) {
    return;
  }

  decoder->Width  = decoder->Info.width;
  decoder->Height = decoder->Info.height;

  if((decoder->Client = ilclient_init()) == NULL) {
     return;
  }
  if (OMX_Init() != OMX_ErrorNone) {
     ilclient_destroy(decoder->Client);
     return;
  }
  if(ilclient_create_component(decoder->Client, &decoder->Video_Decode, "video_decode", ILCLIENT_CREATE_FLAGS_T(ILCLIENT_DISABLE_ALL_PORTS | ILCLIENT_ENABLE_INPUT_BUFFERS)) != 0) {
    return;
  }
  decoder->List[0] = decoder->Video_Decode;

  if (ilclient_create_component(decoder->Client, &decoder->Video_Render, "video_render", ILCLIENT_DISABLE_ALL_PORTS) != 0) {
    return;
  }
  decoder->List[1] = decoder->Video_Render;

  set_tunnel(decoder->Tunnel,     decoder->Video_Decode,    131, decoder->Video_Render, 10);

  if (ilclient_setup_tunnel(decoder->Tunnel, 0, 0) != 0) {
    return;
  }
  ilclient_change_component_state(decoder->Video_Decode, OMX_StateExecuting);

  decoder->Format.nSize              = sizeof(OMX_VIDEO_PARAM_PORTFORMATTYPE);
  decoder->Format.nVersion.nVersion  = OMX_VERSION;
  decoder->Format.nPortIndex         = 130;
  decoder->Format.eCompressionFormat = OMX_VIDEO_CodingAVC;

  if (OMX_SetParameter(ILC_GET_HANDLE(decoder->Video_Decode), OMX_IndexParamVideoPortFormat, &decoder->Format) == OMX_ErrorNone &&
        ilclient_enable_port_buffers(decoder->Video_Decode, 130, NULL, NULL, NULL) == 0) {
     ilclient_change_component_state(decoder->Video_Decode, OMX_StateExecuting);
  }

任何帮助将不胜感激!

0 个答案:

没有答案