Breakthrough - Successfully embed metadata
I can now embed the dolby vision metadata while playing any video. Metadata is put into the gui layer and seems to be rock-solid.
Test build:
248.11 MB file on MEGA
Usage:
Initial once-off setup: Set kodi to use 12-bit 422 with a 3840 x 2160 gui resolution. Enable the option āDisable GUI scalingā. Reboot.
Use:
To use trigger DV with a video (any video, doesnāt need to be DV) playing by
echo Y > /sys/module/amvideo/parameters/inject_osd_metadata
echo Y > /sys/module/am_vecm/parameters/DV_vsif_send_in_hdmi_packet
echo DV_enable > /sys/devices/virtual/amhdmitx/amhdmitx0/attr
Will need to do this for every video started.
Note: When the videos stop the gui will by in all the wrong colors. If you want to correct that enter the ssh commands
echo N > /sys/module/am_vecm/parameters/DV_vsif_send_in_hdmi_packet
echo DV_disable_vsif > /sys/devices/virtual/amhdmitx/amhdmitx0/attr
and then do something that triggers a resolution/refresh rate change.
There are two buffers for DV metadata setup - these are not yet being set by metadata from video files. The two are initially loaded with metadata for a source in the IPT (i.e., profile 5) colorspace with very different L1 data.
Change to suit profile 8.1 with
echo 0,0,0,0,82,0,0,37,102,0,0,53,234,37,102,249,252,235,28,37,102,68,202,0,0,1,0,0,0,8,0,0,0,8,0,0,0,28,54,34,67,1,134,14,70,48,142,5,20,0,0,1,166,62,90,255,255,0,0,0,0,0,0,0,0,12,0,1,0,0,62,11,134,42,42,1,0,0,0,6,1,0,20,0,50,0,35,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,11,120,97,107 > /sys/module/amvideo/parameters/metadata_buffer
echo 0,0,0,0,82,0,0,37,102,0,0,53,234,37,102,249,252,235,28,37,102,68,202,0,0,1,0,0,0,8,0,0,0,8,0,0,0,28,54,34,67,1,134,14,70,48,142,5,20,0,0,1,166,62,90,255,255,0,0,0,0,0,0,0,0,12,0,1,0,0,62,11,134,42,42,1,0,0,0,6,1,5,220,13,172,11,184,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,194,81,228,196 > /sys/module/amvideo/parameters/metadata_buffer2
Change back to IPT with
echo 0,0,0,0,82,0,0,32,0,3,31,6,145,32,0,252,91,4,67,32,0,1,11,234,87,0,0,0,0,8,0,0,0,8,0,0,0,66,185,254,163,254,163,254,163,66,185,254,163,254,163,254,163,66,185,255,255,0,0,0,0,0,0,0,0,12,2,1,1,0,62,11,134,0,42,1,0,0,0,6,1,0,20,0,50,0,35,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,189,151,135,54 > /sys/module/amvideo/parameters/metadata_buffer
echo 0,0,0,0,82,0,0,32,0,3,31,6,145,32,0,252,91,4,67,32,0,1,11,234,87,0,0,0,0,8,0,0,0,8,0,0,0,66,185,254,163,254,163,254,163,66,185,254,163,254,163,254,163,66,185,255,255,0,0,0,0,0,0,0,0,12,2,1,1,0,62,11,134,0,42,1,0,0,0,6,1,5,220,13,172,11,184,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,116,190,2,153 > /sys/module/amvideo/parameters/metadata_buffer2
By default these two sets of metadata will be switched between every 125 frames. Can set this timing to whatever, for every 250 frames use
echo 250 > /sys/module/amvideo/parameters/toggle_metadata_count_limit
To disable the auto toggling use
echo 0> /sys/module/amvideo/parameters/toggle_metadata_count_limit
Can also manually toggle with
echo Y > /sys/module/amvideo/parameters/metadata_toggle
Testing
This build should provide tv-led DV from any device (licenced or not) paired with a TV that support tv-led DV.
Success is the TV goes into DV mode, brightness toggles according to toggle_metadata_count_limit
, and for profile 5 content, correct colors being displayed (when using the default metadata).
Testing has been very solid for me, at risk of a onslaught of problems, try to break it ā¦
As this work is starting to look like it may actually become useful, the more people that can test with different hardware and setup the better.
Next steps
Next is getting the DV metadata from the video files. I know how to do this with the decoded metadata, but I need access to the decoded metadata. This will require getting the dovi_tool
to decode the metadata inside the primary_render_frame
function in video.c
.
I donāt have the slightest clue how to get a access to the c interface of a rust tool inside of the linux kernel and get it to build. I will need someone to (ideally) do this part for me or at least provide significant help. Shoutout to anyone that could help ā¦