Files
pqAutomationApp/UniTAP/utils/dscl_api.py
xinzhu.yin c157e774e5 1.1.0版本
2026-04-16 16:51:05 +08:00

57 lines
1.6 KiB
Python

from UniTAP.libs.lib_dscl.dscl_utils import encode_vf, decode_vf, dscl_image_calculate_crc, dscl_data_processing, calculate_slice_size
from UniTAP.common import VideoFrame, VideoFrameDSC, CompressionInfo
def encode_video_frame(src_video_frame: VideoFrame, info: CompressionInfo) -> VideoFrameDSC:
"""
Encode custom video frame `VideoFrame` with transferred DSC parameters to video frame with DSC data.
Args:
src_video_frame (`VideoFrame`)
info (`CompressionInfo`)
"""
return encode_vf(src_video_frame, info)
def decode_video_frame(src_video_frame: VideoFrameDSC) -> VideoFrame:
"""
Decode custom video frame `VideoFrameDSC` with DSC data.
Args:
src_video_frame (`VideoFrame`)
"""
return decode_vf(src_video_frame)
def dsc_video_frame_from_data(data: bytearray) -> VideoFrameDSC:
"""
Read PPS from DSC video frame data `VideoFrameDSC`.
Args:
data (`bytearray`)
"""
return dscl_data_processing(data)
def calculate_dsc_crc(video_frame: VideoFrameDSC) -> tuple:
"""
Calculate DSC CRC by DSC Video Frame.
Args:
video_frame ('VideoFrameDSC')
"""
if not isinstance(video_frame, VideoFrameDSC):
raise TypeError("Calculate DSC crc accept only VideoFrameDSC object!")
return dscl_image_calculate_crc(video_frame)
def calculate_dsc_slice_size(value: int, slice_number: int):
"""
Calculate DSC slice size by value and slice number.
Args:
value ('int')
slice_number ('int')
"""
return int(calculate_slice_size(value, slice_number))