Skip to content

add dovi_rpu_set_cmv40_default for appending CMv4.0 to CMv2.9 RPUs#393

Merged
quietvoid merged 2 commits into
quietvoid:mainfrom
pannal:cmv29-payload-end-bit
Apr 11, 2026
Merged

add dovi_rpu_set_cmv40_default for appending CMv4.0 to CMv2.9 RPUs#393
quietvoid merged 2 commits into
quietvoid:mainfrom
pannal:cmv29-payload-end-bit

Conversation

@pannal
Copy link
Copy Markdown
Contributor

@pannal pannal commented Apr 10, 2026

Rewrote this based on your feedback. Instead of exposing a raw bit offset, this adds a proper API to set CMv4.0 metadata on a parsed RPU.

New:

  • CmV40DmData::new_with_default_blocks() — creates CMv4.0 with L3 (neutral offsets), L9 (primary index 0), L11 (cinema content type), L254 (dm_version_index=2)
  • DoviRpu::set_cmv40_default_metadata() — sets the above on an RPU if cmv40_metadata is not already present
  • dovi_rpu_set_cmv40_default() C API — returns 1 if added, 0 if already present, -1 on error

On our side (Kodi/CoreELEC on Amlogic), the flow becomes: parse RPU, call this, write it back. No more bitstream surgery.

The block values are the static defaults used by Amlogic DV processors. If you think any of them should be different, or if you'd rather have a more flexible API (e.g. letting the caller pick which blocks to include), let me know.

@pannal pannal changed the title libdovi: expose cmv29_payload_end_bit in VdrDmData and C API Add cmv29_payload_end_bit to VdrDmData for bit-precise CMv4.0 insertion Apr 10, 2026
@pannal pannal changed the title Add cmv29_payload_end_bit to VdrDmData for bit-precise CMv4.0 insertion expose CMv2.9 payload end bit in VdrDmData Apr 10, 2026
@quietvoid
Copy link
Copy Markdown
Owner

I don't understand why you're excluding the alignment padding, it should be present when you append DM v2 payload.

@quietvoid
Copy link
Copy Markdown
Owner

Also, can't we just implement the insertion here instead? I would only add this temporarily..

@pannal
Copy link
Copy Markdown
Contributor Author

pannal commented Apr 10, 2026

Well, this is a direct implementation of the patch @cpm-code did, which I derived from. I just caught what you said on AVS and thought I'd PR the changes.

Let me actually review whether this makes sense.

@pannal
Copy link
Copy Markdown
Contributor Author

pannal commented Apr 10, 2026

Yeah, the alignment subtraction is wrong and doing the insertion in libdovi makes more sense. I can take a crack at implementing it if you have an idea for how the API should look, or just close this if you'd rather do it yourself.

@quietvoid
Copy link
Copy Markdown
Owner

quietvoid commented Apr 10, 2026

Up to you, we already have logic for adding CM v4.0 but I think it doesn't add all the blocks you do.

@pannal
Copy link
Copy Markdown
Contributor Author

pannal commented Apr 10, 2026

Up to you, we already have logic for adding CM v4.0 but I think it doesn't add all the blocks you do.

Right. Checking!

@quietvoid
Copy link
Copy Markdown
Owner

There isn't really much usable, I guess I can work it.

Adds CmV40DmData::new_with_default_blocks() with static L3/L9/L11/L254
extension blocks, and DoviRpu::set_cmv40_default_metadata() to set it
on an RPU that only has CMv2.9 metadata.

Exposed via C API as dovi_rpu_set_cmv40_default(). Returns 1 if added,
0 if CMv4.0 already present, -1 on error. After calling this, the RPU
can be written back with dovi_write_unspec62_nalu() and will include
the CMv4.0 section.
@pannal pannal force-pushed the cmv29-payload-end-bit branch from f83d105 to 2667a67 Compare April 11, 2026 00:26
@pannal pannal changed the title expose CMv2.9 payload end bit in VdrDmData add dovi_rpu_set_cmv40_default for appending CMv4.0 to CMv2.9 RPUs Apr 11, 2026
@pannal
Copy link
Copy Markdown
Contributor Author

pannal commented Apr 11, 2026

Does that work for you?

@quietvoid
Copy link
Copy Markdown
Owner

Yeah that's OK, I made some extra adjustments locally that should work on top of this, mostly refactoring and some better names.
Just need to fix the tests.

@quietvoid
Copy link
Copy Markdown
Owner

quietvoid commented Apr 11, 2026

I've renamed the function to add_cmv40_safe_default_metadata to be more representative.
And C API function follows the same name.

When generating, include all the safe default metadata blocks.
Little refactoring and renaming.

tests: update generated CM v4.0 test files
@quietvoid quietvoid force-pushed the cmv29-payload-end-bit branch from 8cd95fd to 293fbd6 Compare April 11, 2026 01:26
@pannal
Copy link
Copy Markdown
Contributor Author

pannal commented Apr 11, 2026

Looks good!

@quietvoid quietvoid merged commit 293fbd6 into quietvoid:main Apr 11, 2026
1 check passed
quietvoid added a commit that referenced this pull request Apr 11, 2026
quietvoid added a commit that referenced this pull request May 17, 2026
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

Successfully merging this pull request may close these issues.

2 participants