1 /* GStreamer video frame cropping
2 * Copyright (C) 2006 Tim-Philipp Müller <tim centricular net>
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Library General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Library General Public License for more details.
14 * You should have received a copy of the GNU Library General Public
15 * License along with this library; if not, write to the
16 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17 * Boston, MA 02111-1307, USA.
21 * SECTION:element-videocrop
22 * @see_also: #GstVideoBox
24 * This element crops video frames, meaning it can remove parts of the
25 * picture on the left, right, top or bottom of the picture and output
26 * a smaller picture than the input picture, with the unwanted parts at the
29 * The videocrop element is similar to the videobox element, but its main
30 * goal is to support a multitude of formats as efficiently as possible.
31 * Unlike videbox, it cannot add borders to the picture and unlike videbox
32 * it will always output images in exactly the same format as the input image.
34 * If there is nothing to crop, the element will operate in pass-through mode.
36 * Note that no special efforts are made to handle chroma-subsampled formats
37 * in the case of odd-valued cropping and compensate for sub-unit chroma plane
38 * shifts for such formats in the case where the #GstVideoCrop:left or
39 * #GstVideoCrop:top property is set to an odd number. This doesn't matter for
40 * most use cases, but it might matter for yours.
43 * <title>Example launch line</title>
45 * gst-launch -v videotestsrc ! videocrop top=42 left=1 right=4 bottom=0 ! ximagesink
51 * - for packed formats, we could avoid memcpy() in case crop_left
52 * and crop_right are 0 and just create a sub-buffer of the input
61 #include <gst/video/video.h>
63 #include "gstvideocrop.h"
64 #include "gstaspectratiocrop.h"
68 GST_DEBUG_CATEGORY_STATIC (videocrop_debug);
69 #define GST_CAT_DEFAULT videocrop_debug
80 /* the formats we support */
81 #define GST_VIDEO_CAPS_GRAY "video/x-raw-gray, " \
83 "width = " GST_VIDEO_SIZE_RANGE ", " \
84 "height = " GST_VIDEO_SIZE_RANGE ", " \
85 "framerate = " GST_VIDEO_FPS_RANGE
87 #define VIDEO_CROP_CAPS \
88 GST_VIDEO_CAPS_RGBx ";" \
89 GST_VIDEO_CAPS_xRGB ";" \
90 GST_VIDEO_CAPS_BGRx ";" \
91 GST_VIDEO_CAPS_xBGR ";" \
92 GST_VIDEO_CAPS_RGBA ";" \
93 GST_VIDEO_CAPS_ARGB ";" \
94 GST_VIDEO_CAPS_BGRA ";" \
95 GST_VIDEO_CAPS_ABGR ";" \
96 GST_VIDEO_CAPS_RGB ";" \
97 GST_VIDEO_CAPS_BGR ";" \
98 GST_VIDEO_CAPS_YUV ("AYUV") ";" \
99 GST_VIDEO_CAPS_YUV ("YUY2") ";" \
100 GST_VIDEO_CAPS_YUV ("YVYU") ";" \
101 GST_VIDEO_CAPS_YUV ("UYVY") ";" \
102 GST_VIDEO_CAPS_YUV ("Y800") ";" \
103 GST_VIDEO_CAPS_YUV ("I420") ";" \
104 GST_VIDEO_CAPS_YUV ("YV12") ";" \
105 GST_VIDEO_CAPS_RGB_16 ";" \
106 GST_VIDEO_CAPS_RGB_15 ";" \
109 static GstStaticPadTemplate src_template = GST_STATIC_PAD_TEMPLATE ("src",
112 GST_STATIC_CAPS (VIDEO_CROP_CAPS)
115 static GstStaticPadTemplate sink_template = GST_STATIC_PAD_TEMPLATE ("sink",
118 GST_STATIC_CAPS (VIDEO_CROP_CAPS)
121 GST_BOILERPLATE (GstVideoCrop, gst_video_crop, GstBaseTransform,
122 GST_TYPE_BASE_TRANSFORM);
124 static void gst_video_crop_set_property (GObject * object, guint prop_id,
125 const GValue * value, GParamSpec * pspec);
126 static void gst_video_crop_get_property (GObject * object, guint prop_id,
127 GValue * value, GParamSpec * pspec);
129 static GstCaps *gst_video_crop_transform_caps (GstBaseTransform * trans,
130 GstPadDirection direction, GstCaps * caps);
131 static GstFlowReturn gst_video_crop_transform (GstBaseTransform * trans,
132 GstBuffer * inbuf, GstBuffer * outbuf);
133 static gboolean gst_video_crop_get_unit_size (GstBaseTransform * trans,
134 GstCaps * caps, guint * size);
135 static gboolean gst_video_crop_set_caps (GstBaseTransform * trans,
136 GstCaps * in_caps, GstCaps * outcaps);
137 static gboolean gst_video_crop_src_event (GstBaseTransform * trans,
141 gst_video_crop_base_init (gpointer g_class)
143 GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
145 gst_element_class_set_details_simple (element_class, "Crop",
146 "Filter/Effect/Video",
147 "Crops video into a user-defined region",
148 "Tim-Philipp Müller <tim centricular net>");
150 gst_element_class_add_static_pad_template (element_class,
152 gst_element_class_add_static_pad_template (element_class, &src_template);
156 gst_video_crop_src_event (GstBaseTransform * trans, GstEvent * event)
159 GstStructure *new_structure;
160 const GstStructure *structure;
161 const gchar *event_name;
165 GstVideoCrop *vcrop = GST_VIDEO_CROP (trans);
168 GST_OBJECT_LOCK (vcrop);
169 if (GST_EVENT_TYPE (event) == GST_EVENT_NAVIGATION &&
170 (vcrop->crop_left != 0 || vcrop->crop_top != 0)) {
171 structure = gst_event_get_structure (event);
172 event_name = gst_structure_get_string (structure, "event");
175 (strcmp (event_name, "mouse-move") == 0 ||
176 strcmp (event_name, "mouse-button-press") == 0 ||
177 strcmp (event_name, "mouse-button-release") == 0)) {
179 if (gst_structure_get_double (structure, "pointer_x", &pointer_x) &&
180 gst_structure_get_double (structure, "pointer_y", &pointer_y)) {
182 new_structure = gst_structure_copy (structure);
183 gst_structure_set (new_structure,
184 "pointer_x", G_TYPE_DOUBLE, (double) (pointer_x + vcrop->crop_left),
185 "pointer_y", G_TYPE_DOUBLE, (double) (pointer_y + vcrop->crop_top),
188 new_event = gst_event_new_navigation (new_structure);
189 gst_event_unref (event);
191 GST_WARNING_OBJECT (vcrop, "Failed to read navigation event");
196 GST_OBJECT_UNLOCK (vcrop);
197 return GST_BASE_TRANSFORM_CLASS (parent_class)->src_event (trans,
198 (new_event ? new_event : event));
202 gst_video_crop_class_init (GstVideoCropClass * klass)
204 GObjectClass *gobject_class;
205 GstBaseTransformClass *basetransform_class;
207 gobject_class = (GObjectClass *) klass;
208 basetransform_class = (GstBaseTransformClass *) klass;
210 gobject_class->set_property = gst_video_crop_set_property;
211 gobject_class->get_property = gst_video_crop_get_property;
213 g_object_class_install_property (gobject_class, ARG_LEFT,
214 g_param_spec_int ("left", "Left", "Pixels to crop at left",
215 0, G_MAXINT, 0, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
216 g_object_class_install_property (gobject_class, ARG_RIGHT,
217 g_param_spec_int ("right", "Right", "Pixels to crop at right",
218 0, G_MAXINT, 0, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
219 g_object_class_install_property (gobject_class, ARG_TOP,
220 g_param_spec_int ("top", "Top", "Pixels to crop at top",
221 0, G_MAXINT, 0, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
222 g_object_class_install_property (gobject_class, ARG_BOTTOM,
223 g_param_spec_int ("bottom", "Bottom", "Pixels to crop at bottom",
224 0, G_MAXINT, 0, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
226 basetransform_class->transform = GST_DEBUG_FUNCPTR (gst_video_crop_transform);
227 basetransform_class->transform_caps =
228 GST_DEBUG_FUNCPTR (gst_video_crop_transform_caps);
229 basetransform_class->set_caps = GST_DEBUG_FUNCPTR (gst_video_crop_set_caps);
230 basetransform_class->get_unit_size =
231 GST_DEBUG_FUNCPTR (gst_video_crop_get_unit_size);
233 basetransform_class->passthrough_on_same_caps = FALSE;
234 basetransform_class->src_event = GST_DEBUG_FUNCPTR (gst_video_crop_src_event);
238 gst_video_crop_init (GstVideoCrop * vcrop, GstVideoCropClass * klass)
240 vcrop->crop_right = 0;
241 vcrop->crop_left = 0;
243 vcrop->crop_bottom = 0;
247 gst_video_crop_get_image_details_from_caps (GstVideoCrop * vcrop,
248 GstVideoCropImageDetails * details, GstCaps * caps)
250 GstStructure *structure;
253 structure = gst_caps_get_structure (caps, 0);
254 if (!gst_structure_get_int (structure, "width", &width) ||
255 !gst_structure_get_int (structure, "height", &height)) {
256 goto incomplete_format;
259 details->width = width;
260 details->height = height;
262 if (gst_structure_has_name (structure, "video/x-raw-rgb") ||
263 gst_structure_has_name (structure, "video/x-raw-gray")) {
266 if (!gst_structure_get_int (structure, "bpp", &bpp) || (bpp & 0x07) != 0)
267 goto incomplete_format;
269 details->packing = VIDEO_CROP_PIXEL_FORMAT_PACKED_SIMPLE;
270 details->bytes_per_pixel = bpp / 8;
271 details->stride = GST_ROUND_UP_4 (width * details->bytes_per_pixel);
272 details->size = details->stride * height;
273 } else if (gst_structure_has_name (structure, "video/x-raw-yuv")) {
276 if (!gst_structure_get_fourcc (structure, "format", &format))
277 goto incomplete_format;
280 case GST_MAKE_FOURCC ('A', 'Y', 'U', 'V'):
281 details->packing = VIDEO_CROP_PIXEL_FORMAT_PACKED_SIMPLE;
282 details->bytes_per_pixel = 4;
283 details->stride = GST_ROUND_UP_4 (width * 4);
284 details->size = details->stride * height;
286 case GST_MAKE_FOURCC ('Y', 'V', 'Y', 'U'):
287 case GST_MAKE_FOURCC ('Y', 'U', 'Y', '2'):
288 case GST_MAKE_FOURCC ('U', 'Y', 'V', 'Y'):
289 details->packing = VIDEO_CROP_PIXEL_FORMAT_PACKED_COMPLEX;
290 details->bytes_per_pixel = 2;
291 details->stride = GST_ROUND_UP_4 (width * 2);
292 details->size = details->stride * height;
293 if (format == GST_MAKE_FOURCC ('U', 'Y', 'V', 'Y')) {
294 /* UYVY = 4:2:2 - [U0 Y0 V0 Y1] [U2 Y2 V2 Y3] [U4 Y4 V4 Y5] */
295 details->macro_y_off = 1;
297 /* YUYV = 4:2:2 - [Y0 U0 Y1 V0] [Y2 U2 Y3 V2] [Y4 U4 Y5 V4] = YUY2 */
298 details->macro_y_off = 0;
301 case GST_MAKE_FOURCC ('Y', '8', '0', '0'):
302 details->packing = VIDEO_CROP_PIXEL_FORMAT_PACKED_SIMPLE;
303 details->bytes_per_pixel = 1;
304 details->stride = GST_ROUND_UP_4 (width);
305 details->size = details->stride * height;
307 case GST_MAKE_FOURCC ('I', '4', '2', '0'):
308 case GST_MAKE_FOURCC ('Y', 'V', '1', '2'):{
309 details->packing = VIDEO_CROP_PIXEL_FORMAT_PLANAR;
311 details->y_stride = GST_ROUND_UP_4 (width);
312 details->u_stride = GST_ROUND_UP_8 (width) / 2;
313 details->v_stride = GST_ROUND_UP_8 (width) / 2;
315 /* I420 and YV12 have U/V planes swapped, but doesn't matter for us */
317 details->u_off = 0 + details->y_stride * GST_ROUND_UP_2 (height);
318 details->v_off = details->u_off +
319 details->u_stride * (GST_ROUND_UP_2 (height) / 2);
320 details->size = details->v_off +
321 details->v_stride * (GST_ROUND_UP_2 (height) / 2);
336 GST_ELEMENT_ERROR (vcrop, STREAM, NOT_IMPLEMENTED, (NULL),
337 ("Unsupported format"));
343 GST_ELEMENT_ERROR (vcrop, CORE, NEGOTIATION, (NULL),
344 ("Incomplete caps, some required field is missing"));
350 gst_video_crop_get_unit_size (GstBaseTransform * trans, GstCaps * caps,
353 GstVideoCropImageDetails img_details = { 0, };
354 GstVideoCrop *vcrop = GST_VIDEO_CROP (trans);
356 if (!gst_video_crop_get_image_details_from_caps (vcrop, &img_details, caps))
359 *size = img_details.size;
363 #define ROUND_DOWN_2(n) ((n)&(~1))
366 gst_video_crop_transform_packed_complex (GstVideoCrop * vcrop,
367 GstBuffer * inbuf, GstBuffer * outbuf)
369 guint8 *in_data, *out_data;
372 in_data = GST_BUFFER_DATA (inbuf);
373 out_data = GST_BUFFER_DATA (outbuf);
375 in_data += vcrop->crop_top * vcrop->in.stride;
377 /* rounding down here so we end up at the start of a macro-pixel and not
378 * in the middle of one */
379 in_data += ROUND_DOWN_2 (vcrop->crop_left) * vcrop->in.bytes_per_pixel;
381 dx = vcrop->out.width * vcrop->out.bytes_per_pixel;
383 /* UYVY = 4:2:2 - [U0 Y0 V0 Y1] [U2 Y2 V2 Y3] [U4 Y4 V4 Y5]
384 * YUYV = 4:2:2 - [Y0 U0 Y1 V0] [Y2 U2 Y3 V2] [Y4 U4 Y5 V4] = YUY2 */
385 if ((vcrop->crop_left % 2) != 0) {
386 for (i = 0; i < vcrop->out.height; ++i) {
389 memcpy (out_data, in_data, dx);
391 /* move just the Y samples one pixel to the left, don't worry about
393 for (j = vcrop->in.macro_y_off; j < vcrop->out.stride - 2; j += 2)
394 out_data[j] = in_data[j + 2];
396 in_data += vcrop->in.stride;
397 out_data += vcrop->out.stride;
400 for (i = 0; i < vcrop->out.height; ++i) {
401 memcpy (out_data, in_data, dx);
402 in_data += vcrop->in.stride;
403 out_data += vcrop->out.stride;
409 gst_video_crop_transform_packed_simple (GstVideoCrop * vcrop,
410 GstBuffer * inbuf, GstBuffer * outbuf)
412 guint8 *in_data, *out_data;
415 in_data = GST_BUFFER_DATA (inbuf);
416 out_data = GST_BUFFER_DATA (outbuf);
418 in_data += vcrop->crop_top * vcrop->in.stride;
419 in_data += vcrop->crop_left * vcrop->in.bytes_per_pixel;
421 dx = vcrop->out.width * vcrop->out.bytes_per_pixel;
423 for (i = 0; i < vcrop->out.height; ++i) {
424 memcpy (out_data, in_data, dx);
425 in_data += vcrop->in.stride;
426 out_data += vcrop->out.stride;
431 gst_video_crop_transform_planar (GstVideoCrop * vcrop, GstBuffer * inbuf,
434 guint8 *y_out, *u_out, *v_out;
435 guint8 *y_in, *u_in, *v_in;
439 y_in = GST_BUFFER_DATA (inbuf);
440 y_out = GST_BUFFER_DATA (outbuf);
442 y_in += (vcrop->crop_top * vcrop->in.y_stride) + vcrop->crop_left;
443 dx = vcrop->out.width * 1;
445 for (i = 0; i < vcrop->out.height; ++i) {
446 memcpy (y_out, y_in, dx);
447 y_in += vcrop->in.y_stride;
448 y_out += vcrop->out.y_stride;
452 u_in = GST_BUFFER_DATA (inbuf) + vcrop->in.u_off;
453 u_out = GST_BUFFER_DATA (outbuf) + vcrop->out.u_off;
455 u_in += (vcrop->crop_top / 2) * vcrop->in.u_stride;
456 u_in += vcrop->crop_left / 2;
458 v_in = GST_BUFFER_DATA (inbuf) + vcrop->in.v_off;
459 v_out = GST_BUFFER_DATA (outbuf) + vcrop->out.v_off;
461 v_in += (vcrop->crop_top / 2) * vcrop->in.v_stride;
462 v_in += vcrop->crop_left / 2;
464 dx = GST_ROUND_UP_2 (vcrop->out.width) / 2;
466 for (i = 0; i < GST_ROUND_UP_2 (vcrop->out.height) / 2; ++i) {
467 memcpy (u_out, u_in, dx);
468 memcpy (v_out, v_in, dx);
469 u_in += vcrop->in.u_stride;
470 u_out += vcrop->out.u_stride;
471 v_in += vcrop->in.v_stride;
472 v_out += vcrop->out.v_stride;
477 gst_video_crop_transform (GstBaseTransform * trans, GstBuffer * inbuf,
480 GstVideoCrop *vcrop = GST_VIDEO_CROP (trans);
482 switch (vcrop->in.packing) {
483 case VIDEO_CROP_PIXEL_FORMAT_PACKED_SIMPLE:
484 gst_video_crop_transform_packed_simple (vcrop, inbuf, outbuf);
486 case VIDEO_CROP_PIXEL_FORMAT_PACKED_COMPLEX:
487 gst_video_crop_transform_packed_complex (vcrop, inbuf, outbuf);
489 case VIDEO_CROP_PIXEL_FORMAT_PLANAR:
490 gst_video_crop_transform_planar (vcrop, inbuf, outbuf);
493 g_assert_not_reached ();
500 gst_video_crop_transform_dimension (gint val, gint delta)
502 gint64 new_val = (gint64) val + (gint64) delta;
504 new_val = CLAMP (new_val, 1, G_MAXINT);
506 return (gint) new_val;
510 gst_video_crop_transform_dimension_value (const GValue * src_val,
511 gint delta, GValue * dest_val)
515 g_value_init (dest_val, G_VALUE_TYPE (src_val));
517 if (G_VALUE_HOLDS_INT (src_val)) {
518 gint ival = g_value_get_int (src_val);
520 ival = gst_video_crop_transform_dimension (ival, delta);
521 g_value_set_int (dest_val, ival);
522 } else if (GST_VALUE_HOLDS_INT_RANGE (src_val)) {
523 gint min = gst_value_get_int_range_min (src_val);
524 gint max = gst_value_get_int_range_max (src_val);
526 min = gst_video_crop_transform_dimension (min, delta);
527 max = gst_video_crop_transform_dimension (max, delta);
528 gst_value_set_int_range (dest_val, min, max);
529 } else if (GST_VALUE_HOLDS_LIST (src_val)) {
532 for (i = 0; i < gst_value_list_get_size (src_val); ++i) {
533 const GValue *list_val;
534 GValue newval = { 0, };
536 list_val = gst_value_list_get_value (src_val, i);
537 if (gst_video_crop_transform_dimension_value (list_val, delta, &newval))
538 gst_value_list_append_value (dest_val, &newval);
539 g_value_unset (&newval);
542 if (gst_value_list_get_size (dest_val) == 0) {
543 g_value_unset (dest_val);
547 g_value_unset (dest_val);
555 gst_video_crop_transform_caps (GstBaseTransform * trans,
556 GstPadDirection direction, GstCaps * caps)
562 vcrop = GST_VIDEO_CROP (trans);
564 GST_OBJECT_LOCK (vcrop);
566 GST_LOG_OBJECT (vcrop, "l=%d,r=%d,b=%d,t=%d",
567 vcrop->crop_left, vcrop->crop_right, vcrop->crop_bottom, vcrop->crop_top);
569 if (direction == GST_PAD_SRC) {
570 dx = vcrop->crop_left + vcrop->crop_right;
571 dy = vcrop->crop_top + vcrop->crop_bottom;
573 dx = 0 - (vcrop->crop_left + vcrop->crop_right);
574 dy = 0 - (vcrop->crop_top + vcrop->crop_bottom);
576 GST_OBJECT_UNLOCK (vcrop);
578 GST_LOG_OBJECT (vcrop, "transforming caps %" GST_PTR_FORMAT, caps);
580 other_caps = gst_caps_new_empty ();
582 for (i = 0; i < gst_caps_get_size (caps); ++i) {
584 GstStructure *structure, *new_structure;
585 GValue w_val = { 0, }, h_val = {
588 structure = gst_caps_get_structure (caps, i);
590 v = gst_structure_get_value (structure, "width");
591 if (!gst_video_crop_transform_dimension_value (v, dx, &w_val)) {
592 GST_WARNING_OBJECT (vcrop, "could not tranform width value with dx=%d"
593 ", caps structure=%" GST_PTR_FORMAT, dx, structure);
597 v = gst_structure_get_value (structure, "height");
598 if (!gst_video_crop_transform_dimension_value (v, dy, &h_val)) {
599 g_value_unset (&w_val);
600 GST_WARNING_OBJECT (vcrop, "could not tranform height value with dy=%d"
601 ", caps structure=%" GST_PTR_FORMAT, dy, structure);
605 new_structure = gst_structure_copy (structure);
606 gst_structure_set_value (new_structure, "width", &w_val);
607 gst_structure_set_value (new_structure, "height", &h_val);
608 g_value_unset (&w_val);
609 g_value_unset (&h_val);
610 GST_LOG_OBJECT (vcrop, "transformed structure %2d: %" GST_PTR_FORMAT
611 " => %" GST_PTR_FORMAT, i, structure, new_structure);
612 gst_caps_append_structure (other_caps, new_structure);
615 if (gst_caps_is_empty (other_caps)) {
616 gst_caps_unref (other_caps);
624 gst_video_crop_set_caps (GstBaseTransform * trans, GstCaps * incaps,
627 GstVideoCrop *crop = GST_VIDEO_CROP (trans);
629 if (!gst_video_crop_get_image_details_from_caps (crop, &crop->in, incaps))
632 if (!gst_video_crop_get_image_details_from_caps (crop, &crop->out, outcaps))
635 if (G_UNLIKELY ((crop->crop_left + crop->crop_right) >= crop->in.width ||
636 (crop->crop_top + crop->crop_bottom) >= crop->in.height))
637 goto cropping_too_much;
639 GST_LOG_OBJECT (crop, "incaps = %" GST_PTR_FORMAT ", outcaps = %"
640 GST_PTR_FORMAT, incaps, outcaps);
642 if ((crop->crop_left | crop->crop_right | crop->crop_top | crop->
644 GST_LOG_OBJECT (crop, "we are using passthrough");
645 gst_base_transform_set_passthrough (GST_BASE_TRANSFORM (crop), TRUE);
647 GST_LOG_OBJECT (crop, "we are not using passthrough");
648 gst_base_transform_set_passthrough (GST_BASE_TRANSFORM (crop), FALSE);
656 GST_DEBUG_OBJECT (crop, "failed to parse input caps %" GST_PTR_FORMAT,
662 GST_DEBUG_OBJECT (crop, "failed to parse output caps %" GST_PTR_FORMAT,
668 GST_DEBUG_OBJECT (crop, "we are cropping too much");
674 gst_video_crop_set_property (GObject * object, guint prop_id,
675 const GValue * value, GParamSpec * pspec)
677 GstVideoCrop *video_crop;
679 video_crop = GST_VIDEO_CROP (object);
681 /* don't modify while we are transforming */
682 GST_BASE_TRANSFORM_LOCK (GST_BASE_TRANSFORM_CAST (video_crop));
684 /* protect with the object lock so that we can read them */
685 GST_OBJECT_LOCK (video_crop);
688 video_crop->crop_left = g_value_get_int (value);
691 video_crop->crop_right = g_value_get_int (value);
694 video_crop->crop_top = g_value_get_int (value);
697 video_crop->crop_bottom = g_value_get_int (value);
700 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
703 GST_OBJECT_UNLOCK (video_crop);
705 GST_LOG_OBJECT (video_crop, "l=%d,r=%d,b=%d,t=%d",
706 video_crop->crop_left, video_crop->crop_right, video_crop->crop_bottom,
707 video_crop->crop_top);
709 gst_base_transform_reconfigure (GST_BASE_TRANSFORM (video_crop));
710 GST_BASE_TRANSFORM_UNLOCK (GST_BASE_TRANSFORM_CAST (video_crop));
714 gst_video_crop_get_property (GObject * object, guint prop_id, GValue * value,
717 GstVideoCrop *video_crop;
719 video_crop = GST_VIDEO_CROP (object);
721 GST_OBJECT_LOCK (video_crop);
724 g_value_set_int (value, video_crop->crop_left);
727 g_value_set_int (value, video_crop->crop_right);
730 g_value_set_int (value, video_crop->crop_top);
733 g_value_set_int (value, video_crop->crop_bottom);
736 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
739 GST_OBJECT_UNLOCK (video_crop);
743 plugin_init (GstPlugin * plugin)
745 GST_DEBUG_CATEGORY_INIT (videocrop_debug, "videocrop", 0, "videocrop");
747 if (gst_element_register (plugin, "videocrop", GST_RANK_NONE,
749 && gst_element_register (plugin, "aspectratiocrop", GST_RANK_NONE,
750 GST_TYPE_ASPECT_RATIO_CROP))
756 GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
759 "Crops video into a user-defined region",
760 plugin_init, VERSION, GST_LICENSE, GST_PACKAGE_NAME, GST_PACKAGE_ORIGIN)