Skip to content

Commit

Permalink
#3837 add plane range dump utility function
Browse files Browse the repository at this point in the history
  • Loading branch information
totaam committed Jun 4, 2024
1 parent 69553c9 commit de30f80
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
4 changes: 3 additions & 1 deletion xpra/codecs/argb/argb.pxd
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
# This file is part of Xpra.
# Copyright (C) 2008, 2009 Nathaniel Smith <njs@pobox.com>
# Copyright (C) 2013-2021 Antoine Martin <antoine@xpra.org>
# Copyright (C) 2013-2024 Antoine Martin <antoine@xpra.org>
# Xpra is released under the terms of the GNU GPL v2, or, at your option, any
# later version. See the file COPYING for details.

cdef argbdata_to_rgba(const unsigned int* argb, const int argb_len) #pylint: disable=syntax-error
cdef argbdata_to_rgb(const unsigned int* argb, const int argb_len)
cdef bgradata_to_rgb(const unsigned int* bgra, const int bgra_len)
cdef bgradata_to_rgba(const unsigned int* bgra, const int bgra_len)

cdef show_plane_range(name, plane, int width, int stride, int height)
17 changes: 17 additions & 0 deletions xpra/codecs/argb/argb.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -776,3 +776,20 @@ cdef bitdata_to_rectangles(const unsigned char* bitdata, const int bitdata_len,
if start<end:
rectangles.append((start, y, end-start, 1))
return rectangles


cdef show_plane_range(name, plane, int width, int stride, int height):
cdef unsigned char minv = 255
cdef unsigned char maxv = 0
cdef unsigned char value
cdef const unsigned char *plane_buf
with buffer_context(plane) as buf:
plane_buf = <unsigned char *> (<uintptr_t> int(buf))
for y in range(height):
for x in range(width):
value = plane_buf[y*stride + x]
if value < minv:
minv = value
if value > maxv:
maxv = value
log.info("%s plane: min=%s, max=%s", name, minv, maxv)

0 comments on commit de30f80

Please sign in to comment.