@@ -21,7 +21,7 @@ supported_np_pix_fmts = {
2121 " gbrp14be" , " gbrp14le" , " gbrp16be" , " gbrp16le" , " gbrpf32be" , " gbrpf32le" , " gray" ,
2222 " gray16be" , " gray16le" , " gray8" , " grayf32be" , " grayf32le" , " nv12" , " pal8" , " rgb24" ,
2323 " rgb48be" , " rgb48le" , " rgb8" , " rgba" , " rgba64be" , " rgba64le" , " yuv420p" ,
24- " yuv422p10le" , " yuv444p" , " yuv444p16be" , " yuv444p16le" , " yuva444p16be" ,
24+ " yuv420p10le " , " yuv422p10le" , " yuv444p" , " yuv444p16be" , " yuv444p16le" , " yuva444p16be" ,
2525 " yuva444p16le" , " yuvj420p" , " yuvj444p" , " yuyv422" ,
2626}
2727
@@ -321,7 +321,7 @@ cdef class VideoFrame(Frame):
321321 import numpy as np
322322
323323 # check size
324- if frame.format.name in {" yuv420p" , " yuvj420p" , " yuyv422" , " yuv422p10le" }:
324+ if frame.format.name in {" yuv420p" , " yuvj420p" , " yuyv422" , " yuv420p10le " , " yuv422p10le" }:
325325 assert frame.width % 2 == 0 , " the width has to be even for this pixel format"
326326 assert frame.height % 2 == 0 , " the height has to be even for this pixel format"
327327
@@ -407,6 +407,16 @@ cdef class VideoFrame(Frame):
407407 useful_array(frame.planes[1 ]),
408408 useful_array(frame.planes[2 ]),
409409 ]).reshape(- 1 , frame.width)
410+ if frame.format.name == " yuv420p10le" :
411+ # Read planes as uint16:
412+ y = useful_array(frame.planes[0 ], 2 , " uint16" ).reshape(frame.height, frame.width)
413+ u = useful_array(frame.planes[1 ], 2 , " uint16" ).reshape(frame.height // 2 , frame.width // 2 )
414+ v = useful_array(frame.planes[2 ], 2 , " uint16" ).reshape(frame.height // 2 , frame.width // 2 )
415+ u_full = np.repeat(np.repeat(u, 2 , axis = 1 ), 2 , axis = 0 )
416+ v_full = np.repeat(np.repeat(u, 2 , axis = 1 ), 2 , axis = 0 )
417+ if channel_last:
418+ return np.stack([y, u_full, v_full], axis = 2 )
419+ return np.stack([y, u_full, v_full], axis = 0 )
410420 if frame.format.name == " yuv422p10le" :
411421 # Read planes as uint16 at their original width
412422 y = useful_array(frame.planes[0 ], 2 , " uint16" ).reshape(frame.height, frame.width)
0 commit comments