fix(titles): name a dv profile 7 or 8 track with an unnamed pq base DV.HDR

This commit is contained in:
imSp4rky
2026-10-31 21:52:03 -06:00
parent 15e46d8bcc
commit d5a8ed2a39
2 changed files with 29 additions and 2 deletions
+21 -2
View File
@@ -22,7 +22,9 @@ def clean_config(monkeypatch: pytest.MonkeyPatch) -> None:
monkeypatch.setattr(config, "codec_names", {})
def hdr_tag(commercial: str, range_: Video.Range, transfer: str = "PQ") -> str:
def hdr_tag(
commercial: str, range_: Video.Range, transfer: str = "PQ", hdr_format: str = "SMPTE ST 2086", profile: str = ""
) -> str:
movie = Movie(id_="movie-0001", service=DummyService, name="The Film", year=2024, language="en")
movie.tracks = Tracks(Video(url="https://example.test/v.mpd", language="en", codec=Video.Codec.AV1, range_=range_))
video = types.SimpleNamespace(
@@ -32,7 +34,8 @@ def hdr_tag(commercial: str, range_: Video.Range, transfer: str = "PQ") -> str:
scan_type="Progressive",
other_display_aspect_ratio=["16:9"],
hdr_format_commercial=commercial,
hdr_format="SMPTE ST 2086",
hdr_format=hdr_format,
hdr_format_profile=profile,
transfer_characteristics=transfer,
transfer_characteristics_original=None,
frame_rate="23.976",
@@ -63,3 +66,19 @@ def test_hlg_without_an_hdr_format_keeps_the_hlg_tag() -> None:
def test_sdr_gets_no_hdr_tag() -> None:
assert hdr_tag("", Video.Range.SDR, transfer="BT.709") == ""
def test_a_profile_8_dv_track_with_an_unnamed_pq_base_gets_dv_hdr() -> None:
assert hdr_tag("Dolby Vision", Video.Range.DV, hdr_format="Dolby Vision", profile="dvhe.08") == "DV.HDR"
def test_a_profile_5_dv_track_stays_dv() -> None:
assert hdr_tag("Dolby Vision", Video.Range.DV, hdr_format="Dolby Vision", profile="dvhe.05") == "DV"
def test_a_profile_8_4_dv_track_with_an_hlg_base_stays_dv() -> None:
assert hdr_tag("Dolby Vision", Video.Range.DV, transfer="HLG", hdr_format="Dolby Vision", profile="dvhe.08") == "DV"
def test_a_dv_track_with_a_named_hdr10_base_keeps_dv_hdr() -> None:
assert hdr_tag("HDR10", Video.Range.DV, hdr_format="Dolby Vision", profile="dvhe.08") == "DV.HDR"
+8
View File
@@ -163,6 +163,14 @@ class Title:
if (primary_video_track.hdr_format or "").startswith("Dolby Vision"):
context["hdr"] = "DV"
base_layer = DYNAMIC_RANGE_MAP.get(hdr_format)
profile = getattr(primary_video_track, "hdr_format_profile", None) or ""
if (
base_layer in (None, "DV")
and trc
and "PQ" in trc
and profile.startswith(("dvhe.07", "dvhe.08"))
):
base_layer = "HDR"
if base_layer and base_layer != "DV":
context["hdr"] += f".{base_layer}"
elif (primary_video_track.hdr_format or "").startswith("HDR Vivid"):