Files
pqAutomationApp/UniTAP/common/data_info.py

64 lines
1.6 KiB
Python
Raw Normal View History

2026-04-16 16:51:05 +08:00
from enum import IntEnum
class DataInfo:
"""
Class contains information of frame `Packing`, `ComponentOrder`, `Alignment`.
"""
class Packing(IntEnum):
"""
Contains values of possible packing.
"""
P_UNKNOWN = 0
P_PLANAR = 1
P_PACKED = 2
class ComponentOrder(IntEnum):
"""
Contains values of possible component order.
"""
CO_UNKNOWN = 0
CO_UCDRX = 1
CO_RGB = 2
CO_RGBA = 3
CO_BGR = 4
CO_BGRA = 5
CO_YCbCr = 6
CO_CbY0CrY1 = 7
class Alignment(IntEnum):
"""
Contains values of possible alignment.
"""
A_UNKNOWN = 0
A_MSB = 1
A_LSB = 2
def __init__(self):
self.packing = self.Packing.P_UNKNOWN
self.component_order = self.ComponentOrder.CO_UNKNOWN
self.alignment = self.Alignment.A_UNKNOWN
def is_valid(self) -> bool:
"""
Check that information is valid (not equal UNKNOWN state).
Returns:
object of bool type.
"""
return self.packing != self.Packing.P_UNKNOWN and\
self.component_order != self.ComponentOrder.CO_UNKNOWN and\
self.alignment != self.Alignment.A_UNKNOWN
def __str__(self):
return f"Packing: {self.packing.name}\n" \
f"Component Order: {self.component_order.name}\n" \
f"Alignment: {self.alignment.name}\n"
def __eq__(self, other):
return self.packing == other.packing and \
self.component_order == other.component_order and \
self.alignment == other.alignment