diff options
author | Tomi Valkeinen <tomi.valkeinen@ideasonboard.com> | 2022-05-30 17:27:13 +0300 |
---|---|---|
committer | Laurent Pinchart <laurent.pinchart@ideasonboard.com> | 2022-06-01 12:09:02 +0300 |
commit | fbd6c4d1c8bfedf49ed86b32fb7b8c0d0aee67fb (patch) | |
tree | 8061bed2804e783c8e1aa113f64e0a49a0d9b49b /src/py/libcamera/utils | |
parent | e8317de05ce62e5e7ccdef3d18a76ecd590e9ef6 (diff) |
py: Implement FrameBufferPlane
Implement FrameBufferPlane class and adjust the methods and uses
accordingly.
Note that we don't expose the fd as a SharedFD, but as an int.
Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Diffstat (limited to 'src/py/libcamera/utils')
-rw-r--r-- | src/py/libcamera/utils/MappedFrameBuffer.py | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/src/py/libcamera/utils/MappedFrameBuffer.py b/src/py/libcamera/utils/MappedFrameBuffer.py index fc2726b6..a8502d51 100644 --- a/src/py/libcamera/utils/MappedFrameBuffer.py +++ b/src/py/libcamera/utils/MappedFrameBuffer.py @@ -21,8 +21,8 @@ class MappedFrameBuffer: bufinfos = {} - for i in range(fb.num_planes): - fd = fb.fd(i) + for plane in fb.planes: + fd = plane.fd if fd not in bufinfos: buflen = os.lseek(fd, 0, os.SEEK_END) @@ -30,11 +30,11 @@ class MappedFrameBuffer: else: buflen = bufinfos[fd]['buflen'] - if fb.offset(i) > buflen or fb.offset(i) + fb.length(i) > buflen: + if plane.offset > buflen or plane.offset + plane.length > buflen: raise RuntimeError(f'plane is out of buffer: buffer length={buflen}, ' + - f'plane offset={fb.offset(i)}, plane length={fb.length(i)}') + f'plane offset={plane.offset}, plane length={plane.length}') - bufinfos[fd]['maplen'] = max(bufinfos[fd]['maplen'], fb.offset(i) + fb.length(i)) + bufinfos[fd]['maplen'] = max(bufinfos[fd]['maplen'], plane.offset + plane.length) # mmap the buffers @@ -51,14 +51,14 @@ class MappedFrameBuffer: planes = [] - for i in range(fb.num_planes): - fd = fb.fd(i) + for plane in fb.planes: + fd = plane.fd info = bufinfos[fd] mv = memoryview(info['map']) - start = fb.offset(i) - end = fb.offset(i) + fb.length(i) + start = plane.offset + end = plane.offset + plane.length mv = mv[start:end] |