aboutsummaryrefslogtreecommitdiff
path: root/study
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2024-02-01 18:06:26 +0100
committerdec05eba <dec05eba@protonmail.com>2024-02-06 02:43:47 +0100
commit017fd0a37da0fc3dddcd635d09770c123f133e57 (patch)
tree31f551405884b13e8019c95af3b8ad49addc537b /study
parentf36182ea1318d6b19a7e518a6b542d5b19b07276 (diff)
Add support for hdr capture on amd/intel
Nvidia support will be added in the future. Note that hdr metadata is missing from the output file as amd and intel both have bugged drivers that dont add hdr metadata to the output file. Need to find a workaround for this (patching the video bitstream?). Add -cr limited|full, to set color range
Diffstat (limited to 'study')
-rw-r--r--study/color_space_transform_matrix.pngbin0 -> 7166 bytes
-rwxr-xr-xstudy/create_matrix.py42
2 files changed, 42 insertions, 0 deletions
diff --git a/study/color_space_transform_matrix.png b/study/color_space_transform_matrix.png
new file mode 100644
index 0000000..2b7729e5
--- /dev/null
+++ b/study/color_space_transform_matrix.png
Binary files differ
diff --git a/study/create_matrix.py b/study/create_matrix.py
new file mode 100755
index 0000000..96bfcd4
--- /dev/null
+++ b/study/create_matrix.py
@@ -0,0 +1,42 @@
+#!/usr/bin/env python3
+
+import sys
+
+def usage():
+ print("usage: Kr Kg Kb full|limited")
+ print("examples:")
+ print(" create_matrix.py 0.2126 0.7152 0.0722 full")
+ print(" create_matrix.py 0.2126 0.7152 0.0722 limited")
+ exit(1)
+
+def main(argv):
+ if len(argv) != 5:
+ usage()
+
+ Kr = float(sys.argv[1])
+ Kg = float(sys.argv[2])
+ Kb = float(sys.argv[3])
+ color_range = sys.argv[4]
+ luma_offset = 0.0
+ transform_range = 1.0
+
+ if color_range == "full":
+ pass
+ elif color_range == "limited":
+ transform_range = (235.0 - 16.0) / 255.0
+ luma_offset = 16.0 / 255.0
+
+ matrix = [
+ [Kr, Kg, Kb],
+ [-0.5 * (Kr / (1.0 - Kb)), -0.5 * (Kg / (1.0 - Kb)), 0.5],
+ [0.5, -0.5 * (Kg / (1.0 - Kr)), -0.5 * (Kb / (1.0 -Kr))],
+ [0.0, 0.5, 0.5]
+ ]
+
+ # Transform from row major to column major for glsl
+ print("%f, %f, %f, %f" % (matrix[0][0] * transform_range, matrix[1][0] * transform_range, matrix[2][0] * transform_range, 0.0))
+ print("%f, %f, %f, %f" % (matrix[0][1] * transform_range, matrix[1][1] * transform_range, matrix[2][1] * transform_range, 0.0))
+ print("%f, %f, %f, %f" % (matrix[0][2] * transform_range, matrix[1][2] * transform_range, matrix[2][2] * transform_range, 0.0))
+ print("%f, %f, %f, %f" % (matrix[3][0] + luma_offset, matrix[3][1], matrix[3][2], 1.0))
+
+main(sys.argv)