mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-29 11:40:38 +00:00
va: filter: add gst_va_filter_enable_cropping ()
This will toggle the cropping operation in the filter Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/2058>
This commit is contained in:
parent
c770469a8a
commit
c88abb9291
2 changed files with 39 additions and 3 deletions
|
@ -59,6 +59,8 @@ struct _GstVaFilter
|
|||
guint rotation;
|
||||
GstVideoOrientationMethod orientation;
|
||||
|
||||
gboolean crop_enabled;
|
||||
|
||||
VARectangle input_region;
|
||||
VARectangle output_region;
|
||||
|
||||
|
@ -854,6 +856,15 @@ gst_va_filter_get_orientation (GstVaFilter * self)
|
|||
return ret;
|
||||
}
|
||||
|
||||
void
|
||||
gst_va_filter_enable_cropping (GstVaFilter * self, gboolean cropping)
|
||||
{
|
||||
GST_OBJECT_LOCK (self);
|
||||
if (cropping != self->crop_enabled)
|
||||
self->crop_enabled = cropping;
|
||||
GST_OBJECT_UNLOCK (self);
|
||||
}
|
||||
|
||||
static inline GstCaps *
|
||||
_create_base_caps (GstVaFilter * self)
|
||||
{
|
||||
|
@ -1238,14 +1249,37 @@ static gboolean
|
|||
_fill_va_sample (GstVaFilter * self, GstVaSample * sample,
|
||||
GstPadDirection direction)
|
||||
{
|
||||
GstVideoCropMeta *crop;
|
||||
|
||||
sample->surface = gst_va_buffer_get_surface (sample->buffer);
|
||||
if (sample->surface == VA_INVALID_ID)
|
||||
return FALSE;
|
||||
|
||||
/* TODO: handle GstVideoCropMeta */
|
||||
/* XXX: cropping occurs only in input frames */
|
||||
if (direction == GST_PAD_SRC) {
|
||||
GST_OBJECT_LOCK (self);
|
||||
sample->rect = self->output_region;
|
||||
GST_OBJECT_UNLOCK (self);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/* if buffer has crop meta, its real size is in video meta */
|
||||
crop = gst_buffer_get_video_crop_meta (sample->buffer);
|
||||
|
||||
GST_OBJECT_LOCK (self);
|
||||
sample->rect = (direction == GST_PAD_SRC) ?
|
||||
self->output_region : self->input_region;
|
||||
if (crop && self->crop_enabled) {
|
||||
/* *INDENT-OFF* */
|
||||
sample->rect = (VARectangle) {
|
||||
.x = crop->x,
|
||||
.y = crop->y,
|
||||
.width = crop->width,
|
||||
.height = crop->height
|
||||
};
|
||||
/* *INDENT-ON* */
|
||||
} else {
|
||||
sample->rect = self->input_region;
|
||||
}
|
||||
GST_OBJECT_UNLOCK (self);
|
||||
|
||||
return TRUE;
|
||||
|
|
|
@ -68,6 +68,8 @@ gboolean gst_va_filter_install_properties (GstVaFilter * self,
|
|||
gboolean gst_va_filter_set_orientation (GstVaFilter * self,
|
||||
GstVideoOrientationMethod orientation);
|
||||
GstVideoOrientationMethod gst_va_filter_get_orientation (GstVaFilter * self);
|
||||
void gst_va_filter_enable_cropping (GstVaFilter * self,
|
||||
gboolean cropping);
|
||||
const gpointer gst_va_filter_get_filter_caps (GstVaFilter * self,
|
||||
VAProcFilterType type,
|
||||
guint * num_caps);
|
||||
|
|
Loading…
Reference in a new issue