Skip to content

Commit

Permalink
Replace deprecated get_read/write_array calls with indexing
Browse files Browse the repository at this point in the history
This adds support for VSGAN on VS API 4 (at least so far during RC)
  • Loading branch information
rlaphoenix committed Oct 7, 2021
1 parent 2590e0f commit 8ac0550
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions vsgan/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ def frame_to_np(frame: vs.VideoFrame) -> np.dstack:
Alternative to cv2.imread() that will directly read images to a numpy array.
:param frame: VapourSynth frame from a clip
"""
return np.dstack([np.asarray(frame.get_read_array(i)) for i in range(frame.format.num_planes)])
return np.dstack([np.asarray(frame[i]) for i in range(frame.format.num_planes)])

@staticmethod
def np_to_frame(array: np.ndarray, frame: vs.VideoFrame, order: tuple = (2, 1, 0)) -> vs.VideoFrame:
Expand All @@ -201,7 +201,7 @@ def np_to_frame(array: np.ndarray, frame: vs.VideoFrame, order: tuple = (2, 1, 0
array = np.transpose(array[:, :, order], (0, 1, 2)) # `order` to RGB
for plane in range(array.shape[-1]):
np.copyto(
np.asarray(frame.get_write_array(plane)),
np.asarray(frame[plane]),
array[:, :, plane],
casting="unsafe"
)
Expand Down

0 comments on commit 8ac0550

Please sign in to comment.