diff --git a/gnes/preprocessor/io_utils/gif.py b/gnes/preprocessor/io_utils/gif.py index 4e740ec8..24899db6 100644 --- a/gnes/preprocessor/io_utils/gif.py +++ b/gnes/preprocessor/io_utils/gif.py @@ -58,8 +58,8 @@ def capture_frames(input_fn: str = 'pipe:', if pix_fmt == 'rgba': depth = 4 - frames = np.frombuffer(out, - np.uint8).reshape([-1, height, width, depth]) + frames = np.frombuffer(out, np.uint8).copy() + frames = frames.reshape([-1, height, width, depth]) return frames diff --git a/gnes/preprocessor/io_utils/video.py b/gnes/preprocessor/io_utils/video.py index 7ace4b6a..6f71e866 100644 --- a/gnes/preprocessor/io_utils/video.py +++ b/gnes/preprocessor/io_utils/video.py @@ -219,8 +219,8 @@ def capture_frames(input_fn: str = 'pipe:', if pix_fmt == 'rgba': depth = 4 - frames = np.frombuffer(out, - np.uint8).reshape([-1, height, width, depth]) + frames = np.frombuffer(out, np.uint8).copy() + frames = frames.reshape([-1, height, width, depth]) return frames diff --git a/gnes/proto/__init__.py b/gnes/proto/__init__.py index 47f91380..6f531846 100644 --- a/gnes/proto/__init__.py +++ b/gnes/proto/__init__.py @@ -91,7 +91,8 @@ def blob2array(blob: 'gnes_pb2.NdArray') -> np.ndarray: """ Convert a blob proto to an array. """ - return np.frombuffer(blob.data, dtype=blob.dtype).reshape(blob.shape) + x = np.frombuffer(blob.data, dtype=blob.dtype).copy() + return x.reshape(blob.shape) def array2blob(x: np.ndarray) -> 'gnes_pb2.NdArray':