|
| 1 | +# SPDX-License-Identifier: BSD-3-Clause |
| 2 | +# Copyright Contributors to the OpenColorIO Project. |
| 3 | +""" |
| 4 | +*Panasonic* CLF Transforms Generation |
| 5 | +===================================== |
| 6 | +
|
| 7 | +Defines procedures for generating Panasonic *Common LUT Format* (CLF) |
| 8 | +transforms for the OpenColorIO project. |
| 9 | +""" |
| 10 | + |
| 11 | +import PyOpenColorIO as ocio |
| 12 | +from pathlib import Path |
| 13 | + |
| 14 | +from opencolorio_config_aces.clf import ( |
| 15 | + create_conversion_matrix, |
| 16 | + generate_clf, |
| 17 | +) |
| 18 | + |
| 19 | +__author__ = "OpenColorIO Contributors" |
| 20 | +__copyright__ = "Copyright Contributors to the OpenColorIO Project." |
| 21 | +__license__ = "New BSD License - https://opensource.org/licenses/BSD-3-Clause" |
| 22 | +__maintainer__ = "OpenColorIO Contributors" |
| 23 | +__email__ = "ocio-dev@lists.aswf.io" |
| 24 | +__status__ = "Production" |
| 25 | + |
| 26 | +__all__ = [ |
| 27 | + "generate_panasonic", |
| 28 | +] |
| 29 | + |
| 30 | +DEST_DIR = Path(__file__).parent.resolve() / "input" |
| 31 | + |
| 32 | +TF_ID_PREFIX = "urn:aswf:ocio:transformId:1.0:" |
| 33 | +TF_ID_SUFFIX = ":1.0" |
| 34 | + |
| 35 | +CLF_SUFFIX = ".clf" |
| 36 | + |
| 37 | + |
| 38 | +def generate_panasonic(): |
| 39 | + """Make the CLF file for V-Log - V-Gamut plus matrix/curve CLFs.""" |
| 40 | + |
| 41 | + # Based on the document "VARICAM_V-Log_V-Gamut.pdf" dated November 28, 2014. |
| 42 | + # The resulting CLF was reviewed by Panasonic. |
| 43 | + |
| 44 | + if not DEST_DIR.exists(): |
| 45 | + DEST_DIR.mkdir() |
| 46 | + |
| 47 | + cut1 = 0.01 |
| 48 | + b = 0.00873 |
| 49 | + c = 0.241514 |
| 50 | + d = 0.598206 |
| 51 | + |
| 52 | + LIN_SLP = 1.0 |
| 53 | + LIN_OFF = b |
| 54 | + LOG_SLP = c |
| 55 | + LOG_OFF = d |
| 56 | + LIN_SB = cut1 |
| 57 | + BASE = 10.0 |
| 58 | + |
| 59 | + lct = ocio.LogCameraTransform( |
| 60 | + base=BASE, |
| 61 | + linSideBreak=[LIN_SB] * 3, |
| 62 | + logSideSlope=[LOG_SLP] * 3, |
| 63 | + logSideOffset=[LOG_OFF] * 3, |
| 64 | + linSideSlope=[LIN_SLP] * 3, |
| 65 | + linSideOffset=[LIN_OFF] * 3, |
| 66 | + direction=ocio.TRANSFORM_DIR_INVERSE, |
| 67 | + ) |
| 68 | + |
| 69 | + mtx = create_conversion_matrix("V-Gamut", "ACES2065-1", "Bradford") |
| 70 | + |
| 71 | + # Using the CSC ID here because there is a slight discrepancy between the matrix |
| 72 | + # coefficients of the CSC and IDT CTL and the CLF matches the CSC transform. |
| 73 | + aces_transform_id = ( |
| 74 | + "urn:ampas:aces:transformId:v1.5:" |
| 75 | + "ACEScsc.Academy.VLog_VGamut_to_ACES.a1.1.0" |
| 76 | + ) |
| 77 | + |
| 78 | + # Generate full transform. |
| 79 | + |
| 80 | + generate_clf( |
| 81 | + ocio.GroupTransform( |
| 82 | + transforms=[ |
| 83 | + lct, |
| 84 | + mtx, |
| 85 | + ] |
| 86 | + ), |
| 87 | + TF_ID_PREFIX |
| 88 | + + "Panasonic:Input:VLog-VGamut_to_ACES2065-1" |
| 89 | + + TF_ID_SUFFIX, |
| 90 | + "Panasonic V-Log - V-Gamut (SUP v3) to ACES2065-1", |
| 91 | + DEST_DIR / ("VLog-VGamut_to_ACES2065-1" + CLF_SUFFIX), |
| 92 | + "Panasonic V-Log - V-Gamut (SUP v3)", |
| 93 | + "ACES2065-1", |
| 94 | + aces_transform_id, |
| 95 | + ) |
| 96 | + |
| 97 | + # Generate transform for primaries only. |
| 98 | + |
| 99 | + generate_clf( |
| 100 | + ocio.GroupTransform([mtx]), |
| 101 | + TF_ID_PREFIX |
| 102 | + + "Panasonic:Input:Linear-VGamut_to_ACES2065-1" |
| 103 | + + TF_ID_SUFFIX, |
| 104 | + "Linear Panasonic V-Gamut (SUP v3) to ACES2065-1", |
| 105 | + DEST_DIR / ("Linear-VGamut_to_ACES2065-1" + CLF_SUFFIX), |
| 106 | + "Linear Panasonic V-Gamut (SUP v3)", |
| 107 | + "ACES2065-1", |
| 108 | + None, |
| 109 | + ) |
| 110 | + |
| 111 | + # Generate named transform for log curve only. |
| 112 | + |
| 113 | + generate_clf( |
| 114 | + ocio.GroupTransform([lct]), |
| 115 | + TF_ID_PREFIX + "Panasonic:Input:VLog_Log_to_Linear" + TF_ID_SUFFIX, |
| 116 | + "Panasonic V-Log (SUP v3) Log to Linear Curve", |
| 117 | + DEST_DIR / ("VLog-Curve" + CLF_SUFFIX), |
| 118 | + "Panasonic V-Log (SUP v3) Log (arbitrary primaries)", |
| 119 | + "Panasonic V-Log (SUP v3) Linear (arbitrary primaries)", |
| 120 | + None, |
| 121 | + ) |
| 122 | + |
| 123 | + return 0 |
| 124 | + |
| 125 | + |
| 126 | +if __name__ == "__main__": |
| 127 | + import sys |
| 128 | + |
| 129 | + sys.exit(generate_panasonic()) |
0 commit comments