ktb92677
Posts: 2
Joined: Fri Sep 20, 2013 10:29 pm

Remove Video scheduler and Clock elements from hello_pi/hello_video/video.c to improve latency

Mon Apr 01, 2019 10:59 pm

I am writing a h264 stream application involving the raspberry PI as the decoder. I noticed that on 60fps the device had significant decoding latency with just the default code available at hello_pi/hello_video/video.c. I read here: viewtopic.php?t=41584 and here viewtopic.php?f=67&t=235825 that one way to improve latency was to remove the video scheduler and clock components from the code. I did my best to try and remove these elements but I cannot get past this error: "assertion failure:ilclient.c:554:ilclient_disable_tunnel():error == OMX_ErrorNone".

Here's my code:

Code: Select all

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);
  }
Any help would be greatly appreciated!

6by9
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 6876
Joined: Wed Dec 04, 2013 11:27 am
Location: ZZ9 Plural Z Alpha, aka just outside Cambridge.

Re: Remove Video scheduler and Clock elements from hello_pi/hello_video/video.c to improve latency

Tue Apr 02, 2019 9:53 am

Please don't duplicate between github and here, otherwise you just waste our time.
https://github.com/raspberrypi/firmware/issues/1127

As per response there
Your code appears to be a significant change from hello_video as things like the function names have changed. Sorry, I'm not going to debug your code.
I've made the required changes to hello_video and pushed them to https://github.com/6by9/userland/tree/fw1127 as a quick hack.
Software Engineer at Raspberry Pi Trading. Views expressed are still personal views.
I'm not interested in doing contracts for bespoke functionality - please don't ask.

dom
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 5267
Joined: Wed Aug 17, 2011 7:41 pm
Location: Cambridge

Re: Remove Video scheduler and Clock elements from hello_pi/hello_video/video.c to improve latency

Tue Apr 02, 2019 2:33 pm


Return to “OpenMAX”