No more linting error of mypy in H264.
This commit is contained in:
+12
-10
@@ -104,9 +104,11 @@ def read_signed_exp_golomb(buf:bytes, bit_position: int) -> tuple[int, int]:
|
||||
return bit_position, -(v>>1)
|
||||
case 1:
|
||||
return bit_position, (v+1)>>1
|
||||
case _:
|
||||
raise AssertionError("unreachable")
|
||||
|
||||
@typechecked
|
||||
def write_bit(buf:bytes, bit_position: int, b) -> int:
|
||||
def write_bit(buf:bytearray, bit_position: int, b) -> int:
|
||||
buf_length = len(buf)
|
||||
byte_position = floor(bit_position/8)
|
||||
|
||||
@@ -120,7 +122,7 @@ def write_bit(buf:bytes, bit_position: int, b) -> int:
|
||||
return bit_position
|
||||
|
||||
@typechecked
|
||||
def write_boolean(buf:bytes, bit_position: int, b: bool) -> int:
|
||||
def write_boolean(buf:bytearray, bit_position: int, b: bool) -> int:
|
||||
if b:
|
||||
bit_position = write_bit(buf, bit_position, 1)
|
||||
else:
|
||||
@@ -128,7 +130,7 @@ def write_boolean(buf:bytes, bit_position: int, b: bool) -> int:
|
||||
return bit_position
|
||||
|
||||
@typechecked
|
||||
def write_bits(buf:bytes, bit_position: int, v, size) -> int:
|
||||
def write_bits(buf:bytearray, bit_position: int, v, size) -> int:
|
||||
for i in range(size-1,-1,-1):
|
||||
b = (v>>i)&1
|
||||
bit_position = write_bit(buf, bit_position, b)
|
||||
@@ -136,22 +138,22 @@ def write_bits(buf:bytes, bit_position: int, v, size) -> int:
|
||||
return bit_position
|
||||
|
||||
@typechecked
|
||||
def write_byte(buf:bytes, bit_position: int, v) -> int:
|
||||
def write_byte(buf:bytearray, bit_position: int, v) -> int:
|
||||
bit_position = write_bits(buf, bit_position, v, 8)
|
||||
return bit_position
|
||||
|
||||
@typechecked
|
||||
def write_word(buf:bytes, bit_position: int, v) -> int:
|
||||
def write_word(buf:bytearray, bit_position: int, v) -> int:
|
||||
bit_position = write_bits(buf, bit_position, v, 16)
|
||||
return bit_position
|
||||
|
||||
@typechecked
|
||||
def write_long(buf:bytes, bit_position: int, v) -> int:
|
||||
def write_long(buf:bytearray, bit_position: int, v) -> int:
|
||||
bit_position = write_bits(buf, bit_position, v, 32)
|
||||
return bit_position
|
||||
|
||||
@typechecked
|
||||
def write_unsigned_exp_golomb(buf:bytes, bit_position: int, v) -> int:
|
||||
def write_unsigned_exp_golomb(buf:bytearray, bit_position: int, v) -> int:
|
||||
n = floor(log(v+1)/log(2))+1
|
||||
# Write zeroes
|
||||
bit_position = write_bits(buf, bit_position, 0, n-1)
|
||||
@@ -161,7 +163,7 @@ def write_unsigned_exp_golomb(buf:bytes, bit_position: int, v) -> int:
|
||||
return bit_position
|
||||
|
||||
@typechecked
|
||||
def write_signed_exp_golomb(buf:bytes, bit_position: int, v) -> int:
|
||||
def write_signed_exp_golomb(buf:bytearray, bit_position: int, v) -> int:
|
||||
if v <= 0:
|
||||
bit_position = write_unsigned_exp_golomb(buf, bit_position, -v*2)
|
||||
else:
|
||||
@@ -182,7 +184,7 @@ def parse_rbsp_trailing_bits(buf:bytes, bit_position: int) -> int:
|
||||
return bit_position
|
||||
|
||||
@typechecked
|
||||
def write_rbsp_trailing_bits(buf:bytes, bit_position: int) -> int:
|
||||
def write_rbsp_trailing_bits(buf:bytearray, bit_position: int) -> int:
|
||||
bit_position = write_bit(buf, bit_position, 1)
|
||||
while bit_position%8 != 0:
|
||||
bit_position = write_bit(buf, bit_position, 0)
|
||||
@@ -265,7 +267,7 @@ def parse_scaling_list(buf:bytes, bit_position: int, size) -> tuple[int,list[int
|
||||
# The ISO/IEC H.264-201602 seems to take into account the case where the end of the deltas list
|
||||
# is full of zeroes.
|
||||
@typechecked
|
||||
def write_scaling_list(buf:bytes, bit_position: int, size, matrix:list[int],
|
||||
def write_scaling_list(buf:bytearray, bit_position: int, size, matrix:list[int],
|
||||
optimized: bool = False) -> int:
|
||||
logger.debug('Dumping matrix: %s of size: %d, size parameter: %d.', matrix, len(matrix), size)
|
||||
|
||||
|
||||
@@ -110,9 +110,9 @@ class VUI:
|
||||
time_scale:int=0
|
||||
fixed_frame_rate_flag:bool=False
|
||||
nal_hrd_parameters_present_flag:bool=False
|
||||
hrd_parameters:HRD=None
|
||||
hrd_parameters:HRD|None=None
|
||||
vcl_hrd_parameters_present_flag:bool=False
|
||||
vcl_hrd_parameters:HRD=None
|
||||
vcl_hrd_parameters:HRD|None=None
|
||||
low_delay_hrd_flag:bool=False
|
||||
pic_struct_present_flag:bool=False
|
||||
bitstream_restriction_flag:bool=False
|
||||
@@ -261,25 +261,25 @@ class SPS:
|
||||
log2_max_frame_num_minus4:int=0 # ue(v)
|
||||
pic_order_cnt_type:int=0 # ue(v)
|
||||
log2_max_pic_order_cnt_lsb_minus4:int=0 # ue(v)
|
||||
delta_pic_order_always_zero_flag:bool=False # ue(1)
|
||||
delta_pic_order_always_zero_flag:bool=False # ue(1)
|
||||
offset_for_non_ref_pic:int=0 # se(v)
|
||||
offset_for_top_to_bottom_field:int=0 # se(v)
|
||||
num_ref_frames_in_pic_order_cnt_cycle:int=0 # ue(v)
|
||||
offset_for_ref_frame:dict[int] = field(default_factory=dict)
|
||||
offset_for_ref_frame:dict[int,int] = field(default_factory=dict)
|
||||
max_num_ref_frames:int=9 # ue(v)
|
||||
gaps_in_frame_num_value_allowed_flag:bool=False # u(1)
|
||||
gaps_in_frame_num_value_allowed_flag:bool=False # u(1)
|
||||
pic_width_in_mbs_minus1:int=0 # ue(v)
|
||||
pic_height_in_map_units_minus1:int=0 # ue(v)
|
||||
frame_mbs_only_flag:bool=False # u(1)
|
||||
mb_adaptive_frame_field_flag:bool=False # u(1)
|
||||
direct_8x8_inference_flag:bool=False # u(1)
|
||||
frame_cropping_flag:bool=False # u(1)
|
||||
frame_mbs_only_flag:bool=False # u(1)
|
||||
mb_adaptive_frame_field_flag:bool=False # u(1)
|
||||
direct_8x8_inference_flag:bool=False # u(1)
|
||||
frame_cropping_flag:bool=False # u(1)
|
||||
frame_crop_left_offset:int=0 # ue(v)
|
||||
frame_crop_right_offset:int=0 # ue(v)
|
||||
frame_crop_top_offset:int=0 # ue(v)
|
||||
frame_crop_bottom_offset:int=0 # ue(v)
|
||||
vui_parameters_present_flag:bool=False # u(1)
|
||||
vui:VUI=None # VUI object
|
||||
vui_parameters_present_flag:bool=False # u(1)
|
||||
vui:VUI|None=None # VUI object
|
||||
|
||||
def __init__(self):
|
||||
self.scaling_list={}
|
||||
|
||||
Reference in New Issue
Block a user