mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-17 22:06:41 +00:00
gst/librfb/gstrfbsrc.c: don't forget to handle the offset's
Original commit message from CVS: * gst/librfb/gstrfbsrc.c: don't forget to handle the offset's * gst/librfb/rfbdecoder.c: * gst/librfb/rfbdecoder.h: precalculate some many used values
This commit is contained in:
parent
88f5ef13bf
commit
621a4e4792
4 changed files with 46 additions and 26 deletions
|
@ -1,3 +1,11 @@
|
|||
2007-11-15 Thijs Vermeir <thijsvermeir@gmail.com>
|
||||
|
||||
* gst/librfb/gstrfbsrc.c:
|
||||
don't forget to handle the offset's
|
||||
* gst/librfb/rfbdecoder.c:
|
||||
* gst/librfb/rfbdecoder.h:
|
||||
precalculate some many used values
|
||||
|
||||
2007-11-15 Thijs Vermeir <thijsvermeir@gmail.com>
|
||||
|
||||
patch by: Armando Taffarel Neto <taffarel@solis.coop.br>
|
||||
|
|
|
@ -337,14 +337,18 @@ gst_rfb_src_start (GstBaseSrc * bsrc)
|
|||
decoder->prev_frame = g_malloc (bsrc->blocksize);
|
||||
decoder->decoder_private = src;
|
||||
|
||||
/* calculate some many used values */
|
||||
decoder->bytespp = decoder->bpp / 8;
|
||||
decoder->line_size = decoder->rect_width * decoder->bytespp;
|
||||
|
||||
GST_DEBUG_OBJECT (src, "setting caps width to %d and height to %d",
|
||||
decoder->width, decoder->height);
|
||||
decoder->rect_width, decoder->rect_height);
|
||||
|
||||
caps =
|
||||
gst_caps_copy (gst_pad_get_pad_template_caps (GST_BASE_SRC_PAD (bsrc)));
|
||||
gst_caps_set_simple (caps, "width", G_TYPE_INT, decoder->width, "height",
|
||||
G_TYPE_INT, decoder->height, "bpp", G_TYPE_INT, decoder->bpp, "depth",
|
||||
G_TYPE_INT, decoder->depth, "endianness", G_TYPE_INT,
|
||||
gst_caps_set_simple (caps, "width", G_TYPE_INT, decoder->rect_width, "height",
|
||||
G_TYPE_INT, decoder->rect_height, "bpp", G_TYPE_INT, decoder->bpp,
|
||||
"depth", G_TYPE_INT, decoder->depth, "endianness", G_TYPE_INT,
|
||||
(decoder->big_endian ? 1234 : 4321), NULL);
|
||||
gst_pad_set_caps (GST_BASE_SRC_PAD (bsrc), caps);
|
||||
gst_caps_unref (caps);
|
||||
|
@ -425,6 +429,10 @@ gst_rfb_src_event (GstBaseSrc * bsrc, GstEvent * event)
|
|||
gst_structure_get_double (structure, "pointer_y", &y);
|
||||
button = 0;
|
||||
|
||||
/* we need to take care of the offset's */
|
||||
x += src->decoder->offset_x;
|
||||
y += src->decoder->offset_y;
|
||||
|
||||
if (strcmp (event_type, "key-press") == 0) {
|
||||
const gchar *key = gst_structure_get_string (structure, "key");
|
||||
|
||||
|
|
|
@ -641,23 +641,22 @@ rfb_decoder_raw_encoding (RfbDecoder * decoder, gint start_x, gint start_y,
|
|||
{
|
||||
gint size;
|
||||
guint8 *frame, *buffer, *p;
|
||||
guint32 raw_line_size, line_size;
|
||||
guint32 raw_line_size;
|
||||
|
||||
size = rect_h * rect_w * decoder->bpp / 8;
|
||||
raw_line_size = rect_w * decoder->bytespp;
|
||||
size = rect_h * raw_line_size;
|
||||
GST_DEBUG ("Reading %d bytes", size);
|
||||
buffer = rfb_decoder_read (decoder, size);
|
||||
|
||||
line_size = decoder->rect_width * decoder->bpp / 8;
|
||||
raw_line_size = rect_w * decoder->bpp / 8;
|
||||
frame =
|
||||
decoder->frame + (((start_y * decoder->rect_width) +
|
||||
start_x) * decoder->bpp / 8);
|
||||
start_x) * decoder->bytespp);
|
||||
p = buffer;
|
||||
|
||||
while (rect_h--) {
|
||||
memcpy (frame, p, raw_line_size);
|
||||
p += raw_line_size;
|
||||
frame += line_size;
|
||||
frame += decoder->line_size;
|
||||
}
|
||||
|
||||
g_free (buffer);
|
||||
|
@ -668,29 +667,30 @@ rfb_decoder_copyrect_encoding (RfbDecoder * decoder, gint start_x, gint start_y,
|
|||
gint rect_w, gint rect_h)
|
||||
{
|
||||
guint16 src_x, src_y;
|
||||
guint32 src_offset;
|
||||
guint32 dst_offset;
|
||||
gint pos_y, max_y, line_width, copyrect_width;
|
||||
gint line_width, copyrect_width;
|
||||
guint8 *buffer;
|
||||
guint8 *src, *dst;
|
||||
|
||||
buffer = rfb_decoder_read (decoder, 4);
|
||||
max_y = start_y + rect_h;
|
||||
|
||||
src_x = RFB_GET_UINT16 (buffer);
|
||||
src_y = RFB_GET_UINT16 (buffer + 2);
|
||||
/* don't forget the offset */
|
||||
src_x = RFB_GET_UINT16 (buffer) - decoder->offset_x;
|
||||
src_y = RFB_GET_UINT16 (buffer + 2) - decoder->offset_y;
|
||||
GST_DEBUG ("Copyrect from %d %d", src_x, src_y);
|
||||
|
||||
dst_offset =
|
||||
(((start_y - 1) * decoder->rect_width) + start_x) * decoder->bpp / 8;
|
||||
src_offset = (((src_y - 1) * decoder->rect_width) + src_x) * decoder->bpp / 8;
|
||||
line_width = decoder->rect_width * decoder->bpp / 8;
|
||||
copyrect_width = rect_w * decoder->bpp / 8;
|
||||
copyrect_width = rect_w * decoder->bytespp;
|
||||
line_width = decoder->line_size;
|
||||
src =
|
||||
decoder->prev_frame + ((src_y * decoder->rect_width) +
|
||||
src_x) * decoder->bytespp;
|
||||
dst =
|
||||
decoder->frame + ((start_y * decoder->rect_width) +
|
||||
start_x) * decoder->bytespp;
|
||||
|
||||
for (pos_y = start_y; pos_y < max_y; pos_y++) {
|
||||
dst_offset += line_width;
|
||||
src_offset += line_width;
|
||||
memcpy (decoder->frame + dst_offset, decoder->prev_frame + src_offset,
|
||||
copyrect_width);
|
||||
while (rect_h--) {
|
||||
memcpy (dst, src, copyrect_width);
|
||||
src += line_width;
|
||||
dst += line_width;
|
||||
}
|
||||
|
||||
g_free (buffer);
|
||||
|
|
|
@ -69,6 +69,10 @@ struct _RfbDecoder
|
|||
guint rect_height;
|
||||
|
||||
gint n_rects;
|
||||
|
||||
/* some many used values */
|
||||
guint bytespp;
|
||||
guint line_size;
|
||||
};
|
||||
|
||||
#if 0
|
||||
|
|
Loading…
Reference in a new issue