Skip to content

Commit

Permalink
refactor: update black formatting, because line limit changed
Browse files Browse the repository at this point in the history
  • Loading branch information
senyai committed Jan 3, 2025
1 parent b6b770e commit 4422744
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 6 deletions.
8 changes: 6 additions & 2 deletions python/videoreader/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,9 @@ def seek_get_img(self, seek_idx: int) -> T | None:

def set(self, arguments: list[str]) -> None:
argv_keepalive = [ffi.new("char[]", arg.encode()) for arg in arguments]
if backend.videoreader_set(self._handler, argv_keepalive, len(argv_keepalive)):
if backend.videoreader_set(
self._handler, argv_keepalive, len(argv_keepalive)
):
raise_error()


Expand Down Expand Up @@ -187,7 +189,9 @@ def videoreader_n_frames(uri: str) -> int:
Get number of frames in a file
"""
handler = ffi.new("struct videoreader **")
backend.videoreader_create(handler, uri.encode("utf-8"), [], 0, ffi.NULL, ffi.NULL)
backend.videoreader_create(
handler, uri.encode("utf-8"), [], 0, ffi.NULL, ffi.NULL
)
n_frames = ffi.new("uint64_t *")
backend.videoreader_size(handler[0], n_frames)
backend.videoreader_delete(handler[0])
Expand Down
8 changes: 6 additions & 2 deletions python/videoreader/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@

def main():
parser = ArgumentParser()
default = Path(__file__).parents[2] / "test" / "big_buck_bunny_480p_1mb.mp4"
default = (
Path(__file__).parents[2] / "test" / "big_buck_bunny_480p_1mb.mp4"
)
parser.add_argument("uri", nargs="?", default=default)
parser.add_argument(
"--backend", choices=["base", "numpy", "minimg"], default="base"
Expand All @@ -18,7 +20,9 @@ def main():
case "base":
from . import VideoReaderBase as VideoReader

fmt_image = lambda image: f"{image.width}x{image.height}x{image.channels}"
fmt_image = (
lambda image: f"{image.width}x{image.height}x{image.channels}"
)

case "numpy":
from .numpy import VideoReaderNumpy as VideoReader
Expand Down
4 changes: 3 additions & 1 deletion python/videoreader/minimg.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@
@ffi.callback("void (VRImage*, void*)")
def alloc_callback_numpy(image: ffi.CData, self: ffi.CData) -> None:
assert image.scalar_type == 0, f"non uint8 images not yet supported"
img = MinImg.empty(image.width, image.height, image.channels, mintype=TYP_UINT8)
img = MinImg.empty(
image.width, image.height, image.channels, mintype=TYP_UINT8
)
image.data = img.data
image.stride = img.stride
address = int(ffi.cast("uintptr_t", image.data))
Expand Down
4 changes: 3 additions & 1 deletion python/videoreader/numpy.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@
def alloc_callback_numpy(image: ffi.CData, self: ffi.CData) -> None:
assert image.scalar_type == 0, f"non uint8 images not yet supported"
if image.channels == 3:
arr = np.empty((image.height, image.width, image.channels), dtype=np.uint8)
arr = np.empty(
(image.height, image.width, image.channels), dtype=np.uint8
)
ai = arr.__array_interface__
address = ai["data"][0]
assert (
Expand Down

0 comments on commit 4422744

Please sign in to comment.