591 lines
30 KiB
Python
591 lines
30 KiB
Python
from enum import IntEnum
|
||
import UniTAP
|
||
|
||
|
||
class UCDEnum:
|
||
class ColorInfo:
|
||
"""
|
||
|
||
Class contains information of frame `ColorFormat`, `DynamicRange`, `Colorimetry`.
|
||
|
||
"""
|
||
|
||
class ColorFormat(IntEnum):
|
||
"""
|
||
Contains values of possible color format.
|
||
"""
|
||
|
||
CF_NONE = 0
|
||
CF_UNKNOWN = 1
|
||
CF_RGB = 2
|
||
CF_YCbCr_422 = 3
|
||
CF_YCbCr_444 = 4
|
||
CF_YCbCr_420 = 5
|
||
CF_IDO_DEFINED = 6
|
||
CF_Y_ONLY = 7
|
||
CF_RAW = 8
|
||
CF_DSC = 9
|
||
|
||
class DynamicRange(IntEnum):
|
||
"""
|
||
Contains values of possible dynamic range.
|
||
"""
|
||
|
||
DR_UNKNOWN = -1
|
||
DR_VESA = 0
|
||
DR_CTA = 1
|
||
|
||
class Colorimetry(IntEnum):
|
||
"""
|
||
Contains values of possible colorimetry.
|
||
"""
|
||
|
||
CM_NONE = 0
|
||
CM_RESERVED = 1
|
||
CM_sRGB = 2
|
||
CM_SMPTE_170M = 3
|
||
CM_ITUR_BT601 = 4
|
||
CM_ITUR_BT709 = 5
|
||
CM_xvYCC601 = 6
|
||
CM_xvYCC709 = 7
|
||
CM_sYCC601 = 8
|
||
CM_AdobeYCC601 = 9
|
||
CM_AdobeRGB = 10
|
||
CM_ITUR_BT2020_YcCbcCrc = 11
|
||
CM_ITUR_BT2020_YCbCr = 12
|
||
CM_ITUR_BT2020_RGB = 13
|
||
CM_RGB_WIDE_GAMUT_FIX = 14
|
||
CM_RGB_WIDE_GAMUT_FLT = 15
|
||
CM_DCI_P3 = 16
|
||
CM_DICOM_1_4_GRAY_SCALE = 17
|
||
CM_CUSTOM_COLOR_PROFILE = 18
|
||
|
||
CM_opYCC601 = CM_AdobeYCC601
|
||
CM_opRGB = CM_AdobeRGB
|
||
|
||
# 颜色格式映射 - 支持不区分大小写的字符串匹配
|
||
@staticmethod
|
||
def get_color_format(format_str):
|
||
format_map = {
|
||
"none": UniTAP.ColorInfo.ColorFormat.CF_NONE,
|
||
"unknown": UniTAP.ColorInfo.ColorFormat.CF_UNKNOWN,
|
||
"rgb": UniTAP.ColorInfo.ColorFormat.CF_RGB,
|
||
"ycbcr422": UniTAP.ColorInfo.ColorFormat.CF_YCbCr_422,
|
||
"ycbcr444": UniTAP.ColorInfo.ColorFormat.CF_YCbCr_444,
|
||
"ycbcr420": UniTAP.ColorInfo.ColorFormat.CF_YCbCr_420,
|
||
"ido_defined": UniTAP.ColorInfo.ColorFormat.CF_IDO_DEFINED,
|
||
"yonly": UniTAP.ColorInfo.ColorFormat.CF_Y_ONLY,
|
||
"raw": UniTAP.ColorInfo.ColorFormat.CF_RAW,
|
||
"dsc": UniTAP.ColorInfo.ColorFormat.CF_DSC,
|
||
}
|
||
if not format_str:
|
||
return None
|
||
return format_map.get(format_str.lower(), None)
|
||
|
||
# 色度映射 - 支持不区分大小写的字符串匹配
|
||
@staticmethod
|
||
def get_colorimetry(colorimetry_str):
|
||
colorimetry_map = {
|
||
"none": UniTAP.ColorInfo.Colorimetry.CM_NONE,
|
||
"reserved": UniTAP.ColorInfo.Colorimetry.CM_RESERVED,
|
||
"srgb": UniTAP.ColorInfo.Colorimetry.CM_sRGB,
|
||
"smpte170m": UniTAP.ColorInfo.Colorimetry.CM_SMPTE_170M,
|
||
"bt601": UniTAP.ColorInfo.Colorimetry.CM_ITUR_BT601,
|
||
"bt709": UniTAP.ColorInfo.Colorimetry.CM_ITUR_BT709,
|
||
"xvycc601": UniTAP.ColorInfo.Colorimetry.CM_xvYCC601,
|
||
"xvycc709": UniTAP.ColorInfo.Colorimetry.CM_xvYCC709,
|
||
"sycc601": UniTAP.ColorInfo.Colorimetry.CM_sYCC601,
|
||
"adobeycc601": UniTAP.ColorInfo.Colorimetry.CM_AdobeYCC601,
|
||
"adobergb": UniTAP.ColorInfo.Colorimetry.CM_AdobeRGB,
|
||
"bt2020yccbccrc": UniTAP.ColorInfo.Colorimetry.CM_ITUR_BT2020_YcCbcCrc,
|
||
"bt2020ycbcr": UniTAP.ColorInfo.Colorimetry.CM_ITUR_BT2020_YCbCr,
|
||
"bt2020rgb": UniTAP.ColorInfo.Colorimetry.CM_ITUR_BT2020_RGB,
|
||
"rgbwidegamutfix": UniTAP.ColorInfo.Colorimetry.CM_RGB_WIDE_GAMUT_FIX,
|
||
"rgbwidegamutflt": UniTAP.ColorInfo.Colorimetry.CM_RGB_WIDE_GAMUT_FLT,
|
||
"dcip3": UniTAP.ColorInfo.Colorimetry.CM_DCI_P3,
|
||
"dicom14grayscale": UniTAP.ColorInfo.Colorimetry.CM_DICOM_1_4_GRAY_SCALE,
|
||
"customcolorprofile": UniTAP.ColorInfo.Colorimetry.CM_CUSTOM_COLOR_PROFILE,
|
||
"opycc601": UniTAP.ColorInfo.Colorimetry.CM_opYCC601,
|
||
"oprgb": UniTAP.ColorInfo.Colorimetry.CM_opRGB,
|
||
}
|
||
if not colorimetry_str:
|
||
return None
|
||
return colorimetry_map.get(colorimetry_str.lower(), None)
|
||
|
||
class VideoPatternInfo:
|
||
class VideoPattern(IntEnum):
|
||
"""
|
||
Class `VideoPattern` contains all possible variants of patterns which can be set in the function `set_pattern`.
|
||
"""
|
||
|
||
Disabled = 0
|
||
ColorBars = 1
|
||
Chessboard = 2
|
||
SolidColor = 3
|
||
SolidWhite = 4
|
||
SolidRed = 5
|
||
SolidGreen = 6
|
||
SolidBlue = 7
|
||
WhiteVStrips = 8
|
||
GradientRGBStripes = 9
|
||
ColorRamp = 10
|
||
ColorSquares = 11
|
||
MotionPattern = 12
|
||
SquareWindow = 15
|
||
|
||
class VideoPatternParams(IntEnum):
|
||
"""
|
||
Class `VideoPatternParams` contains all possible variants of parameters which can be set in the function `set_pattern_params`.
|
||
"""
|
||
|
||
SolidColor = 3
|
||
WhiteVStrips = 8
|
||
GradientRGBStripes = 9
|
||
MotionPattern = 12
|
||
SquareWindow = 15
|
||
|
||
@staticmethod
|
||
def get_video_pattern(pattern_str):
|
||
pattern_map = {
|
||
"disabled": UniTAP.VideoPattern.Disabled,
|
||
"colorbars": UniTAP.VideoPattern.ColorBars,
|
||
"chessboard": UniTAP.VideoPattern.Chessboard,
|
||
"solidcolor": UniTAP.VideoPattern.SolidColor,
|
||
"solidwhite": UniTAP.VideoPattern.SolidWhite,
|
||
"solidred": UniTAP.VideoPattern.SolidRed,
|
||
"solidgreen": UniTAP.VideoPattern.SolidGreen,
|
||
"solidblue": UniTAP.VideoPattern.SolidBlue,
|
||
"whitevstrips": UniTAP.VideoPattern.WhiteVStrips,
|
||
"gradientrgbstripes": UniTAP.VideoPattern.GradientRGBStripes,
|
||
"colorramp": UniTAP.VideoPattern.ColorRamp,
|
||
"coloursquares": UniTAP.VideoPattern.ColorSquares,
|
||
"motionpattern": UniTAP.VideoPattern.MotionPattern,
|
||
"squarewindow": UniTAP.VideoPattern.SquareWindow,
|
||
}
|
||
if not pattern_str:
|
||
return None
|
||
return pattern_map.get(pattern_str.lower(), None)
|
||
|
||
class TimingInfo:
|
||
class ResolutionType(IntEnum):
|
||
"""
|
||
分辨率类型枚举,包含DMT、CTA、CVT和OVT四种类型
|
||
"""
|
||
|
||
DMT = 0 # VESA Display Monitor Timing
|
||
CTA = 1 # Consumer Technology Association
|
||
CVT = 2 # Coordinated Video Timing
|
||
OVT = 3 # Other Video Timing
|
||
|
||
# 分辨率类型映射
|
||
resolution_type_map = {
|
||
"dmt": ResolutionType.DMT,
|
||
"cta": ResolutionType.CTA,
|
||
"cvt": ResolutionType.CVT,
|
||
"ovt": ResolutionType.OVT,
|
||
}
|
||
|
||
# DMT分辨率ID映射
|
||
dmt_resolution_map = {
|
||
9: {"width": 800, "height": 600, "refresh_rate": 60.317, "id_hex": "9h"},
|
||
14: {"width": 848, "height": 480, "refresh_rate": 60.0, "id_hex": "Eh"},
|
||
16: {"width": 1024, "height": 768, "refresh_rate": 60.0, "id_hex": "10h"},
|
||
23: {"width": 1280, "height": 768, "refresh_rate": 60.0, "id_hex": "17h"},
|
||
27: {
|
||
"width": 1280,
|
||
"height": 800,
|
||
"refresh_rate": 60.0,
|
||
"id_hex": "1Bh",
|
||
"note": "RB1",
|
||
},
|
||
28: {"width": 1280, "height": 800, "refresh_rate": 60.0, "id_hex": "1Ch"},
|
||
32: {"width": 1280, "height": 960, "refresh_rate": 60.0, "id_hex": "20h"},
|
||
35: {"width": 1280, "height": 1024, "refresh_rate": 60.0, "id_hex": "23h"},
|
||
39: {"width": 1360, "height": 768, "refresh_rate": 60.0, "id_hex": "27h"},
|
||
41: {
|
||
"width": 1400,
|
||
"height": 1050,
|
||
"refresh_rate": 60.0,
|
||
"id_hex": "29h",
|
||
"note": "RB1",
|
||
},
|
||
42: {"width": 1400, "height": 1050, "refresh_rate": 60.0, "id_hex": "2Ah"},
|
||
47: {"width": 1440, "height": 900, "refresh_rate": 59.887, "id_hex": "2Fh"},
|
||
51: {"width": 1600, "height": 1200, "refresh_rate": 60.0, "id_hex": "33h"},
|
||
57: {
|
||
"width": 1680,
|
||
"height": 1050,
|
||
"refresh_rate": 60.0,
|
||
"id_hex": "39h",
|
||
"note": "RB1",
|
||
},
|
||
58: {"width": 1680, "height": 1050, "refresh_rate": 60.0, "id_hex": "3Ah"},
|
||
62: {"width": 1792, "height": 1344, "refresh_rate": 60.0, "id_hex": "3Eh"},
|
||
65: {"width": 1856, "height": 1392, "refresh_rate": 60.0, "id_hex": "41h"},
|
||
69: {"width": 1920, "height": 1200, "refresh_rate": 60.0, "id_hex": "45h"},
|
||
73: {"width": 1920, "height": 1440, "refresh_rate": 60.0, "id_hex": "49h"},
|
||
76: {
|
||
"width": 2560,
|
||
"height": 1600,
|
||
"refresh_rate": 60.0,
|
||
"id_hex": "4Ch",
|
||
"note": "RB1",
|
||
},
|
||
77: {"width": 2560, "height": 1600, "refresh_rate": 60.0, "id_hex": "4Dh"},
|
||
82: {"width": 1920, "height": 1080, "refresh_rate": 60.0, "id_hex": "52h"},
|
||
}
|
||
|
||
# CTA分辨率ID映射
|
||
cta_resolution_map = {
|
||
1: {"width": 640, "height": 480, "refresh_rate": 59.94, "vic": 1},
|
||
2: {"width": 720, "height": 480, "refresh_rate": 59.94, "vic": 2},
|
||
3: {"width": 720, "height": 480, "refresh_rate": 59.94, "vic": 3},
|
||
4: {"width": 1280, "height": 720, "refresh_rate": 60.0, "vic": 4},
|
||
8: {"width": 1440, "height": 240, "refresh_rate": 59.826, "vic": 8},
|
||
9: {"width": 1440, "height": 240, "refresh_rate": 60.054, "vic": 9},
|
||
12: {"width": 2880, "height": 240, "refresh_rate": 59.826, "vic": 12},
|
||
13: {"width": 2880, "height": 240, "refresh_rate": 59.826, "vic": 13},
|
||
14: {"width": 1440, "height": 480, "refresh_rate": 59.94, "vic": 14},
|
||
15: {"width": 1440, "height": 480, "refresh_rate": 59.94, "vic": 15},
|
||
16: {"width": 1920, "height": 1080, "refresh_rate": 60.0, "vic": 16},
|
||
17: {"width": 720, "height": 576, "refresh_rate": 50.0, "vic": 17},
|
||
18: {"width": 720, "height": 576, "refresh_rate": 50.0, "vic": 18},
|
||
19: {"width": 1280, "height": 720, "refresh_rate": 50.0, "vic": 19},
|
||
23: {"width": 1440, "height": 288, "refresh_rate": 49.761, "vic": 23},
|
||
24: {"width": 1440, "height": 288, "refresh_rate": 49.761, "vic": 24},
|
||
27: {"width": 2880, "height": 288, "refresh_rate": 49.761, "vic": 27},
|
||
28: {"width": 2880, "height": 288, "refresh_rate": 49.761, "vic": 28},
|
||
29: {"width": 1440, "height": 576, "refresh_rate": 50.0, "vic": 29},
|
||
30: {"width": 1440, "height": 576, "refresh_rate": 50.0, "vic": 30},
|
||
31: {"width": 1920, "height": 1080, "refresh_rate": 50.0, "vic": 31},
|
||
32: {"width": 1920, "height": 1080, "refresh_rate": 24.0, "vic": 32},
|
||
33: {"width": 1920, "height": 1080, "refresh_rate": 25.0, "vic": 33},
|
||
34: {"width": 1920, "height": 1080, "refresh_rate": 30.0, "vic": 34},
|
||
35: {"width": 2880, "height": 480, "refresh_rate": 59.94, "vic": 35},
|
||
36: {"width": 2880, "height": 480, "refresh_rate": 59.94, "vic": 36},
|
||
37: {"width": 2880, "height": 576, "refresh_rate": 50.0, "vic": 37},
|
||
38: {"width": 2880, "height": 576, "refresh_rate": 50.0, "vic": 38},
|
||
41: {"width": 1280, "height": 720, "refresh_rate": 100.0, "vic": 41},
|
||
42: {"width": 720, "height": 576, "refresh_rate": 100.0, "vic": 42},
|
||
43: {"width": 720, "height": 576, "refresh_rate": 100.0, "vic": 43},
|
||
47: {"width": 1280, "height": 720, "refresh_rate": 120.0, "vic": 47},
|
||
48: {"width": 720, "height": 480, "refresh_rate": 120.0, "vic": 48},
|
||
49: {"width": 720, "height": 480, "refresh_rate": 119.88, "vic": 49},
|
||
52: {"width": 720, "height": 576, "refresh_rate": 200.0, "vic": 52},
|
||
53: {"width": 720, "height": 576, "refresh_rate": 200.0, "vic": 53},
|
||
56: {"width": 720, "height": 480, "refresh_rate": 239.76, "vic": 56},
|
||
57: {"width": 720, "height": 480, "refresh_rate": 239.76, "vic": 57},
|
||
60: {"width": 1280, "height": 720, "refresh_rate": 24.0, "vic": 60},
|
||
61: {"width": 1280, "height": 720, "refresh_rate": 25.0, "vic": 61},
|
||
62: {"width": 1280, "height": 720, "refresh_rate": 30.0, "vic": 62},
|
||
63: {"width": 1920, "height": 1080, "refresh_rate": 120.0, "vic": 63},
|
||
64: {"width": 1920, "height": 1080, "refresh_rate": 100.0, "vic": 64},
|
||
65: {"width": 1280, "height": 720, "refresh_rate": 24.0, "vic": 65},
|
||
66: {"width": 1280, "height": 720, "refresh_rate": 25.0, "vic": 66},
|
||
67: {"width": 1280, "height": 720, "refresh_rate": 30.0, "vic": 67},
|
||
68: {"width": 1280, "height": 720, "refresh_rate": 50.0, "vic": 68},
|
||
69: {"width": 1280, "height": 720, "refresh_rate": 60.0, "vic": 69},
|
||
70: {"width": 1280, "height": 720, "refresh_rate": 100.0, "vic": 70},
|
||
71: {"width": 1280, "height": 720, "refresh_rate": 120.0, "vic": 71},
|
||
72: {"width": 1920, "height": 1080, "refresh_rate": 24.0, "vic": 72},
|
||
73: {"width": 1920, "height": 1080, "refresh_rate": 25.0, "vic": 73},
|
||
74: {"width": 1920, "height": 1080, "refresh_rate": 30.0, "vic": 74},
|
||
75: {"width": 1920, "height": 1080, "refresh_rate": 50.0, "vic": 75},
|
||
76: {"width": 1920, "height": 1080, "refresh_rate": 60.0, "vic": 76},
|
||
77: {"width": 1920, "height": 1080, "refresh_rate": 100.0, "vic": 77},
|
||
78: {"width": 1920, "height": 1080, "refresh_rate": 120.0, "vic": 78},
|
||
79: {"width": 1680, "height": 720, "refresh_rate": 24.0, "vic": 79},
|
||
80: {"width": 1680, "height": 720, "refresh_rate": 25.0, "vic": 80},
|
||
81: {"width": 1680, "height": 720, "refresh_rate": 30.0, "vic": 81},
|
||
82: {"width": 1680, "height": 720, "refresh_rate": 50.0, "vic": 82},
|
||
83: {"width": 1680, "height": 720, "refresh_rate": 60.0, "vic": 83},
|
||
84: {"width": 1680, "height": 720, "refresh_rate": 100.0, "vic": 84},
|
||
85: {"width": 1680, "height": 720, "refresh_rate": 120.0, "vic": 85},
|
||
86: {"width": 2560, "height": 1080, "refresh_rate": 24.0, "vic": 86},
|
||
87: {"width": 2560, "height": 1080, "refresh_rate": 25.0, "vic": 87},
|
||
88: {"width": 2560, "height": 1080, "refresh_rate": 30.0, "vic": 88},
|
||
89: {"width": 2560, "height": 1080, "refresh_rate": 50.0, "vic": 89},
|
||
90: {"width": 2560, "height": 1080, "refresh_rate": 60.0, "vic": 90},
|
||
91: {"width": 2560, "height": 1080, "refresh_rate": 100.0, "vic": 91},
|
||
92: {"width": 2560, "height": 1080, "refresh_rate": 120.0, "vic": 92},
|
||
93: {"width": 3840, "height": 2160, "refresh_rate": 24.0, "vic": 93},
|
||
94: {"width": 3840, "height": 2160, "refresh_rate": 25.0, "vic": 94},
|
||
95: {"width": 3840, "height": 2160, "refresh_rate": 30.0, "vic": 95},
|
||
96: {"width": 3840, "height": 2160, "refresh_rate": 50.0, "vic": 96},
|
||
97: {"width": 3840, "height": 2160, "refresh_rate": 60.0, "vic": 97},
|
||
98: {"width": 4096, "height": 2160, "refresh_rate": 24.0, "vic": 98},
|
||
99: {"width": 4096, "height": 2160, "refresh_rate": 25.0, "vic": 99},
|
||
100: {"width": 4096, "height": 2160, "refresh_rate": 30.0, "vic": 100},
|
||
101: {"width": 4096, "height": 2160, "refresh_rate": 50.0, "vic": 101},
|
||
102: {"width": 4096, "height": 2160, "refresh_rate": 60.0, "vic": 102},
|
||
103: {"width": 3840, "height": 2160, "refresh_rate": 24.0, "vic": 103},
|
||
104: {"width": 3840, "height": 2160, "refresh_rate": 25.0, "vic": 104},
|
||
105: {"width": 3840, "height": 2160, "refresh_rate": 30.0, "vic": 105},
|
||
106: {"width": 3840, "height": 2160, "refresh_rate": 50.0, "vic": 106},
|
||
107: {"width": 3840, "height": 2160, "refresh_rate": 60.0, "vic": 107},
|
||
108: {"width": 1280, "height": 720, "refresh_rate": 48.0, "vic": 108},
|
||
109: {"width": 1280, "height": 720, "refresh_rate": 48.0, "vic": 109},
|
||
110: {"width": 1680, "height": 720, "refresh_rate": 48.0, "vic": 110},
|
||
111: {"width": 1920, "height": 1080, "refresh_rate": 48.0, "vic": 111},
|
||
112: {"width": 1920, "height": 1080, "refresh_rate": 48.0, "vic": 112},
|
||
113: {"width": 2560, "height": 1080, "refresh_rate": 48.0, "vic": 113},
|
||
114: {"width": 3840, "height": 2160, "refresh_rate": 48.0, "vic": 114},
|
||
115: {"width": 4096, "height": 2160, "refresh_rate": 48.0, "vic": 115},
|
||
116: {"width": 3840, "height": 2160, "refresh_rate": 48.0, "vic": 116},
|
||
117: {"width": 3840, "height": 2160, "refresh_rate": 100.0, "vic": 117},
|
||
118: {"width": 3840, "height": 2160, "refresh_rate": 120.0, "vic": 118},
|
||
119: {"width": 3840, "height": 2160, "refresh_rate": 100.0, "vic": 119},
|
||
120: {"width": 3840, "height": 2160, "refresh_rate": 120.0, "vic": 120},
|
||
218: {"width": 4096, "height": 2160, "refresh_rate": 100.0, "vic": 218},
|
||
219: {"width": 4096, "height": 2160, "refresh_rate": 120.0, "vic": 219},
|
||
}
|
||
|
||
# CVT分辨率ID映射
|
||
cvt_resolution_map = {
|
||
0: [
|
||
{"width": 640, "height": 480, "refresh_rate": 60.0},
|
||
{"width": 768, "height": 480, "refresh_rate": 84.502},
|
||
{"width": 1024, "height": 640, "refresh_rate": 59.887},
|
||
{"width": 1152, "height": 720, "refresh_rate": 74.721},
|
||
{"width": 1280, "height": 768, "refresh_rate": 60.0, "note": "RB1"},
|
||
{"width": 1280, "height": 960, "refresh_rate": 59.939},
|
||
{"width": 1536, "height": 960, "refresh_rate": 84.884},
|
||
{"width": 1600, "height": 1200, "refresh_rate": 60.0, "note": "RB1"},
|
||
{"width": 1920, "height": 1080, "refresh_rate": 30.0, "note": "RB1"},
|
||
{"width": 1920, "height": 1080, "refresh_rate": 30.0, "note": "RB2"},
|
||
{"width": 1920, "height": 1080, "refresh_rate": 60.0, "note": "RB1"},
|
||
{"width": 1920, "height": 1080, "refresh_rate": 60.0, "note": "RB2"},
|
||
{"width": 1920, "height": 1080, "refresh_rate": 84.884},
|
||
{"width": 1920, "height": 1080, "refresh_rate": 120.0, "note": "RB1"},
|
||
{"width": 1920, "height": 1080, "refresh_rate": 120.0, "note": "RB2"},
|
||
{"width": 1920, "height": 1080, "refresh_rate": 144.05, "note": "RB1"},
|
||
{"width": 1920, "height": 1080, "refresh_rate": 144.05, "note": "RB2"},
|
||
{"width": 1920, "height": 1080, "refresh_rate": 144.05, "note": "RB3"},
|
||
{"width": 1920, "height": 1080, "refresh_rate": 200.07, "note": "RB3"},
|
||
{"width": 1920, "height": 1080, "refresh_rate": 239.898, "note": "RB1"},
|
||
{"width": 1920, "height": 1080, "refresh_rate": 239.898, "note": "RB2"},
|
||
{"width": 1920, "height": 1080, "refresh_rate": 239.898, "note": "RB3"},
|
||
{"width": 1920, "height": 1440, "refresh_rate": 59.974, "note": "RB1"},
|
||
{"width": 2048, "height": 1280, "refresh_rate": 59.922, "note": "RB1"},
|
||
{"width": 2048, "height": 1536, "refresh_rate": 60.0, "note": "RB1"},
|
||
{"width": 2128, "height": 1200, "refresh_rate": 59.946},
|
||
{"width": 2456, "height": 1536, "refresh_rate": 50.0},
|
||
{"width": 2456, "height": 1536, "refresh_rate": 74.935},
|
||
{"width": 2560, "height": 1080, "refresh_rate": 60.0},
|
||
{"width": 2560, "height": 1080, "refresh_rate": 60.0, "note": "RB1"},
|
||
{"width": 2560, "height": 1080, "refresh_rate": 144.051, "note": "RB3"},
|
||
{"width": 2560, "height": 1080, "refresh_rate": 200.07, "note": "RB3"},
|
||
{"width": 2560, "height": 1440, "refresh_rate": 60.0, "note": "RB1"},
|
||
{"width": 2560, "height": 1440, "refresh_rate": 60.0, "note": "RB2"},
|
||
{"width": 2560, "height": 1440, "refresh_rate": 144.05, "note": "RB3"},
|
||
{"width": 2560, "height": 1440, "refresh_rate": 200.07, "note": "RB3"},
|
||
{"width": 2560, "height": 1920, "refresh_rate": 74.979},
|
||
{"width": 2728, "height": 1536, "refresh_rate": 59.944},
|
||
{"width": 3440, "height": 1440, "refresh_rate": 60.0},
|
||
{"width": 3440, "height": 1440, "refresh_rate": 60.0, "note": "RB1"},
|
||
{"width": 3440, "height": 1440, "refresh_rate": 60.0, "note": "RB2"},
|
||
{"width": 3440, "height": 1440, "refresh_rate": 120.0},
|
||
{"width": 3440, "height": 1440, "refresh_rate": 120.0, "note": "RB1"},
|
||
{"width": 3440, "height": 1440, "refresh_rate": 120.0, "note": "RB2"},
|
||
{"width": 3440, "height": 1440, "refresh_rate": 165.0, "note": "RB1"},
|
||
{"width": 3440, "height": 1440, "refresh_rate": 165.0, "note": "RB2"},
|
||
{"width": 3440, "height": 1440, "refresh_rate": 200.0, "note": "RB1"},
|
||
{"width": 3440, "height": 1440, "refresh_rate": 200.0, "note": "RB2"},
|
||
{"width": 3840, "height": 2160, "refresh_rate": 30.0, "note": "RB1"},
|
||
{"width": 3840, "height": 2160, "refresh_rate": 30.0, "note": "RB2"},
|
||
{"width": 3840, "height": 2160, "refresh_rate": 60.0, "note": "RB1"},
|
||
{"width": 3840, "height": 2160, "refresh_rate": 60.0, "note": "RB2"},
|
||
{"width": 3840, "height": 2160, "refresh_rate": 60.021, "note": "RB3"},
|
||
{"width": 3840, "height": 2160, "refresh_rate": 120.0, "note": "RB1"},
|
||
{"width": 3840, "height": 2160, "refresh_rate": 120.0, "note": "RB2"},
|
||
{"width": 4096, "height": 2160, "refresh_rate": 60.0, "note": "RB1"},
|
||
{"width": 4096, "height": 2160, "refresh_rate": 60.0, "note": "RB2"},
|
||
{"width": 4096, "height": 2160, "refresh_rate": 60.021, "note": "RB3"},
|
||
]
|
||
}
|
||
|
||
# OVT分辨率ID映射
|
||
ovt_resolution_map = {
|
||
0: [
|
||
{"width": 768, "height": 480, "refresh_rate": 85.0},
|
||
{"width": 1024, "height": 640, "refresh_rate": 60.0},
|
||
{"width": 1152, "height": 720, "refresh_rate": 75.0},
|
||
{"width": 1280, "height": 768, "refresh_rate": 60.0},
|
||
{"width": 1280, "height": 960, "refresh_rate": 60.0},
|
||
{"width": 1440, "height": 240, "refresh_rate": 60.0},
|
||
{"width": 1440, "height": 480, "refresh_rate": 60.0},
|
||
{"width": 1440, "height": 900, "refresh_rate": 60.0},
|
||
{"width": 1536, "height": 960, "refresh_rate": 85.0},
|
||
{"width": 1920, "height": 1080, "refresh_rate": 30.0},
|
||
{"width": 1920, "height": 1080, "refresh_rate": 60.0},
|
||
{"width": 1920, "height": 1080, "refresh_rate": 85.0},
|
||
{"width": 1920, "height": 1080, "refresh_rate": 100.0},
|
||
{"width": 1920, "height": 1080, "refresh_rate": 120.0},
|
||
{"width": 1920, "height": 1440, "refresh_rate": 60.0},
|
||
{"width": 2048, "height": 1280, "refresh_rate": 60.0},
|
||
{"width": 2048, "height": 1536, "refresh_rate": 60.0},
|
||
{"width": 2128, "height": 1200, "refresh_rate": 60.0},
|
||
{"width": 2456, "height": 1536, "refresh_rate": 50.0},
|
||
{"width": 2456, "height": 1536, "refresh_rate": 75.0},
|
||
{"width": 2560, "height": 1080, "refresh_rate": 30.0},
|
||
{"width": 2560, "height": 1080, "refresh_rate": 60.0},
|
||
{"width": 2560, "height": 1080, "refresh_rate": 120.0},
|
||
{"width": 2560, "height": 1600, "refresh_rate": 60.0},
|
||
{"width": 2560, "height": 1920, "refresh_rate": 75.0},
|
||
{"width": 2728, "height": 1536, "refresh_rate": 60.0},
|
||
{"width": 3840, "height": 2160, "refresh_rate": 30.0},
|
||
{"width": 3840, "height": 2160, "refresh_rate": 60.0},
|
||
{"width": 3840, "height": 2160, "refresh_rate": 120.0},
|
||
{"width": 4096, "height": 2160, "refresh_rate": 30.0},
|
||
],
|
||
1: [
|
||
{"width": 1280, "height": 720, "refresh_rate": 24.0},
|
||
{"width": 1280, "height": 720, "refresh_rate": 120.0},
|
||
],
|
||
4: [
|
||
{"width": 1920, "height": 1080, "refresh_rate": 144.0},
|
||
{"width": 1920, "height": 1080, "refresh_rate": 240.0},
|
||
],
|
||
}
|
||
|
||
# 根据分辨率类型和ID获取分辨率信息的函数
|
||
@staticmethod
|
||
def get_resolution_info(resolution_type, resolution_id):
|
||
"""
|
||
根据分辨率类型和ID获取分辨率信息
|
||
|
||
Args:
|
||
resolution_type: 分辨率类型,可以是DMT、CTA、CVT或OVT
|
||
resolution_id: 分辨率ID
|
||
|
||
Returns:
|
||
包含分辨率信息的字典,如果未找到则返回None
|
||
"""
|
||
if resolution_type == UCDEnum.ResolutionType.DMT:
|
||
return UCDEnum.dmt_resolution_map.get(resolution_id)
|
||
elif resolution_type == UCDEnum.ResolutionType.CTA:
|
||
return UCDEnum.cta_resolution_map.get(resolution_id)
|
||
elif resolution_type == UCDEnum.ResolutionType.CVT:
|
||
resolutions = UCDEnum.cvt_resolution_map.get(resolution_id, [])
|
||
return resolutions[0] if resolutions else None
|
||
elif resolution_type == UCDEnum.ResolutionType.OVT:
|
||
resolutions = UCDEnum.ovt_resolution_map.get(resolution_id, [])
|
||
return resolutions[0] if resolutions else None
|
||
return None
|
||
|
||
@staticmethod
|
||
def get_formatted_resolution_list():
|
||
"""
|
||
从分辨率映射中生成格式化的分辨率字符串列表,用于UI显示
|
||
格式为: "类型 宽度x 高度 @ 刷新率Hz"
|
||
|
||
Returns:
|
||
包含格式化分辨率字符串的列表
|
||
"""
|
||
formatted_list = []
|
||
|
||
# 添加DMT分辨率
|
||
for res_id, res_info in UCDEnum.TimingInfo.dmt_resolution_map.items():
|
||
formatted_str = f"DMT {res_info['width']}x {res_info['height']} @ {int(res_info['refresh_rate'])}Hz"
|
||
formatted_list.append(formatted_str)
|
||
|
||
# 添加CTA分辨率
|
||
for res_id, res_info in UCDEnum.TimingInfo.cta_resolution_map.items():
|
||
formatted_str = f"CTA {res_info['width']}x {res_info['height']} @ {int(res_info['refresh_rate'])}Hz"
|
||
formatted_list.append(formatted_str)
|
||
|
||
# 添加CVT分辨率 (只取每个ID的第一个)
|
||
for res_id, res_list in UCDEnum.TimingInfo.cvt_resolution_map.items():
|
||
for res_info in res_list:
|
||
note = f" {res_info.get('note', '')}" if "note" in res_info else ""
|
||
formatted_str = f"CVT {res_info['width']}x {res_info['height']} @ {int(res_info['refresh_rate'])}Hz{note}"
|
||
formatted_list.append(formatted_str)
|
||
|
||
# 添加OVT分辨率 (只取每个ID的第一个)
|
||
for res_id, res_list in UCDEnum.TimingInfo.ovt_resolution_map.items():
|
||
for res_info in res_list:
|
||
formatted_str = f"OVT {res_info['width']}x {res_info['height']} @ {int(res_info['refresh_rate'])}Hz"
|
||
formatted_list.append(formatted_str)
|
||
|
||
# 排序并去重
|
||
return sorted(list(set(formatted_list)))
|
||
|
||
class SignalFormat:
|
||
"""信号格式相关枚举"""
|
||
|
||
class GammaType:
|
||
"""Gamma 类型枚举"""
|
||
|
||
GAMMA_22 = "2.2"
|
||
GAMMA_24 = "2.4"
|
||
GAMMA_26 = "2.6"
|
||
|
||
@staticmethod
|
||
def get_list():
|
||
return [
|
||
SignalFormat.GammaType.GAMMA_22,
|
||
SignalFormat.GammaType.GAMMA_24,
|
||
SignalFormat.GammaType.GAMMA_26,
|
||
]
|
||
|
||
@staticmethod
|
||
def get_gamma_value(gamma_str):
|
||
"""将 Gamma 字符串转换为数值"""
|
||
gamma_map = {"2.2": 2.2, "2.4": 2.4, "2.6": 2.6}
|
||
return gamma_map.get(gamma_str, 2.2)
|
||
|
||
class DataRange:
|
||
"""数据范围枚举"""
|
||
|
||
FULL = "Full"
|
||
LIMITED = "Limited"
|
||
|
||
@staticmethod
|
||
def get_list():
|
||
return [SignalFormat.DataRange.FULL, SignalFormat.DataRange.LIMITED]
|
||
|
||
@staticmethod
|
||
def is_full_range(range_str):
|
||
"""判断是否为 Full Range"""
|
||
return range_str == SignalFormat.DataRange.FULL
|
||
|
||
class BitDepth:
|
||
"""编码位深枚举"""
|
||
|
||
BIT_8 = "8bit"
|
||
BIT_10 = "10bit"
|
||
BIT_12 = "12bit"
|
||
|
||
@staticmethod
|
||
def get_list():
|
||
return [
|
||
SignalFormat.BitDepth.BIT_8,
|
||
SignalFormat.BitDepth.BIT_10,
|
||
SignalFormat.BitDepth.BIT_12,
|
||
]
|
||
|
||
@staticmethod
|
||
def get_bit_value(bit_str):
|
||
"""将位深字符串转换为数值"""
|
||
bit_map = {"8bit": 8, "10bit": 10, "12bit": 12}
|
||
return bit_map.get(bit_str, 8)
|
||
|
||
class HDRMetadata:
|
||
"""HDR Metadata 参数"""
|
||
|
||
# MaxCLL (Maximum Content Light Level) - 最大内容亮度级别
|
||
MAX_CLL_DEFAULT = 1000
|
||
MAX_CLL_OPTIONS = [400, 600, 800, 1000, 1200, 1500, 2000, 4000]
|
||
|
||
# MaxFALL (Maximum Frame Average Light Level) - 最大帧平均亮度级别
|
||
MAX_FALL_DEFAULT = 400
|
||
MAX_FALL_OPTIONS = [200, 300, 400, 500, 600, 800, 1000]
|
||
|
||
@staticmethod
|
||
def get_maxcll_list():
|
||
return SignalFormat.HDRMetadata.MAX_CLL_OPTIONS
|
||
|
||
@staticmethod
|
||
def get_maxfall_list():
|
||
return SignalFormat.HDRMetadata.MAX_FALL_OPTIONS
|