mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-10-02 16:52:42 +00:00
gst-libs/gst/video/: Add helper function needed for video sinks.
Original commit message from CVS: 2005-11-16 Julien MOUTTE <julien@moutte.net> * gst-libs/gst/video/gstvideosink.c: (gst_video_sink_center_rect): * gst-libs/gst/video/videosink.h: Add helper function needed for video sinks.
This commit is contained in:
parent
0f873a9ab4
commit
451645fd56
4 changed files with 67 additions and 0 deletions
|
@ -1,3 +1,9 @@
|
|||
2005-11-16 Julien MOUTTE <julien@moutte.net>
|
||||
|
||||
* gst-libs/gst/video/gstvideosink.c: (gst_video_sink_center_rect):
|
||||
* gst-libs/gst/video/videosink.h: Add helper function needed
|
||||
for video sinks.
|
||||
|
||||
2005-11-16 Tim-Philipp Müller <tim at centricular dot net>
|
||||
|
||||
* gst/videoscale/gstvideoscale.c:
|
||||
|
|
|
@ -27,6 +27,45 @@
|
|||
|
||||
static GstElementClass *parent_class = NULL;
|
||||
|
||||
void
|
||||
gst_video_sink_center_rect (GstVideoRectangle src, GstVideoRectangle dst,
|
||||
GstVideoRectangle * result, gboolean scaling)
|
||||
{
|
||||
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.w - result->w) / 2;
|
||||
result->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;
|
||||
|
||||
if (src_ratio > dst_ratio) {
|
||||
result->w = dst.w;
|
||||
result->h = dst.w / src_ratio;
|
||||
result->x = 0;
|
||||
result->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.w - result->w) / 2;
|
||||
result->y = 0;
|
||||
} else {
|
||||
result->x = 0;
|
||||
result->y = 0;
|
||||
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);
|
||||
}
|
||||
|
||||
/* Initing stuff */
|
||||
|
||||
static void
|
||||
|
|
|
@ -46,6 +46,14 @@ G_BEGIN_DECLS
|
|||
|
||||
typedef struct _GstVideoSink GstVideoSink;
|
||||
typedef struct _GstVideoSinkClass GstVideoSinkClass;
|
||||
typedef struct _GstVideoRectangle GstVideoRectangle;
|
||||
|
||||
struct _GstVideoRectangle {
|
||||
gint x;
|
||||
gint y;
|
||||
gint w;
|
||||
gint h;
|
||||
};
|
||||
|
||||
struct _GstVideoSink {
|
||||
GstBaseSink element;
|
||||
|
@ -63,6 +71,9 @@ struct _GstVideoSinkClass {
|
|||
|
||||
GType gst_video_sink_get_type (void);
|
||||
|
||||
void gst_video_sink_center_rect (GstVideoRectangle src, GstVideoRectangle dst,
|
||||
GstVideoRectangle *result, gboolean scaling);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __GST_VIDEO_SINK_H__ */
|
||||
|
|
|
@ -46,6 +46,14 @@ G_BEGIN_DECLS
|
|||
|
||||
typedef struct _GstVideoSink GstVideoSink;
|
||||
typedef struct _GstVideoSinkClass GstVideoSinkClass;
|
||||
typedef struct _GstVideoRectangle GstVideoRectangle;
|
||||
|
||||
struct _GstVideoRectangle {
|
||||
gint x;
|
||||
gint y;
|
||||
gint w;
|
||||
gint h;
|
||||
};
|
||||
|
||||
struct _GstVideoSink {
|
||||
GstBaseSink element;
|
||||
|
@ -63,6 +71,9 @@ struct _GstVideoSinkClass {
|
|||
|
||||
GType gst_video_sink_get_type (void);
|
||||
|
||||
void gst_video_sink_center_rect (GstVideoRectangle src, GstVideoRectangle dst,
|
||||
GstVideoRectangle *result, gboolean scaling);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __GST_VIDEO_SINK_H__ */
|
||||
|
|
Loading…
Reference in a new issue