wpt-nathan
Posts: 5
Joined: Fri Oct 24, 2014 12:27 pm

h264 SPS frame timing info loses precision

Thu Jun 07, 2018 8:47 pm

Hi All,

I'm trying to enable timing info in the h264 SPS via OMX_IndexParamBrcmVideoAVCSPSTimingEnable. The timing info is being emitted, but it is incorrect compared to what is set in xFramerate. I've set xFramerate to 59.94 ( xFramerate = ( 30000 << 16 ) / 1001 ) but the resulting timing shows a frame rate of 59fps.

Am I setting xFramerate wrong? Or is there an issue with fractional frame rates?

Thanks,
--Nate

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

Re: h264 SPS frame timing info loses precision

Fri Jun 08, 2018 9:52 am

The current code only supports encoding integer framerates - it does a >>16 on the IL xFramerate field.

I'm having to read the H264 spec to see whether it is even possible to encode non-integer framerates in the timing info fields. num_units_in_tick and time_scale are the relevant bits, but the usage isn't immediately clear.
The example "30000÷1001 frames per second with time_scale equal to 60000 and num_units_in_tick equal to 1 001 and nuit_field_based_flag equal to 1" would imply that time_scale=2*xFramerate and num_units_in_tick=65536 would encode the value correctly, but implementing that means amending APIs in various places through the firmware and therefore isn't a trivial task.
Software Engineer at Raspberry Pi Trading. Views expressed are still personal views.
Please don't send PMs asking for support - use the forum.
I'm not interested in doing contracts for bespoke functionality - please don't ask.

wpt-nathan
Posts: 5
Joined: Fri Oct 24, 2014 12:27 pm

Re: h264 SPS frame timing info loses precision

Fri Jun 08, 2018 3:12 pm

I made a mistake in my post. The calculation for xFrametrate I am setting is ( 60000 << 16 ) / 1001 for 59.94. Sorry if that may have caused confusion.

While being able to set num_units_in_tick and time_scale to 1001 and 60000 respectively would be ideal, I understand it is not practical.

An option that would be close enough would be to set num_units_in_tick to 100, and time_scale to xFramerate / 655.36 if xFramerate has a real component.

Thank you for looking into this.

--Nate

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

Re: h264 SPS frame timing info loses precision

Fri Jun 08, 2018 5:00 pm

It's that the frame rate is passed into the codec as an integer, and is then used in various places for bitrate calcs and the like, so changing that API to take a fixed point frame rate in means very careful handling to ensure doesn't mess up any other area. It's not impossible, just not a five minute job.

Could you raise an issue on https://github.com/raspberrypi/firmware/issues, linking to this thread? I'm less likely to forget it if it's logged there than buried in a forum post.
Software Engineer at Raspberry Pi Trading. Views expressed are still personal views.
Please don't send PMs asking for support - use the forum.
I'm not interested in doing contracts for bespoke functionality - please don't ask.

Return to “OpenMAX”

Who is online

Users browsing this forum: No registered users and 2 guests