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_pad_template (element_class,
151 gst_static_pad_template_get (&sink_template));
152 gst_element_class_add_pad_template (element_class,
153 gst_static_pad_template_get (&src_template));
157 gst_video_crop_src_event (GstBaseTransform * trans, GstEvent * event)
160 GstStructure *new_structure;
161 const GstStructure *structure;
162 const gchar *event_name;
166 GstVideoCrop *vcrop = GST_VIDEO_CROP (trans);
169 GST_OBJECT_LOCK (vcrop);
170 if (GST_EVENT_TYPE (event) == GST_EVENT_NAVIGATION &&
171 (vcrop->crop_left != 0 || vcrop->crop_top != 0)) {
172 structure = gst_event_get_structure (event);
173 event_name = gst_structure_get_string (structure, "event");
176 (strcmp (event_name, "mouse-move") == 0 ||
177 strcmp (event_name, "mouse-button-press") == 0 ||
178 strcmp (event_name, "mouse-button-release") == 0)) {
180 if (gst_structure_get_double (structure, "pointer_x", &pointer_x) &&
181 gst_structure_get_double (structure, "pointer_y", &pointer_y)) {
183 new_structure = gst_structure_copy (structure);
184 gst_structure_set (new_structure,
185 "pointer_x", G_TYPE_DOUBLE, (double) (pointer_x + vcrop->crop_left),
186 "pointer_y", G_TYPE_DOUBLE, (double) (pointer_y + vcrop->crop_top),
189 new_event = gst_event_new_navigation (new_structure);
190 gst_event_unref (event);
192 GST_WARNING_OBJECT (vcrop, "Failed to read navigation event");
197 GST_OBJECT_UNLOCK (vcrop);
198 return GST_BASE_TRANSFORM_CLASS (parent_class)->src_event (trans,
199 (new_event ? new_event : event));
203 gst_video_crop_class_init (GstVideoCropClass * klass)
205 GObjectClass *gobject_class;
206 GstBaseTransformClass *basetransform_class;
208 gobject_class = (GObjectClass *) klass;
209 basetransform_class = (GstBaseTransformClass *) klass;
211 gobject_class->set_property = gst_video_crop_set_property;
212 gobject_class->get_property = gst_video_crop_get_property;
214 g_object_class_install_property (gobject_class, ARG_LEFT,
215 g_param_spec_int ("left", "Left", "Pixels to crop at left",
216 0, G_MAXINT, 0, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
217 g_object_class_install_property (gobject_class, ARG_RIGHT,
218 g_param_spec_int ("right", "Right", "Pixels to crop at right",
219 0, G_MAXINT, 0, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
220 g_object_class_install_property (gobject_class, ARG_TOP,
221 g_param_spec_int ("top", "Top", "Pixels to crop at top",
222 0, G_MAXINT, 0, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
223 g_object_class_install_property (gobject_class, ARG_BOTTOM,
224 g_param_spec_int ("bottom", "Bottom", "Pixels to crop at bottom",
225 0, G_MAXINT, 0, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
227 basetransform_class->transform = GST_DEBUG_FUNCPTR (gst_video_crop_transform);
228 basetransform_class->transform_caps =
229 GST_DEBUG_FUNCPTR (gst_video_crop_transform_caps);
230 basetransform_class->set_caps = GST_DEBUG_FUNCPTR (gst_video_crop_set_caps);
231 basetransform_class->get_unit_size =
232 GST_DEBUG_FUNCPTR (gst_video_crop_get_unit_size);
234 basetransform_class->passthrough_on_same_caps = FALSE;
235 basetransform_class->src_event = GST_DEBUG_FUNCPTR (gst_video_crop_src_event);
239 gst_video_crop_init (GstVideoCrop * vcrop, GstVideoCropClass * klass)
241 vcrop->crop_right = 0;
242 vcrop->crop_left = 0;
244 vcrop->crop_bottom = 0;
248 gst_video_crop_get_image_details_from_caps (GstVideoCrop * vcrop,
249 GstVideoCropImageDetails * details, GstCaps * caps)
251 GstStructure *structure;
254 structure = gst_caps_get_structure (caps, 0);
255 if (!gst_structure_get_int (structure, "width", &width) ||
256 !gst_structure_get_int (structure, "height", &height)) {
257 goto incomplete_format;
260 details->width = width;
261 details->height = height;
263 if (gst_structure_has_name (structure, "video/x-raw-rgb") ||
264 gst_structure_has_name (structure, "video/x-raw-gray")) {
267 if (!gst_structure_get_int (structure, "bpp", &bpp) || (bpp & 0x07) != 0)
268 goto incomplete_format;
270 details->packing = VIDEO_CROP_PIXEL_FORMAT_PACKED_SIMPLE;
271 details->bytes_per_pixel = bpp / 8;
272 details->stride = GST_ROUND_UP_4 (width * details->bytes_per_pixel);
273 details->size = details->stride * height;
274 } else if (gst_structure_has_name (structure, "video/x-raw-yuv")) {
277 if (!gst_structure_get_fourcc (structure, "format", &format))
278 goto incomplete_format;
281 case GST_MAKE_FOURCC ('A', 'Y', 'U', 'V'):
282 details->packing = VIDEO_CROP_PIXEL_FORMAT_PACKED_SIMPLE;
283 details->bytes_per_pixel = 4;
284 details->stride = GST_ROUND_UP_4 (width * 4);
285 details->size = details->stride * height;
287 case GST_MAKE_FOURCC ('Y', 'V', 'Y', 'U'):
288 case GST_MAKE_FOURCC ('Y', 'U', 'Y', '2'):
289 case GST_MAKE_FOURCC ('U', 'Y', 'V', 'Y'):
290 details->packing = VIDEO_CROP_PIXEL_FORMAT_PACKED_COMPLEX;
291 details->bytes_per_pixel = 2;
292 details->stride = GST_ROUND_UP_4 (width * 2);
293 details->size = details->stride * height;
294 if (format == GST_MAKE_FOURCC ('U', 'Y', 'V', 'Y')) {
295 /* UYVY = 4:2:2 - [U0 Y0 V0 Y1] [U2 Y2 V2 Y3] [U4 Y4 V4 Y5] */
296 details->macro_y_off = 1;
298 /* YUYV = 4:2:2 - [Y0 U0 Y1 V0] [Y2 U2 Y3 V2] [Y4 U4 Y5 V4] = YUY2 */
299 details->macro_y_off = 0;
302 case GST_MAKE_FOURCC ('Y', '8', '0', '0'):
303 details->packing = VIDEO_CROP_PIXEL_FORMAT_PACKED_SIMPLE;
304 details->bytes_per_pixel = 1;
305 details->stride = GST_ROUND_UP_4 (width);
306 details->size = details->stride * height;
308 case GST_MAKE_FOURCC ('I', '4', '2', '0'):
309 case GST_MAKE_FOURCC ('Y', 'V', '1', '2'):{
310 details->packing = VIDEO_CROP_PIXEL_FORMAT_PLANAR;
312 details->y_stride = GST_ROUND_UP_4 (width);
313 details->u_stride = GST_ROUND_UP_8 (width) / 2;
314 details->v_stride = GST_ROUND_UP_8 (width) / 2;
316 /* I420 and YV12 have U/V planes swapped, but doesn't matter for us */
318 details->u_off = 0 + details->y_stride * GST_ROUND_UP_2 (height);
319 details->v_off = details->u_off +
320 details->u_stride * (GST_ROUND_UP_2 (height) / 2);
321 details->size = details->v_off +
322 details->v_stride * (GST_ROUND_UP_2 (height) / 2);
337 GST_ELEMENT_ERROR (vcrop, STREAM, NOT_IMPLEMENTED, (NULL),
338 ("Unsupported format"));
344 GST_ELEMENT_ERROR (vcrop, CORE, NEGOTIATION, (NULL),
345 ("Incomplete caps, some required field is missing"));
351 gst_video_crop_get_unit_size (GstBaseTransform * trans, GstCaps * caps,
354 GstVideoCropImageDetails img_details = { 0, };
355 GstVideoCrop *vcrop = GST_VIDEO_CROP (trans);
357 if (!gst_video_crop_get_image_details_from_caps (vcrop, &img_details, caps))
360 *size = img_details.size;
364 #define ROUND_DOWN_2(n) ((n)&(~1))
367 gst_video_crop_transform_packed_complex (GstVideoCrop * vcrop,
368 GstBuffer * inbuf, GstBuffer * outbuf)
370 guint8 *in_data, *out_data;
373 in_data = GST_BUFFER_DATA (inbuf);
374 out_data = GST_BUFFER_DATA (outbuf);
376 in_data += vcrop->crop_top * vcrop->in.stride;
378 /* rounding down here so we end up at the start of a macro-pixel and not
379 * in the middle of one */
380 in_data += ROUND_DOWN_2 (vcrop->crop_left) * vcrop->in.bytes_per_pixel;
382 dx = vcrop->out.width * vcrop->out.bytes_per_pixel;
384 /* UYVY = 4:2:2 - [U0 Y0 V0 Y1] [U2 Y2 V2 Y3] [U4 Y4 V4 Y5]
385 * YUYV = 4:2:2 - [Y0 U0 Y1 V0] [Y2 U2 Y3 V2] [Y4 U4 Y5 V4] = YUY2 */
386 if ((vcrop->crop_left % 2) != 0) {
387 for (i = 0; i < vcrop->out.height; ++i) {
390 memcpy (out_data, in_data, dx);
392 /* move just the Y samples one pixel to the left, don't worry about
394 for (j = vcrop->in.macro_y_off; j < vcrop->out.stride - 2; j += 2)
395 out_data[j] = in_data[j + 2];
397 in_data += vcrop->in.stride;
398 out_data += vcrop->out.stride;
401 for (i = 0; i < vcrop->out.height; ++i) {
402 memcpy (out_data, in_data, dx);
403 in_data += vcrop->in.stride;
404 out_data += vcrop->out.stride;
410 gst_video_crop_transform_packed_simple (GstVideoCrop * vcrop,
411 GstBuffer * inbuf, GstBuffer * outbuf)
413 guint8 *in_data, *out_data;
416 in_data = GST_BUFFER_DATA (inbuf);
417 out_data = GST_BUFFER_DATA (outbuf);
419 in_data += vcrop->crop_top * vcrop->in.stride;
420 in_data += vcrop->crop_left * vcrop->in.bytes_per_pixel;
422 dx = vcrop->out.width * vcrop->out.bytes_per_pixel;
424 for (i = 0; i < vcrop->out.height; ++i) {
425 memcpy (out_data, in_data, dx);
426 in_data += vcrop->in.stride;
427 out_data += vcrop->out.stride;
432 gst_video_crop_transform_planar (GstVideoCrop * vcrop, GstBuffer * inbuf,
435 guint8 *y_out, *u_out, *v_out;
436 guint8 *y_in, *u_in, *v_in;
440 y_in = GST_BUFFER_DATA (inbuf);
441 y_out = GST_BUFFER_DATA (outbuf);
443 y_in += (vcrop->crop_top * vcrop->in.y_stride) + vcrop->crop_left;
444 dx = vcrop->out.width * 1;
446 for (i = 0; i < vcrop->out.height; ++i) {
447 memcpy (y_out, y_in, dx);
448 y_in += vcrop->in.y_stride;
449 y_out += vcrop->out.y_stride;
453 u_in = GST_BUFFER_DATA (inbuf) + vcrop->in.u_off;
454 u_out = GST_BUFFER_DATA (outbuf) + vcrop->out.u_off;
456 u_in += (vcrop->crop_top / 2) * vcrop->in.u_stride;
457 u_in += vcrop->crop_left / 2;
459 v_in = GST_BUFFER_DATA (inbuf) + vcrop->in.v_off;
460 v_out = GST_BUFFER_DATA (outbuf) + vcrop->out.v_off;
462 v_in += (vcrop->crop_top / 2) * vcrop->in.v_stride;
463 v_in += vcrop->crop_left / 2;
465 dx = GST_ROUND_UP_2 (vcrop->out.width) / 2;
467 for (i = 0; i < GST_ROUND_UP_2 (vcrop->out.height) / 2; ++i) {
468 memcpy (u_out, u_in, dx);
469 memcpy (v_out, v_in, dx);
470 u_in += vcrop->in.u_stride;
471 u_out += vcrop->out.u_stride;
472 v_in += vcrop->in.v_stride;
473 v_out += vcrop->out.v_stride;
478 gst_video_crop_transform (GstBaseTransform * trans, GstBuffer * inbuf,
481 GstVideoCrop *vcrop = GST_VIDEO_CROP (trans);
483 switch (vcrop->in.packing) {
484 case VIDEO_CROP_PIXEL_FORMAT_PACKED_SIMPLE:
485 gst_video_crop_transform_packed_simple (vcrop, inbuf, outbuf);
487 case VIDEO_CROP_PIXEL_FORMAT_PACKED_COMPLEX:
488 gst_video_crop_transform_packed_complex (vcrop, inbuf, outbuf);
490 case VIDEO_CROP_PIXEL_FORMAT_PLANAR:
491 gst_video_crop_transform_planar (vcrop, inbuf, outbuf);
494 g_assert_not_reached ();
501 gst_video_crop_transform_dimension (gint val, gint delta)
503 gint64 new_val = (gint64) val + (gint64) delta;
505 new_val = CLAMP (new_val, 1, G_MAXINT);
507 return (gint) new_val;
511 gst_video_crop_transform_dimension_value (const GValue * src_val,
512 gint delta, GValue * dest_val)
516 g_value_init (dest_val, G_VALUE_TYPE (src_val));
518 if (G_VALUE_HOLDS_INT (src_val)) {
519 gint ival = g_value_get_int (src_val);
521 ival = gst_video_crop_transform_dimension (ival, delta);
522 g_value_set_int (dest_val, ival);
523 } else if (GST_VALUE_HOLDS_INT_RANGE (src_val)) {
524 gint min = gst_value_get_int_range_min (src_val);
525 gint max = gst_value_get_int_range_max (src_val);
527 min = gst_video_crop_transform_dimension (min, delta);
528 max = gst_video_crop_transform_dimension (max, delta);
529 gst_value_set_int_range (dest_val, min, max);
530 } else if (GST_VALUE_HOLDS_LIST (src_val)) {
533 for (i = 0; i < gst_value_list_get_size (src_val); ++i) {
534 const GValue *list_val;
535 GValue newval = { 0, };
537 list_val = gst_value_list_get_value (src_val, i);
538 if (gst_video_crop_transform_dimension_value (list_val, delta, &newval))
539 gst_value_list_append_value (dest_val, &newval);
540 g_value_unset (&newval);
543 if (gst_value_list_get_size (dest_val) == 0) {
544 g_value_unset (dest_val);
548 g_value_unset (dest_val);
556 gst_video_crop_transform_caps (GstBaseTransform * trans,
557 GstPadDirection direction, GstCaps * caps)
563 vcrop = GST_VIDEO_CROP (trans);
565 GST_OBJECT_LOCK (vcrop);
567 GST_LOG_OBJECT (vcrop, "l=%d,r=%d,b=%d,t=%d",
568 vcrop->crop_left, vcrop->crop_right, vcrop->crop_bottom, vcrop->crop_top);
570 if (direction == GST_PAD_SRC) {
571 dx = vcrop->crop_left + vcrop->crop_right;
572 dy = vcrop->crop_top + vcrop->crop_bottom;
574 dx = 0 - (vcrop->crop_left + vcrop->crop_right);
575 dy = 0 - (vcrop->crop_top + vcrop->crop_bottom);
577 GST_OBJECT_UNLOCK (vcrop);
579 GST_LOG_OBJECT (vcrop, "transforming caps %" GST_PTR_FORMAT, caps);
581 other_caps = gst_caps_new_empty ();
583 for (i = 0; i < gst_caps_get_size (caps); ++i) {
585 GstStructure *structure, *new_structure;
586 GValue w_val = { 0, }, h_val = {
589 structure = gst_caps_get_structure (caps, i);
591 v = gst_structure_get_value (structure, "width");
592 if (!gst_video_crop_transform_dimension_value (v, dx, &w_val)) {
593 GST_WARNING_OBJECT (vcrop, "could not tranform width value with dx=%d"
594 ", caps structure=%" GST_PTR_FORMAT, dx, structure);
598 v = gst_structure_get_value (structure, "height");
599 if (!gst_video_crop_transform_dimension_value (v, dy, &h_val)) {
600 g_value_unset (&w_val);
601 GST_WARNING_OBJECT (vcrop, "could not tranform height value with dy=%d"
602 ", caps structure=%" GST_PTR_FORMAT, dy, structure);
606 new_structure = gst_structure_copy (structure);
607 gst_structure_set_value (new_structure, "width", &w_val);
608 gst_structure_set_value (new_structure, "height", &h_val);
609 g_value_unset (&w_val);
610 g_value_unset (&h_val);
611 GST_LOG_OBJECT (vcrop, "transformed structure %2d: %" GST_PTR_FORMAT
612 " => %" GST_PTR_FORMAT, i, structure, new_structure);
613 gst_caps_append_structure (other_caps, new_structure);
616 if (gst_caps_is_empty (other_caps)) {
617 gst_caps_unref (other_caps);
625 gst_video_crop_set_caps (GstBaseTransform * trans, GstCaps * incaps,
628 GstVideoCrop *crop = GST_VIDEO_CROP (trans);
630 if (!gst_video_crop_get_image_details_from_caps (crop, &crop->in, incaps))
633 if (!gst_video_crop_get_image_details_from_caps (crop, &crop->out, outcaps))
636 if (G_UNLIKELY ((crop->crop_left + crop->crop_right) >= crop->in.width ||
637 (crop->crop_top + crop->crop_bottom) >= crop->in.height))
638 goto cropping_too_much;
640 GST_LOG_OBJECT (crop, "incaps = %" GST_PTR_FORMAT ", outcaps = %"
641 GST_PTR_FORMAT, incaps, outcaps);
643 if ((crop->crop_left | crop->crop_right | crop->crop_top | crop->
645 GST_LOG_OBJECT (crop, "we are using passthrough");
646 gst_base_transform_set_passthrough (GST_BASE_TRANSFORM (crop), TRUE);
648 GST_LOG_OBJECT (crop, "we are not using passthrough");
649 gst_base_transform_set_passthrough (GST_BASE_TRANSFORM (crop), FALSE);
657 GST_DEBUG_OBJECT (crop, "failed to parse input caps %" GST_PTR_FORMAT,
663 GST_DEBUG_OBJECT (crop, "failed to parse output caps %" GST_PTR_FORMAT,
669 GST_DEBUG_OBJECT (crop, "we are cropping too much");
675 gst_video_crop_set_property (GObject * object, guint prop_id,
676 const GValue * value, GParamSpec * pspec)
678 GstVideoCrop *video_crop;
680 video_crop = GST_VIDEO_CROP (object);
682 /* don't modify while we are transforming */
683 GST_BASE_TRANSFORM_LOCK (GST_BASE_TRANSFORM_CAST (video_crop));
685 /* protect with the object lock so that we can read them */
686 GST_OBJECT_LOCK (video_crop);
689 video_crop->crop_left = g_value_get_int (value);
692 video_crop->crop_right = g_value_get_int (value);
695 video_crop->crop_top = g_value_get_int (value);
698 video_crop->crop_bottom = g_value_get_int (value);
701 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
704 GST_OBJECT_UNLOCK (video_crop);
706 GST_LOG_OBJECT (video_crop, "l=%d,r=%d,b=%d,t=%d",
707 video_crop->crop_left, video_crop->crop_right, video_crop->crop_bottom,
708 video_crop->crop_top);
710 gst_base_transform_reconfigure (GST_BASE_TRANSFORM (video_crop));
711 GST_BASE_TRANSFORM_UNLOCK (GST_BASE_TRANSFORM_CAST (video_crop));
715 gst_video_crop_get_property (GObject * object, guint prop_id, GValue * value,
718 GstVideoCrop *video_crop;
720 video_crop = GST_VIDEO_CROP (object);
722 GST_OBJECT_LOCK (video_crop);
725 g_value_set_int (value, video_crop->crop_left);
728 g_value_set_int (value, video_crop->crop_right);
731 g_value_set_int (value, video_crop->crop_top);
734 g_value_set_int (value, video_crop->crop_bottom);
737 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
740 GST_OBJECT_UNLOCK (video_crop);
744 plugin_init (GstPlugin * plugin)
746 GST_DEBUG_CATEGORY_INIT (videocrop_debug, "videocrop", 0, "videocrop");
748 if (gst_element_register (plugin, "videocrop", GST_RANK_NONE,
750 && gst_element_register (plugin, "aspectratiocrop", GST_RANK_NONE,
751 GST_TYPE_ASPECT_RATIO_CROP))
757 GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
760 "Crops video into a user-defined region",
761 plugin_init, VERSION, GST_LICENSE, GST_PACKAGE_NAME, GST_PACKAGE_ORIGIN)