xpra icon
Bug tracker and wiki

Ticket #410: video-subregion-client.patch

File video-subregion-client.patch, 4.9 KB (added by Antoine Martin, 6 years ago)

allows clients to process video sub-regions

  • xpra/client/gl/gl_window_backing.py

     
    512512            fire_paint_callbacks(callbacks, False)
    513513
    514514    def update_planar_textures(self, x, y, width, height, img, pixel_format, scaling=False):
    515         assert x==0 and y==0
    516515        assert self.textures is not None, "no OpenGL textures!"
    517516        log("%s.update_planar_textures%s", self, (x, y, width, height, img, pixel_format))
    518517
     
    539538
    540539
    541540        self.gl_marker("updating planar textures: %sx%s %s" % (width, height, pixel_format))
    542         U_width = 0
    543         U_height = 0
    544541        rowstrides = img.get_rowstride()
    545542        img_data = img.get_pixels()
    546         assert len(rowstrides)==3
    547         assert len(img_data)==3
     543        assert len(rowstrides)==3 and len(img_data)==3
    548544        for texture, index in ((GL_TEXTURE0, 0), (GL_TEXTURE1, 1), (GL_TEXTURE2, 2)):
    549545            (div_w, div_h) = divs[index]
    550546            glActiveTexture(texture)
     
    552548            glPixelStorei(GL_UNPACK_ROW_LENGTH, rowstrides[index])
    553549            pixel_data = img_data[index]
    554550            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))
    555             glTexSubImage2D(GL_TEXTURE_RECTANGLE_ARB, 0, x, y, width/div_w, height/div_h, GL_LUMINANCE, GL_UNSIGNED_BYTE, pixel_data)
    556             if index == 1:
    557                 U_width = width/div_w
    558                 U_height = height/div_h
    559             elif index == 2:
    560                 if width/div_w != U_width:
    561                     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)
    562                 if height/div_h != U_height:
    563                     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)
     551            glTexSubImage2D(GL_TEXTURE_RECTANGLE_ARB, 0, 0, 0, width/div_w, height/div_h, GL_LUMINANCE, GL_UNSIGNED_BYTE, pixel_data)
    564552
    565553    def render_planar_update(self, rx, ry, rw, rh, x_scale=1, y_scale=1):
    566554        log("%s.render_planar_update%s pixel_format=%s", self, (rx, ry, rw, rh, x_scale, y_scale), self.pixel_format)
     
    567555        if self.pixel_format not in ("YUV420P", "YUV422P", "YUV444P", "GBRP"):
    568556            #not ready to render yet
    569557            return
    570         assert rx==0 and ry==0
    571558        if self.pixel_format == "GBRP":
    572559            self.set_rgbP_paint_state()
    573560        self.gl_marker("painting planar update, format %s" % self.pixel_format)
     
    580567        tw, th = self.texture_size
    581568        log("%s.render_planar_update(..) texture_size=%s, size=%s", self, self.texture_size, self.size)
    582569        glBegin(GL_QUADS)
    583         for x,y in ((rx, ry), (rx, ry+rh), (rx+rw, ry+rh), (rx+rw, ry)):
     570        for x,y in ((0, 0), (0, rh), (rw, rh), (rw, 0)):
    584571            ax = min(tw, x)
    585572            ay = min(th, y)
    586573            for texture, index in ((GL_TEXTURE0, 0), (GL_TEXTURE1, 1), (GL_TEXTURE2, 2)):
    587574                (div_w, div_h) = divs[index]
    588575                glMultiTexCoord2i(texture, ax/div_w, ay/div_h)
    589             glVertex2i(int(ax*x_scale), int(ay*y_scale))
     576            glVertex2i(int(rx+ax*x_scale), int(ry+ay*y_scale))
    590577        glEnd()
    591578        if self.pixel_format == "GBRP":
    592579            self.unset_rgbP_paint_state()
  • xpra/client/ui_client_base.py

     
    683683            "encoding_client_options"   : True,
    684684            "encoding.csc_atoms"        : True,
    685685            #TODO: check for csc support (swscale only?)
     686            "encoding.video_subregion"  : True,
    686687            "encoding.video_reinit"     : True,
    687688            "encoding.video_scaling"    : True,
    688689            "encoding.rgb_lz4"          : use_lz4 and self.compression_level==1,
  • xpra/client/window_backing_base.py

     
    292292        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))
    293293
    294294    def paint_with_video_decoder(self, decoder_name, coding, img_data, x, y, width, height, options, callbacks):
    295         assert x==0 and y==0
    296295        decoder_module = get_codec(decoder_name)
    297296        assert decoder_module, "decoder module not found for %s" % decoder_name
    298297        assert hasattr(decoder_module, "Decoder"), "decoder module %s does not have 'Decoder' factory function!" % decoder_module