aboutsummaryrefslogtreecommitdiff
path: root/study/create_matrix.py
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2024-03-07 22:53:04 +0100
committerdec05eba <dec05eba@protonmail.com>2024-03-08 11:35:30 +0100
commit3d9a7065280e64797c5a68c794a04d60fb3f767c (patch)
tree75ad01478ec31296bf24dfd56dd1881347a54f1e /study/create_matrix.py
parent0d89378021b9e8913b521164d1bc436d9bc2630f (diff)
Set frame size to video codec context size, nicer rgb to nv12
Diffstat (limited to 'study/create_matrix.py')
-rwxr-xr-xstudy/create_matrix.py14
1 files changed, 10 insertions, 4 deletions
diff --git a/study/create_matrix.py b/study/create_matrix.py
index 96bfcd4..1599a12 100755
--- a/study/create_matrix.py
+++ b/study/create_matrix.py
@@ -9,6 +9,12 @@ def usage():
print(" create_matrix.py 0.2126 0.7152 0.0722 limited")
exit(1)
+def a(v):
+ if v >= 0:
+ return " %f" % v
+ else:
+ return "%f" % v
+
def main(argv):
if len(argv) != 5:
usage()
@@ -34,9 +40,9 @@ def main(argv):
]
# 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))
+ print("const mat4 RGBtoYUV = mat4(%f, %s, %s, %f," % (matrix[0][0] * transform_range, a(matrix[1][0] * transform_range), a(matrix[2][0] * transform_range), 0.0))
+ print(" %f, %s, %s, %f," % (matrix[0][1] * transform_range, a(matrix[1][1] * transform_range), a(matrix[2][1] * transform_range), 0.0))
+ print(" %f, %s, %s, %f," % (matrix[0][2] * transform_range, a(matrix[1][2] * transform_range), a(matrix[2][2] * transform_range), 0.0))
+ print(" %f, %s, %s, %f);" % (matrix[3][0] + luma_offset, a(matrix[3][1]), a(matrix[3][2]), 1.0))
main(sys.argv)