Skip to content
This repository was archived by the owner on Nov 22, 2019. It is now read-only.

Commit 0f8a251

Browse files
author
mfe
committed
Add 3dl export
1 parent ad63966 commit 0f8a251

File tree

1 file changed

+47
-0
lines changed

1 file changed

+47
-0
lines changed

utils/threedl_helper.py

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
""" 3dl (3D LUT) helpers
2+
3+
.. moduleauthor:: `Marie FETIVEAU <github.com/mfe>`_
4+
5+
"""
6+
import math
7+
8+
9+
class ThreeDLHelperException(Exception):
10+
pass
11+
12+
13+
def get_shaper_lut(cube_size, bit_depth):
14+
""" Return shaper lut as a list
15+
16+
Args:
17+
cube_size (int): cube size. Ex: 17, 32...
18+
19+
bit_depth (int): bit depth of shaper lut values. Ex: 10, 12, 16...
20+
21+
Returns:
22+
.int list
23+
24+
"""
25+
max_value = float(math.pow(2, bit_depth) - 1)
26+
step = max_value / (cube_size - 1)
27+
shaper_lut = []
28+
for i in range(0, cube_size):
29+
shaper_lut.append(int(i*step))
30+
return shaper_lut
31+
32+
33+
def get_string_shaper_lut(cube_size, bit_depth):
34+
""" Return shaper lut as a string
35+
36+
Args:
37+
cube_size (int): cube size. Ex: 17, 32...
38+
39+
bit_depth (int): bit depth of the value of the shaper lut. Ex: 10, 12,
40+
16...
41+
42+
Returns:
43+
.string list
44+
45+
"""
46+
shaper_lut = get_shaper_lut(cube_size, bit_depth)
47+
return "{0}".format(" ".join(map(str, shaper_lut)))

0 commit comments

Comments
 (0)