Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[omx][Regression] Fw versions after 911147a3276beee fail to encode h264 when input buffers are configured before port is enabled #1051

Closed
drott opened this issue Oct 2, 2018 · 10 comments

Comments

@drott
Copy link

drott commented Oct 2, 2018

The discussion in gst-omx bug 785967 shows that in firmware versions at least after 911147a3276beee gst-omx fails when input buffers are configured before the OMX encoder port is enabled.

This used to work in older firmware versions, unfortunately, we do not have an exact firmware hash for which it worked.

CC @thiblahute

@popcornmix
Copy link
Contributor

Ping @6by9

@6by9
Copy link

6by9 commented Oct 2, 2018

Will investigate.
I think I may now apply extra sanity checking on the port definition than before which may be tripping it up. OMX is a right pain as to exactly which fields need validating vs the component dictating the value.

@6by9
Copy link

6by9 commented Oct 2, 2018

For info, rpi-update hashes:

  • 5315c7a was the last release before I started tweaking video_encode
  • ec9d84e required the stride being a multiple of 32.
  • 911147a drops back to the software path if the stride is only a multiple of 16.

@drott
Copy link
Author

drott commented Oct 2, 2018

For info, rpi-update hashes:

  • 5315c7a was the last release before I started tweaking video_encode

Thanks for listing those. I can confirm that the same gst-omx tip of tree version works for encoding h264 with 5315c7a2f806c123e9e4ee26980f0019c43b9f69.

@6by9
Copy link

6by9 commented Oct 2, 2018

OK, as expected it's the stride and sliceheight parameters.
Using gst-launch-1.0 videotestsrc ! omxh264enc ! fakesink -v it's setting the port definition to

nFrameWidth = 320 (0x140)
nFrameHeight = 240 (0xf0)
nStride = 160 (0xa0)
nSliceHeight = 64 (0x40)

which the component is sanity checking and rejecting.
It looks like gst-omx has taken the default of 160x64 nStride 160, nSliceHeight 64 and updated only nFrame[Width|Height].

The old code always ignored the user supplied nSliceHeight and set it as nFrameHeight aligned up to 16., and set the pitch to the required value if nStride was less than the minimum required.
Having integrated the ISP for the format conversion I was expecting sane values to always be passed in, and also allowing the user to set their own strides/sliceheights should they wish for extra padding. I'll amend it to take the old behaviour when below the minimum required.

popcornmix added a commit that referenced this issue Oct 9, 2018
2ndstage: Increase eth_open timeout to 5 seconds
See: #1041

firmware: video_encode: Use default values on invalid nStride or nSliceHeight
See: #1051

firmware: gpioman/FXL6408: Handle open failing sensibly
See: #1053

firmware: Delay backlight coming on
See: #1052

firmware: LCD driver close fixes

2ndstage: ignore autoboot.txt if boot partition is already set
See: raspberrypi/noobs#508
popcornmix added a commit to Hexxeh/rpi-firmware that referenced this issue Oct 9, 2018
2ndstage: Increase eth_open timeout to 5 seconds
See: raspberrypi/firmware#1041

firmware: video_encode: Use default values on invalid nStride or nSliceHeight
See: raspberrypi/firmware#1051

firmware: gpioman/FXL6408: Handle open failing sensibly
See: raspberrypi/firmware#1053

firmware: Delay backlight coming on
See: raspberrypi/firmware#1052

firmware: LCD driver close fixes

2ndstage: ignore autoboot.txt if boot partition is already set
See: raspberrypi/noobs#508
@popcornmix
Copy link
Contributor

Fix should be in latest rpi-update firmware.

@ndufresne
Copy link

@6by9 thanks for investigating this. We will also check the provided stride on our side as we where expecting to pass a valid default stride (not half the width at least). We even have code to align from port definition requirement. For Tizonia and Xilinx stack, we have a partial OMX 1.2 draft dynamic buffer implemented for buffer management, so code path is totally different.

@6by9
Copy link

6by9 commented Oct 9, 2018

No problems @ndufresne. Sorry the issue crept in.

It's yet another of those awkward things in IL that the spec says that nStride gets validated on state change, so then you get yet another random reason for a state change failure with no obvious reason.
And as for nSliceHeight being read only and set by the component, it almost makes you wonder why they bothered in the first place. Why worry about a low memory footprint sliced mode if you can't control when it's used?

I think I tripped over the same thing when trying something else. IIRC there are two places in the code that called SetParameter for the PortDefinition. One updated nStride and nSliceHeight to sensible values before setting (gst_omx_video_enc_configure_input_buffer), the other didn't (gst_omx_video_enc_set_format). I'd initially put that down as something quirky in gst-omx instead of me having changed the behaviour :-(

We are almost at the position of merging a V4L2 M2M driver for video encode and decode so that may reduce the requirement for gst-omx. It's working fairly nicely with the GStreamer components, and supports optimisations such as dmabufs for zero copy.
If I can drop support for OpenMax then I will be one very happy chap!

@ndufresne
Copy link

We are almost at the position of merging a V4L2 M2M driver for video encode and decode so that may reduce the requirement for gst-omx. It's working fairly nicely with the GStreamer components, and supports optimisations such as dmabufs for zero copy.
If I can drop support for OpenMax then I will be one very happy chap!

That's is a really good news!

@drott
Copy link
Author

drott commented Oct 10, 2018

Fix should be in latest rpi-update firmware.

I can confirm that the original issue is fixed and running a basic pipeline with omxh264enc works after updating to e0a0ba809ef11f6bed8a00d34dda961239ea432c using rpi-update. Thanks!

@drott drott closed this as completed Oct 10, 2018
pepijndevos pushed a commit to pepijndevos/meta-raspberrypi that referenced this issue Dec 13, 2018
pepijndevos pushed a commit to pepijndevos/meta-raspberrypi that referenced this issue Dec 15, 2018
This fixes raspberrypi/firmware#1051

Signed-off-by: Pepijn de Vos <pepijndevos@gmail.com>
agherzan pushed a commit to agherzan/meta-raspberrypi that referenced this issue Dec 15, 2018
This fixes raspberrypi/firmware#1051

Signed-off-by: Pepijn de Vos <pepijndevos@gmail.com>
agherzan pushed a commit to agherzan/meta-raspberrypi that referenced this issue Feb 19, 2019
This fixes raspberrypi/firmware#1051

Signed-off-by: Pepijn de Vos <pepijndevos@gmail.com>
agherzan pushed a commit to agherzan/meta-raspberrypi that referenced this issue Feb 19, 2019
This fixes raspberrypi/firmware#1051

Signed-off-by: Pepijn de Vos <pepijndevos@gmail.com>
daregit pushed a commit to daregit/yocto-combined that referenced this issue May 22, 2024
This fixes raspberrypi/firmware#1051

Signed-off-by: Pepijn de Vos <pepijndevos@gmail.com>
daregit pushed a commit to daregit/yocto-combined that referenced this issue May 22, 2024
This fixes raspberrypi/firmware#1051

Signed-off-by: Pepijn de Vos <pepijndevos@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants