improve performance for decoder collect

This commit is contained in:
henryruhs
2026-05-26 18:29:12 +02:00
parent 6eaabe123e
commit e813d7df95
2 changed files with 14 additions and 8 deletions
+7 -4
View File
@@ -46,7 +46,7 @@ def decode(aom_decoder : AomDecoder, input_buffer : bytes) -> Optional[AomPointe
def collect(address : int, frame_width : int, frame_height : int) -> bytes:
output_buffer = bytes()
output_parts = []
for index in range(3):
plane_pointer = ctypes.c_void_p.from_address(address + 64 + index * 8).value
@@ -54,10 +54,13 @@ def collect(address : int, frame_width : int, frame_height : int) -> bytes:
plane_width = frame_width >> (index > 0)
plane_height = frame_height >> (index > 0)
for row in range(plane_height):
output_buffer += ctypes.string_at(plane_pointer + row * stride, plane_width)
if stride == plane_width:
output_parts.append(ctypes.string_at(plane_pointer, plane_width * plane_height))
else:
for row in range(plane_height):
output_parts.append(ctypes.string_at(plane_pointer + row * stride, plane_width))
return output_buffer
return bytes().join(output_parts)
def destroy(aom_decoder : AomDecoder) -> None:
+7 -4
View File
@@ -45,7 +45,7 @@ def decode(vpx_decoder : VpxDecoder, input_buffer : bytes) -> Optional[VpxPointe
def collect(address : int, frame_width : int, frame_height : int) -> bytes:
output_buffer = bytes()
output_parts = []
for index in range(3):
plane_pointer = ctypes.c_void_p.from_address(address + 48 + index * 8).value
@@ -53,10 +53,13 @@ def collect(address : int, frame_width : int, frame_height : int) -> bytes:
plane_width = frame_width >> (index > 0)
plane_height = frame_height >> (index > 0)
for row in range(plane_height):
output_buffer += ctypes.string_at(plane_pointer + row * stride, plane_width)
if stride == plane_width:
output_parts.append(ctypes.string_at(plane_pointer, plane_width * plane_height))
else:
for row in range(plane_height):
output_parts.append(ctypes.string_at(plane_pointer + row * stride, plane_width))
return output_buffer
return bytes().join(output_parts)
def destroy(vpx_decoder : VpxDecoder) -> None: