Skip to content

Commit

Permalink
#410 support video regions client side: video data that is not necess…
Browse files Browse the repository at this point in the history
…arily at 0,0

* add "encoding.video_subregion" capability
* remove check in window backing base
* use offset in gl code (and remove pointless checks)

git-svn-id: https://xpra.org/svn/Xpra/trunk@5429 3bb7dfac-3a0b-4e04-842a-767bc560f471
  • Loading branch information
totaam committed Feb 11, 2014
1 parent e60745c commit 0027354
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 18 deletions.
21 changes: 4 additions & 17 deletions src/xpra/client/gl/gl_window_backing.py
Original file line number Diff line number Diff line change
Expand Up @@ -512,7 +512,6 @@ def gl_paint_planar(self, img, x, y, enc_width, enc_height, width, height, callb
fire_paint_callbacks(callbacks, False)

def update_planar_textures(self, x, y, width, height, img, pixel_format, scaling=False):
assert x==0 and y==0
assert self.textures is not None, "no OpenGL textures!"
log("%s.update_planar_textures%s", self, (x, y, width, height, img, pixel_format))

Expand All @@ -539,35 +538,23 @@ def update_planar_textures(self, x, y, width, height, img, pixel_format, scaling


self.gl_marker("updating planar textures: %sx%s %s" % (width, height, pixel_format))
U_width = 0
U_height = 0
rowstrides = img.get_rowstride()
img_data = img.get_pixels()
assert len(rowstrides)==3
assert len(img_data)==3
assert len(rowstrides)==3 and len(img_data)==3
for texture, index in ((GL_TEXTURE0, 0), (GL_TEXTURE1, 1), (GL_TEXTURE2, 2)):
(div_w, div_h) = divs[index]
glActiveTexture(texture)
glBindTexture(GL_TEXTURE_RECTANGLE_ARB, self.textures[index])
glPixelStorei(GL_UNPACK_ROW_LENGTH, rowstrides[index])
pixel_data = img_data[index]
log("texture %s: div=%s, rowstride=%s, %sx%s, data=%s bytes", index, divs[index], rowstrides[index], width/div_w, height/div_h, len(pixel_data))
glTexSubImage2D(GL_TEXTURE_RECTANGLE_ARB, 0, x, y, width/div_w, height/div_h, GL_LUMINANCE, GL_UNSIGNED_BYTE, pixel_data)
if index == 1:
U_width = width/div_w
U_height = height/div_h
elif index == 2:
if width/div_w != U_width:
log.error("Width of V plane is %d, differs from width of corresponding U plane (%d), pixel_format is %d", width/div_w, U_width, pixel_format)
if height/div_h != U_height:
log.error("Height of V plane is %d, differs from height of corresponding U plane (%d), pixel_format is %d", height/div_h, U_height, pixel_format)
glTexSubImage2D(GL_TEXTURE_RECTANGLE_ARB, 0, 0, 0, width/div_w, height/div_h, GL_LUMINANCE, GL_UNSIGNED_BYTE, pixel_data)

def render_planar_update(self, rx, ry, rw, rh, x_scale=1, y_scale=1):
log("%s.render_planar_update%s pixel_format=%s", self, (rx, ry, rw, rh, x_scale, y_scale), self.pixel_format)
if self.pixel_format not in ("YUV420P", "YUV422P", "YUV444P", "GBRP"):
#not ready to render yet
return
assert rx==0 and ry==0
if self.pixel_format == "GBRP":
self.set_rgbP_paint_state()
self.gl_marker("painting planar update, format %s" % self.pixel_format)
Expand All @@ -580,13 +567,13 @@ def render_planar_update(self, rx, ry, rw, rh, x_scale=1, y_scale=1):
tw, th = self.texture_size
log("%s.render_planar_update(..) texture_size=%s, size=%s", self, self.texture_size, self.size)
glBegin(GL_QUADS)
for x,y in ((rx, ry), (rx, ry+rh), (rx+rw, ry+rh), (rx+rw, ry)):
for x,y in ((0, 0), (0, rh), (rw, rh), (rw, 0)):
ax = min(tw, x)
ay = min(th, y)
for texture, index in ((GL_TEXTURE0, 0), (GL_TEXTURE1, 1), (GL_TEXTURE2, 2)):
(div_w, div_h) = divs[index]
glMultiTexCoord2i(texture, ax/div_w, ay/div_h)
glVertex2i(int(ax*x_scale), int(ay*y_scale))
glVertex2i(int(rx+ax*x_scale), int(ry+ay*y_scale))
glEnd()
if self.pixel_format == "GBRP":
self.unset_rgbP_paint_state()
1 change: 1 addition & 0 deletions src/xpra/client/ui_client_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -683,6 +683,7 @@ def make_hello(self):
"encoding_client_options" : True,
"encoding.csc_atoms" : True,
#TODO: check for csc support (swscale only?)
"encoding.video_subregion" : True,
"encoding.video_reinit" : True,
"encoding.video_scaling" : True,
"encoding.rgb_lz4" : use_lz4 and self.compression_level==1,
Expand Down
1 change: 0 additions & 1 deletion src/xpra/client/window_backing_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,6 @@ def make_csc(self, src_width, src_height, src_format,
raise Exception("no csc module found for %s(%sx%s) to %s(%sx%s) in %s" % (src_format, src_width, src_height, " or ".join(dst_format_options), dst_width, dst_height, CSC_OPTIONS))

def paint_with_video_decoder(self, decoder_name, coding, img_data, x, y, width, height, options, callbacks):
assert x==0 and y==0
decoder_module = get_codec(decoder_name)
assert decoder_module, "decoder module not found for %s" % decoder_name
assert hasattr(decoder_module, "Decoder"), "decoder module %s does not have 'Decoder' factory function!" % decoder_module
Expand Down

0 comments on commit 0027354

Please sign in to comment.