player: fix SDL_UpdateNVTexture ctypes cast — cast c_char_Array to LP_c_ubyte
This commit is contained in:
@@ -244,8 +244,11 @@ class GStreamerBackend(PlayerBackend):
|
||||
if frame.pixel_format == "NV12" and frame.uv_pixels is not None:
|
||||
# Zero-copy NV12 path: upload Y and UV planes separately.
|
||||
# SDL_UpdateNVTexture avoids a full BGRA conversion on CPU.
|
||||
y_buf = ctypes.create_string_buffer(frame.pixels)
|
||||
uv_buf = ctypes.create_string_buffer(frame.uv_pixels)
|
||||
# ctypes.create_string_buffer returns c_char_Array_N; cast to
|
||||
# LP_c_ubyte which SDL_UpdateNVTexture requires.
|
||||
_ubyte_p = ctypes.POINTER(ctypes.c_ubyte)
|
||||
y_buf = ctypes.cast(ctypes.create_string_buffer(frame.pixels), _ubyte_p)
|
||||
uv_buf = ctypes.cast(ctypes.create_string_buffer(frame.uv_pixels), _ubyte_p)
|
||||
result = sdl2.SDL_UpdateNVTexture(
|
||||
self._texture, None,
|
||||
y_buf, frame.pitch,
|
||||
|
||||
Reference in New Issue
Block a user