Bug 280208 - multimedia/x265: Fix HDR10+ support [PATCH]
Summary: multimedia/x265: Fix HDR10+ support [PATCH]
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: --- Affects Many People
Assignee: Vladimir Druzenko
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2024-07-09 17:07 UTC by Oliver Fromme
Modified: 2024-07-25 19:03 UTC (History)
2 users (show)

See Also:


Attachments
HDR10+ JSON file for testing. Save as "dummy.json". (638 bytes, application/json)
2024-07-09 17:07 UTC, Oliver Fromme
no flags Details
Patch for multimedia/x265 (618 bytes, patch)
2024-07-09 17:10 UTC, Oliver Fromme
no flags Details | Diff
sort out Makefile and pet portclippy (6.15 KB, patch)
2024-07-10 16:25 UTC, Vladimir Druzenko
vvd: maintainer-approval? (freebsd-2024)
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Oliver Fromme freebsd_committer freebsd_triage 2024-07-09 17:07:46 UTC
Created attachment 251953 [details]
HDR10+ JSON file for testing. Save as "dummy.json".

Currently, the FreeBSD build of multimedia/x265 (version 3.5_1) fails to include HDR10+ (a.k.a. HDR10plus or "dynamic HDR") support. It only includes HDR10 support (without "plus", sometimes referred to as "static HDR").

That problem also affects the ffmpeg port because it uses the x265 port for encoding. And that, in turn, affects many other ports that use ffmpeg or its library for encoding. In other words, the problem renders several ports unable to produce HDR10+ video content.

How to reproduce (short):

The simplest way to check for the problem is this:

Command:  strings -a /usr/local/lib/libx265.so | grep HDR10_PLUS
Output:  --dhdr10-info disabled. Enable HDR10_PLUS in cmake.

That string shown in the output is only included in the library if support for HDR10_PLUS was *not* enabled at build time.  See the file source/encoder/encoder.cpp in the x265 distribution for details.  It contains the conditionally compiled code responsible for that.

How to reproduce (long):

The following ffmpeg command line will demonstrate the problem. It is supposed to generate 1 second of black frames with HDR10+ data. In order for it to work, you need to store the JSON file attached to this PR with the file name "dummy.json".  Be sure that the JSON data doesn't get damaged.  If it doesn't parse as proper JSON, ffmpeg will simply coredump.

Command (all on one line):  ffmpeg -hide_banner -loglevel warning -t 1 -f lavfi -i "color=c=black:s=1280x720" -pix_fmt yuv420p10le -r 25 -c:V:0 libx265 -x265-params "log-level=warning:hdr10=1:hdr10-opt=1:colorprim=bt2020:transfer=smpte2084:colormatrix=bt2020nc:repeat-headers=1:dhdr10-info=dummy.json" -preset fast test.mkv

It will print the following warning:
x265 [warning] --dhdr10-info disabled. Enable HDR10_PLUS in cmake.

The resulting video file only contains static HDR10, not dynamic HDR10+. You can check with the multimedia/mediainfo port:

Command:  mediainfo test.mkv | grep HDR
Output:  HDR format : SMPTE ST 2086, HDR10 compatible

How to fix:

Put the the follwing patch in the "files" directory of the multimedia/x265 port (suggested name "patch-HDR10_PLUS":


--- source/CMakeLists.txt.ORIG  2023-08-24 13:11:18.000000000 +0200
+++ source/CMakeLists.txt       2024-07-05 20:45:28.571155000 +0200
@@ -196,7 +196,7 @@
     add_definitions(-qinline=level=10 -qpath=IL:/data/video_files/latest.tpo/)
 endif()
 # this option is to enable the inclusion of dynamic HDR10 library to the libx265 compilation
-option(ENABLE_HDR10_PLUS "Enable dynamic HDR10 compilation" OFF)
+option(ENABLE_HDR10_PLUS "Enable dynamic HDR10 compilation" ON)
 if(MSVC AND (MSVC_VERSION LESS 1800) AND ENABLE_HDR10_PLUS)
     message(FATAL_ERROR "MSVC version 12.0 or above required to support hdr10plus")
 endif()


Then rebuild and install the port.

Afterwards, the above mentioned strings(1) command produces empty output. That means, the warning message is not in the library anymore because the HDR10+ support has been compiled in correctly.

When you repeat the above ffmpeg command (remove the old test.mkv file first), the resulting file contains proper HR10+ meta data. The check with the mediainfo command now gives this output:

HDR format : SMPTE ST 2094 App 4, Version 1, HDR10+ Profile A compatible

Hooray, we can now create dynamic HDR10+ video content!
Comment 1 Bugzilla Automation freebsd_committer freebsd_triage 2024-07-09 17:07:46 UTC
Maintainer informed via mail
Comment 2 Oliver Fromme freebsd_committer freebsd_triage 2024-07-09 17:10:40 UTC
Created attachment 251954 [details]
Patch for multimedia/x265

Added the patch as an attachment to the PR.
Comment 3 Vladimir Druzenko freebsd_committer freebsd_triage 2024-07-09 21:17:17 UTC
(In reply to Oliver Fromme from comment #2)
Try this patch to multimedia/x265/Makefile:
-CMAKE_ARGS=    -DENABLE_TESTS=on -DENABLE_HDR10_PLUS:BOOL=true -DGIT_ARCHETYPE=1
+CMAKE_ARGS=    -DENABLE_TESTS=on -DGIT_ARCHETYPE=1
+CMAKE_ON=      ENABLE_HDR10_PLUS

I can't add maintainer ports@virtual-estates.net to CC or to maintainer-feedback.
Look same as here: https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=206413
Is maintainer still active?

I found only "Mikhail T. <freebsd-2024@virtual-estates.net>" with domain virtual-estates.net.
Comment 4 Mikhail T. 2024-07-10 03:24:55 UTC
The change makes sense, but I'm no longer able to commit anything -- because portmgr's been taken over...

Whatever committer comes across this, please, consider this comment as a maintainer-approval. Don't forget to deal with the PORTREVISION, though or you may lose your commit too.

Thanks!
Comment 5 Vladimir Druzenko freebsd_committer freebsd_triage 2024-07-10 10:43:53 UTC
(In reply to Mikhail T. from comment #4)
Is it your old email ports@virtual-estates.net?
There are 61 ports with this maintainer: https://portscout.freebsd.org/ports@virtual-estates.net.html
What happen? Is virtual-estates.net your private domain?
Comment 6 Vladimir Druzenko freebsd_committer freebsd_triage 2024-07-10 11:11:41 UTC
Are you mi@?
Comment 7 Vladimir Druzenko freebsd_committer freebsd_triage 2024-07-10 12:48:54 UTC
If you want to update MAINTAINER email create please separate PR with patch for all your ports.
Comment 8 Vladimir Druzenko freebsd_committer freebsd_triage 2024-07-10 13:02:16 UTC
portclippy show several warnings - can I fix?
Comment 9 commit-hook freebsd_committer freebsd_triage 2024-07-10 13:36:37 UTC
A commit in branch main references this bug:

URL: https://cgit.FreeBSD.org/ports/commit/?id=92c083249312380c8e3fb72279fb8e91a7d4b50c

commit 92c083249312380c8e3fb72279fb8e91a7d4b50c
Author:     Vladimir Druzenko <vvd@FreeBSD.org>
AuthorDate: 2024-07-10 13:15:23 +0000
Commit:     Vladimir Druzenko <vvd@FreeBSD.org>
CommitDate: 2024-07-10 13:33:31 +0000

    multimedia/x265: fix HDR10+ support

    Currently, the FreeBSD build of multimedia/x265 fails to include HDR10+
    (a.k.a. HDR10plus or "dynamic HDR") support. It only includes HDR10
    support (without "plus", sometimes referred to as "static HDR").
    That problem also affects the ffmpeg port because it uses the x265 port
    for encoding. And that, in turn, affects many other ports that use
    ffmpeg or its library for encoding. In other words, the problem renders
    several ports unable to produce HDR10+ video content.

    There is a non-default cmake build option ENABLE_HDR10_PLUS, but the
    port does not handle it correctly.

    PR:             280208
    Approved by:    Mikhail T. <freebsd-2024@virtual-estates.net> (maintainer)

 multimedia/x265/Makefile | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
Comment 10 Oliver Fromme freebsd_committer freebsd_triage 2024-07-10 16:03:44 UTC
(In reply to Vladimir Druzenko from comment #3)

I tested the updated x265 port, and I can indeed confirm that the commit fixes the problem.

Thank you very much!
Comment 11 Vladimir Druzenko freebsd_committer freebsd_triage 2024-07-10 16:25:35 UTC
Created attachment 251963 [details]
sort out Makefile and pet portclippy
Comment 12 commit-hook freebsd_committer freebsd_triage 2024-07-25 19:03:16 UTC
A commit in branch main references this bug:

URL: https://cgit.FreeBSD.org/ports/commit/?id=ecee7811204a75e6c90e12e55f7a5f8105899748

commit ecee7811204a75e6c90e12e55f7a5f8105899748
Author:     Vladimir Druzenko <vvd@FreeBSD.org>
AuthorDate: 2024-07-25 18:59:48 +0000
Commit:     Vladimir Druzenko <vvd@FreeBSD.org>
CommitDate: 2024-07-25 18:59:48 +0000

    multimedia/x265: sort out Makefile, pet portclippy

    No functional changes.

    PR:             280208
    Approved by:    ports@virtual-estates.net (maintainer, timeout > 2 weeks)

 multimedia/x265/Makefile | 101 +++++++++++++++++++++++------------------------
 1 file changed, 49 insertions(+), 52 deletions(-)