From 2291f90f6495b3ef30a462df169bdabeb4a71ee3 Mon Sep 17 00:00:00 2001
From: rlaphoenix <rlaphoenix@pm.me>
Date: Mon, 8 Jan 2024 23:56:45 +0000
Subject: [PATCH] Re-map Video Transfer value 5 to 6

This is seen in some manifests/services for whatever reason. I can't find documentation for this value anywhere. It seems unused in official specifications as of right now. However, it seems in some services/places it is unofficially used as a PAL-version of BT-601 transfer, which makes sense.

Devine's code (and other services) wouldn't care about the difference here so currently it is just implemented as a remap from 5 to 6. In the future it may be changed and actually defined as two seperate BT_601 Transfer enum entries.
---
 devine/core/tracks/video.py | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/devine/core/tracks/video.py b/devine/core/tracks/video.py
index b5922d7..c2e8ce4 100644
--- a/devine/core/tracks/video.py
+++ b/devine/core/tracks/video.py
@@ -117,6 +117,12 @@ class Video(Track):
                 YCbCr_BT_2020_and_2100 = 9  # YCbCr BT.2100 shares the same CP
                 ICtCp_BT_2100 = 14
 
+            if transfer == 5:
+                # While not part of any standard, it is typically used as a PAL variant of Transfer.BT_601=6.
+                # i.e. where Transfer 6 would be for BT.601-NTSC and Transfer 5 would be for BT.601-PAL.
+                # The codebase is currently agnostic to either, so a manual conversion to 6 is done.
+                transfer = 6
+
             primaries = Primaries(primaries)
             transfer = Transfer(transfer)
             matrix = Matrix(matrix)