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)
|
return bit_position, -(v>>1)
|
||||||
case 1:
|
case 1:
|
||||||
return bit_position, (v+1)>>1
|
return bit_position, (v+1)>>1
|
||||||
|
case _:
|
||||||
|
raise AssertionError("unreachable")
|
||||||
|
|
||||||
@typechecked
|
@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)
|
buf_length = len(buf)
|
||||||
byte_position = floor(bit_position/8)
|
byte_position = floor(bit_position/8)
|
||||||
|
|
||||||
@@ -120,7 +122,7 @@ def write_bit(buf:bytes, bit_position: int, b) -> int:
|
|||||||
return bit_position
|
return bit_position
|
||||||
|
|
||||||
@typechecked
|
@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:
|
if b:
|
||||||
bit_position = write_bit(buf, bit_position, 1)
|
bit_position = write_bit(buf, bit_position, 1)
|
||||||
else:
|
else:
|
||||||
@@ -128,7 +130,7 @@ def write_boolean(buf:bytes, bit_position: int, b: bool) -> int:
|
|||||||
return bit_position
|
return bit_position
|
||||||
|
|
||||||
@typechecked
|
@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):
|
for i in range(size-1,-1,-1):
|
||||||
b = (v>>i)&1
|
b = (v>>i)&1
|
||||||
bit_position = write_bit(buf, bit_position, b)
|
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
|
return bit_position
|
||||||
|
|
||||||
@typechecked
|
@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)
|
bit_position = write_bits(buf, bit_position, v, 8)
|
||||||
return bit_position
|
return bit_position
|
||||||
|
|
||||||
@typechecked
|
@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)
|
bit_position = write_bits(buf, bit_position, v, 16)
|
||||||
return bit_position
|
return bit_position
|
||||||
|
|
||||||
@typechecked
|
@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)
|
bit_position = write_bits(buf, bit_position, v, 32)
|
||||||
return bit_position
|
return bit_position
|
||||||
|
|
||||||
@typechecked
|
@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
|
n = floor(log(v+1)/log(2))+1
|
||||||
# Write zeroes
|
# Write zeroes
|
||||||
bit_position = write_bits(buf, bit_position, 0, n-1)
|
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
|
return bit_position
|
||||||
|
|
||||||
@typechecked
|
@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:
|
if v <= 0:
|
||||||
bit_position = write_unsigned_exp_golomb(buf, bit_position, -v*2)
|
bit_position = write_unsigned_exp_golomb(buf, bit_position, -v*2)
|
||||||
else:
|
else:
|
||||||
@@ -182,7 +184,7 @@ def parse_rbsp_trailing_bits(buf:bytes, bit_position: int) -> int:
|
|||||||
return bit_position
|
return bit_position
|
||||||
|
|
||||||
@typechecked
|
@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)
|
bit_position = write_bit(buf, bit_position, 1)
|
||||||
while bit_position%8 != 0:
|
while bit_position%8 != 0:
|
||||||
bit_position = write_bit(buf, bit_position, 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
|
# The ISO/IEC H.264-201602 seems to take into account the case where the end of the deltas list
|
||||||
# is full of zeroes.
|
# is full of zeroes.
|
||||||
@typechecked
|
@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:
|
optimized: bool = False) -> int:
|
||||||
logger.debug('Dumping matrix: %s of size: %d, size parameter: %d.', matrix, len(matrix), size)
|
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
|
time_scale:int=0
|
||||||
fixed_frame_rate_flag:bool=False
|
fixed_frame_rate_flag:bool=False
|
||||||
nal_hrd_parameters_present_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_present_flag:bool=False
|
||||||
vcl_hrd_parameters:HRD=None
|
vcl_hrd_parameters:HRD|None=None
|
||||||
low_delay_hrd_flag:bool=False
|
low_delay_hrd_flag:bool=False
|
||||||
pic_struct_present_flag:bool=False
|
pic_struct_present_flag:bool=False
|
||||||
bitstream_restriction_flag:bool=False
|
bitstream_restriction_flag:bool=False
|
||||||
@@ -265,7 +265,7 @@ class SPS:
|
|||||||
offset_for_non_ref_pic:int=0 # se(v)
|
offset_for_non_ref_pic:int=0 # se(v)
|
||||||
offset_for_top_to_bottom_field: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)
|
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)
|
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_width_in_mbs_minus1:int=0 # ue(v)
|
||||||
@@ -279,7 +279,7 @@ class SPS:
|
|||||||
frame_crop_top_offset:int=0 # ue(v)
|
frame_crop_top_offset:int=0 # ue(v)
|
||||||
frame_crop_bottom_offset:int=0 # ue(v)
|
frame_crop_bottom_offset:int=0 # ue(v)
|
||||||
vui_parameters_present_flag:bool=False # u(1)
|
vui_parameters_present_flag:bool=False # u(1)
|
||||||
vui:VUI=None # VUI object
|
vui:VUI|None=None # VUI object
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.scaling_list={}
|
self.scaling_list={}
|
||||||
|
|||||||
Reference in New Issue
Block a user