This repository has been archived by the owner on Nov 22, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
mfe
committed
Dec 27, 2013
1 parent
ad63966
commit 0f8a251
Showing
1 changed file
with
47 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
""" 3dl (3D LUT) helpers | ||
.. moduleauthor:: `Marie FETIVEAU <github.com/mfe>`_ | ||
""" | ||
import math | ||
|
||
|
||
class ThreeDLHelperException(Exception): | ||
pass | ||
|
||
|
||
def get_shaper_lut(cube_size, bit_depth): | ||
""" Return shaper lut as a list | ||
Args: | ||
cube_size (int): cube size. Ex: 17, 32... | ||
bit_depth (int): bit depth of shaper lut values. Ex: 10, 12, 16... | ||
Returns: | ||
.int list | ||
""" | ||
max_value = float(math.pow(2, bit_depth) - 1) | ||
step = max_value / (cube_size - 1) | ||
shaper_lut = [] | ||
for i in range(0, cube_size): | ||
shaper_lut.append(int(i*step)) | ||
return shaper_lut | ||
|
||
|
||
def get_string_shaper_lut(cube_size, bit_depth): | ||
""" Return shaper lut as a string | ||
Args: | ||
cube_size (int): cube size. Ex: 17, 32... | ||
bit_depth (int): bit depth of the value of the shaper lut. Ex: 10, 12, | ||
16... | ||
Returns: | ||
.string list | ||
""" | ||
shaper_lut = get_shaper_lut(cube_size, bit_depth) | ||
return "{0}".format(" ".join(map(str, shaper_lut))) |