From 700d1fedc55c86f39996e0162a0b6a539b017ddd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Tronel?= Date: Fri, 28 Aug 2026 23:09:02 +0200 Subject: [PATCH] Fixing type error. --- src/tscut/h264/avc.py | 16 +++++++++------- src/tscut/matroska/ebml.py | 2 ++ 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/src/tscut/h264/avc.py b/src/tscut/h264/avc.py index 125728b..518129a 100644 --- a/src/tscut/h264/avc.py +++ b/src/tscut/h264/avc.py @@ -307,15 +307,15 @@ def get_avc_config_from_h264(input_file: IO[bytes]) -> AVCDecoderConfiguration: return avcconfig # Unused ? -@typechecked -def get_codec_private_data_from_h264(input_file: IO[bytes]) -> AVCDecoderConfiguration: - avcconfig = get_avc_config_from_h264(input_file) - res = dump_codec_private_data(avcconfig) - - return res +# @typechecked +# def get_codec_private_data_from_h264(input_file: IO[bytes]) -> AVCDecoderConfiguration: +# avcconfig = get_avc_config_from_h264(input_file) +# res = dump_codec_private_data(avcconfig) +# +# return res @typechecked -def dump_codec_private_data(avc_decoder_configuration: AVCDecoderConfiguration) -> bytearray: +def dump_codec_private_data(avc_decoder_configuration: AVCDecoderConfiguration) -> bytearray | None: # Rebuild a Matroska Codec Private Element res = bytearray() # Code private element @@ -325,6 +325,8 @@ def dump_codec_private_data(avc_decoder_configuration: AVCDecoderConfiguration) len(buf)) embl_length = get_ebml_length(len(buf)) + if embl_length is None: + return None logger.debug('EMBL encoded length: %s', hexdump.dump(embl_length, sep=':')) res.extend(embl_length) res.extend(buf) diff --git a/src/tscut/matroska/ebml.py b/src/tscut/matroska/ebml.py index 78b54db..5cebb96 100644 --- a/src/tscut/matroska/ebml.py +++ b/src/tscut/matroska/ebml.py @@ -130,6 +130,8 @@ def change_ebml_element_size(input_file: IO[bytes], position:int, addendum:int) if new_size > max_size: # TODO: Test this code ... new_encoded_size = get_ebml_length(new_size) + if new_encoded_size is None: + raise ValueError() size_of_new_encoded_size = len(new_encoded_size) if size_of_new_encoded_size <= size_of_data_size: logger.error('New encoded size is smaller (%d) or equal than previous size (%d).\