From 66142747bda12ceca122edfe3daff660b481740b Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Mon, 1 Aug 2011 18:36:33 +0200 Subject: [PATCH] xv: apply cropping on padded images Store the dimensions of the unpadded image in the metadata and use that info to display the valid region of the image. --- sys/xvimage/xvimagepool.c | 6 ++++-- sys/xvimage/xvimagepool.h | 4 +++- sys/xvimage/xvimagesink.c | 8 ++++---- 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/sys/xvimage/xvimagepool.c b/sys/xvimage/xvimagepool.c index b558678..809d0a8 100644 --- a/sys/xvimage/xvimagepool.c +++ b/sys/xvimage/xvimagepool.c @@ -107,8 +107,10 @@ gst_buffer_add_meta_xvimage (GstBuffer * buffer, GstXvImageBufferPool * xvpool) meta->SHMInfo.shmaddr = ((void *) -1); meta->SHMInfo.shmid = -1; #endif - meta->width = width; - meta->height = height; + meta->x = priv->align.padding_left; + meta->y = priv->align.padding_top; + meta->width = priv->info.width; + meta->height = priv->info.height; meta->sink = gst_object_ref (xvimagesink); meta->im_format = im_format; diff --git a/sys/xvimage/xvimagepool.h b/sys/xvimage/xvimagepool.h index 76a5654..b15f0e0 100644 --- a/sys/xvimage/xvimagepool.h +++ b/sys/xvimage/xvimagepool.h @@ -76,7 +76,9 @@ struct _GstMetaXvImage XShmSegmentInfo SHMInfo; #endif /* HAVE_XSHM */ - gint width, height, im_format; + gint x, y; + gint width, height; + gint im_format; size_t size; }; diff --git a/sys/xvimage/xvimagesink.c b/sys/xvimage/xvimagesink.c index 4b99143..433fb06 100644 --- a/sys/xvimage/xvimagesink.c +++ b/sys/xvimage/xvimagesink.c @@ -313,13 +313,13 @@ gst_xvimagesink_xvimage_put (GstXvImageSink * xvimagesink, GstBuffer * xvimage) crop = gst_buffer_get_meta_video_crop (xvimage); if (crop) { - src.x = crop->x; - src.y = crop->y; + src.x = crop->x + meta->x; + src.y = crop->y + meta->y; src.w = crop->width; src.h = crop->height; } else { - src.x = 0; - src.y = 0; + src.x = meta->x; + src.y = meta->y; src.w = meta->width; src.h = meta->height; } -- 2.7.4