from typing import List
[docs]
class RDCurve:
def __init__(
self,
rates: List[float],
rate_unit: str,
distortions: List[float],
distortion_name: str,
distortion_unit: str,
codec_name: str,
title: str,
) -> None:
self.__rates = rates
self.__distortions = distortions
assert len(self.__rates) == len(self.__distortions)
self.__rate_unit = rate_unit
self.__distortion_name = distortion_name
self.__distortion_unit = distortion_unit
self.__codec_name = codec_name
self.__title = title
@property
def codec_name(self) -> str:
"""Gets the codec name.
:return: Codec name
:rtype: str
"""
return self.__codec_name
@property
def title(self) -> str:
"""Gets the curve title.
:return: Curve title
:rtype: str
"""
return self.__title
@property
def rate(self) -> List[float]:
"""Gets the rate values.
:return: List of rate values
:rtype: List[float]
"""
return self.__rates
@property
def distortion(self) -> List[float]:
"""Gets the distortion values.
:return: List of distortion values
:rtype: List[float]
"""
return self.__distortions
@property
def rate_unit(self) -> str:
"""Gets the rate unit.
:return: Rate unit string
:rtype: str
"""
return self.__rate_unit
@property
def distortion_unit(self) -> str:
"""Gets the distortion unit.
:return: Distortion unit string
:rtype: str
"""
return self.__distortion_unit
@property
def distortion_name(self) -> str:
"""Gets the distortion metric name.
:return: Distortion name
:rtype: str
"""
return self.__distortion_name
[docs]
def is_compatible(self, other: "RDCurve") -> bool:
"""Checks if this RD curve is compatible with another for comparison.
:param other: Other RD curve to compare
:type other: RDCurve
:return: True if curves have same rate unit, distortion name and unit
:rtype: bool
"""
if (
self.rate_unit == other.rate_unit
and self.distortion_name == other.distortion_name
and self.distortion_unit == other.distortion_unit
):
return True
return False
def __str__(self) -> str:
return f"RD curve ({self.rate_unit}x{self.distortion_name}): {list(zip(self.rate, self.distortion))}"