summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSeungha Yang <seungha@centricular.com>2021-05-19 20:11:15 +0900
committerSeungha Yang <seungha@centricular.com>2021-06-29 18:00:43 +0900
commit2551b1d976dba885f5950a7b3b170389b0f05c2c (patch)
tree827f1b0ce493623f91db7c2dcfda9a092ed9ca9a
parent556ce36ce43c429d8df4032057fe9bcbbb2b69a9 (diff)
downloadgstreamer-plugins-base-2551b1d976dba885f5950a7b3b170389b0f05c2c.tar.gz
video: Deprecate gst_video_sink_center_rect()
... and add gst_video_center_rect() method as a replacement. The method is useful for outside of videosink subclasses as well but the old naming might be able to mislead people. Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-base/-/merge_requests/1156>
-rw-r--r--gst-libs/gst/video/gstvideosink.c68
-rw-r--r--gst-libs/gst/video/gstvideosink.h8
2 files changed, 53 insertions, 23 deletions
diff --git a/gst-libs/gst/video/gstvideosink.c b/gst-libs/gst/video/gstvideosink.c
index 34e3c9d1a..67d634af0 100644
--- a/gst-libs/gst/video/gstvideosink.c
+++ b/gst-libs/gst/video/gstvideosink.c
@@ -93,50 +93,74 @@ static void gst_video_sink_get_times (GstBaseSink * bsink, GstBuffer * buffer,
* gst_video_sink_center_rect:
* @src: the #GstVideoRectangle describing the source area
* @dst: the #GstVideoRectangle describing the destination area
- * @result: a pointer to a #GstVideoRectangle which will receive the result area
+ * @result: (out caller-allocates): a pointer to a #GstVideoRectangle which will receive the result area
+ * @scaling: a #gboolean indicating if scaling should be applied or not
+ *
+ * Deprecated: 1.20: Use gst_video_center_rect() instead.
+ */
+void
+gst_video_sink_center_rect (GstVideoRectangle src, GstVideoRectangle dst,
+ GstVideoRectangle * result, gboolean scaling)
+{
+ gst_video_center_rect (&src, &dst, result, scaling);
+}
+
+/**
+ * gst_video_center_rect:
+ * @src: a pointer to #GstVideoRectangle describing the source area
+ * @dst: a pointer to #GstVideoRectangle describing the destination area
+ * @result: (out caller-allocates): a pointer to a #GstVideoRectangle which will receive the result area
* @scaling: a #gboolean indicating if scaling should be applied or not
*
* Takes @src rectangle and position it at the center of @dst rectangle with or
* without @scaling. It handles clipping if the @src rectangle is bigger than
* the @dst one and @scaling is set to FALSE.
+ *
+ * Since: 1.20
*/
void
-gst_video_sink_center_rect (GstVideoRectangle src, GstVideoRectangle dst,
- GstVideoRectangle * result, gboolean scaling)
+gst_video_center_rect (const GstVideoRectangle * src,
+ const GstVideoRectangle * dst, GstVideoRectangle * result, gboolean scaling)
{
+ g_return_if_fail (src != NULL);
+ g_return_if_fail (dst != NULL);
g_return_if_fail (result != NULL);
if (!scaling) {
- result->w = MIN (src.w, dst.w);
- result->h = MIN (src.h, dst.h);
- result->x = dst.x + (dst.w - result->w) / 2;
- result->y = dst.y + (dst.h - result->h) / 2;
+ result->w = MIN (src->w, dst->w);
+ result->h = MIN (src->h, dst->h);
+ result->x = dst->x + (dst->w - result->w) / 2;
+ result->y = dst->y + (dst->h - result->h) / 2;
} else {
gdouble src_ratio, dst_ratio;
- src_ratio = (gdouble) src.w / src.h;
- dst_ratio = (gdouble) dst.w / dst.h;
+ g_return_if_fail (src->h != 0);
+ g_return_if_fail (dst->h != 0);
+
+ src_ratio = (gdouble) src->w / src->h;
+ dst_ratio = (gdouble) dst->w / dst->h;
if (src_ratio > dst_ratio) {
- result->w = dst.w;
- result->h = dst.w / src_ratio;
- result->x = dst.x;
- result->y = dst.y + (dst.h - result->h) / 2;
+ result->w = dst->w;
+ result->h = dst->w / src_ratio;
+ result->x = dst->x;
+ result->y = dst->y + (dst->h - result->h) / 2;
} else if (src_ratio < dst_ratio) {
- result->w = dst.h * src_ratio;
- result->h = dst.h;
- result->x = dst.x + (dst.w - result->w) / 2;
- result->y = dst.y;
+ result->w = dst->h * src_ratio;
+ result->h = dst->h;
+ result->x = dst->x + (dst->w - result->w) / 2;
+ result->y = dst->y;
} else {
- result->x = dst.x;
- result->y = dst.y;
- result->w = dst.w;
- result->h = dst.h;
+ result->x = dst->x;
+ result->y = dst->y;
+ result->w = dst->w;
+ result->h = dst->h;
}
}
GST_DEBUG ("source is %dx%d dest is %dx%d, result is %dx%d with x,y %dx%d",
- src.w, src.h, dst.w, dst.h, result->w, result->h, result->x, result->y);
+ src->w, src->h, dst->w, dst->h,
+ result->w, result->h, result->x, result->y);
}
/* Initing stuff */
diff --git a/gst-libs/gst/video/gstvideosink.h b/gst-libs/gst/video/gstvideosink.h
index 329b5d2c2..a7a226dde 100644
--- a/gst-libs/gst/video/gstvideosink.h
+++ b/gst-libs/gst/video/gstvideosink.h
@@ -136,10 +136,16 @@ struct _GstVideoSinkClass {
GST_VIDEO_API
GType gst_video_sink_get_type (void);
-GST_VIDEO_API
+GST_VIDEO_DEPRECATED_FOR(gst_video_center_rect)
void gst_video_sink_center_rect (GstVideoRectangle src, GstVideoRectangle dst,
GstVideoRectangle *result, gboolean scaling);
+GST_VIDEO_API
+void gst_video_center_rect (const GstVideoRectangle * src,
+ const GstVideoRectangle * dst,
+ GstVideoRectangle * result,
+ gboolean scaling);
+
G_DEFINE_AUTOPTR_CLEANUP_FUNC(GstVideoSink, gst_object_unref)
G_END_DECLS