mirror of
https://github.com/brl/mutter.git
synced 2024-11-22 16:10:41 -05:00
cogl-gst: add cogl_gst_video_sink_get_natural_size() api
This adds api for querying a "natural" width and height for a video which has the correct aspect ratio for displaying on square, 1:1 pixels. The natural size is the minimum size where downscaling is not required. Reviewed-by: Neil Roberts <neil@linux.intel.com>
This commit is contained in:
parent
0e2771a4a4
commit
849f691969
@ -1658,6 +1658,54 @@ cogl_gst_video_sink_fit_size (CoglGstVideoSink *vt,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
cogl_gst_video_sink_get_natural_size (CoglGstVideoSink *vt,
|
||||||
|
float *width,
|
||||||
|
float *height)
|
||||||
|
{
|
||||||
|
GstVideoInfo *info;
|
||||||
|
|
||||||
|
g_return_val_if_fail (COGL_GST_IS_VIDEO_SINK (vt), 0.);
|
||||||
|
|
||||||
|
info = &vt->priv->info;
|
||||||
|
|
||||||
|
if (info->par_n > info->par_d)
|
||||||
|
{
|
||||||
|
/* To display the video at the right aspect ratio then in this
|
||||||
|
* case the pixels need to be stretched horizontally and so we
|
||||||
|
* use the unscaled height as our reference.
|
||||||
|
*/
|
||||||
|
|
||||||
|
if (height)
|
||||||
|
*height = info->height;
|
||||||
|
if (width)
|
||||||
|
*width = cogl_gst_video_sink_get_width_for_height (vt, info->height);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (width)
|
||||||
|
*width = info->width;
|
||||||
|
if (height)
|
||||||
|
*height = cogl_gst_video_sink_get_height_for_width (vt, info->width);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
float
|
||||||
|
cogl_gst_video_sink_get_natural_width (CoglGstVideoSink *vt)
|
||||||
|
{
|
||||||
|
float width;
|
||||||
|
cogl_gst_video_sink_get_natural_size (vt, &width, NULL);
|
||||||
|
return width;
|
||||||
|
}
|
||||||
|
|
||||||
|
float
|
||||||
|
cogl_gst_video_sink_get_natural_height (CoglGstVideoSink *vt)
|
||||||
|
{
|
||||||
|
float height;
|
||||||
|
cogl_gst_video_sink_get_natural_size (vt, NULL, &height);
|
||||||
|
return height;
|
||||||
|
}
|
||||||
|
|
||||||
CoglBool
|
CoglBool
|
||||||
cogl_gst_video_sink_is_ready (CoglGstVideoSink *sink)
|
cogl_gst_video_sink_is_ready (CoglGstVideoSink *sink)
|
||||||
{
|
{
|
||||||
|
@ -412,6 +412,77 @@ float
|
|||||||
cogl_gst_video_sink_get_height_for_width (CoglGstVideoSink *sink,
|
cogl_gst_video_sink_get_height_for_width (CoglGstVideoSink *sink,
|
||||||
float width);
|
float width);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* cogl_gst_video_sink_get_natural_size:
|
||||||
|
* @sink: A #CoglGstVideoSink
|
||||||
|
* @width: (out): return location for the video's natural width
|
||||||
|
* @height: (out): return location for the video's natural height
|
||||||
|
*
|
||||||
|
* Considering the real resolution of the video as well as the aspect
|
||||||
|
* ratio of pixel data that may need to be stretched when being displayed;
|
||||||
|
* this function calculates what the natural size of the underlying
|
||||||
|
* video source is.
|
||||||
|
*
|
||||||
|
* The natural size has the correct aspect ratio for displaying the
|
||||||
|
* video and is the minimum size where downscaling is not required.
|
||||||
|
*
|
||||||
|
* <note>This natural size is calculated assuming that the video will
|
||||||
|
* be displayed on square pixels.</note>
|
||||||
|
*
|
||||||
|
* Since: 1.18
|
||||||
|
* Stability: unstable
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
cogl_gst_video_sink_get_natural_size (CoglGstVideoSink *sink,
|
||||||
|
float *width,
|
||||||
|
float *height);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* cogl_gst_video_sink_get_natural_width:
|
||||||
|
* @sink: A #CoglGstVideoSink
|
||||||
|
*
|
||||||
|
* Considering the real resolution of the video as well as the aspect
|
||||||
|
* ratio of pixel data that may need to be stretched when being displayed;
|
||||||
|
* this function calculates what the natural size of the underlying
|
||||||
|
* video source is, and returns its width.
|
||||||
|
*
|
||||||
|
* The natural size has the correct aspect ratio for displaying the
|
||||||
|
* video and is the minimum size where downscaling is not required.
|
||||||
|
*
|
||||||
|
* <note>This natural size is calculated assuming that the video will
|
||||||
|
* be displayed on square pixels.</note>
|
||||||
|
*
|
||||||
|
* Return value: The video's natural width
|
||||||
|
*
|
||||||
|
* Since: 1.18
|
||||||
|
* Stability: unstable
|
||||||
|
*/
|
||||||
|
float
|
||||||
|
cogl_gst_video_sink_get_natural_width (CoglGstVideoSink *sink);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* cogl_gst_video_sink_get_natural_height:
|
||||||
|
* @sink: A #CoglGstVideoSink
|
||||||
|
*
|
||||||
|
* Considering the real resolution of the video as well as the aspect
|
||||||
|
* ratio of pixel data that may need to be stretched when being displayed;
|
||||||
|
* this function calculates what the natural size of the underlying
|
||||||
|
* video source is, and returns its height.
|
||||||
|
*
|
||||||
|
* The natural size has the correct aspect ratio for displaying the
|
||||||
|
* video and is the minimum size where downscaling is not required.
|
||||||
|
*
|
||||||
|
* <note>This natural size is calculated assuming that the video will
|
||||||
|
* be displayed on square pixels.</note>
|
||||||
|
*
|
||||||
|
* Return value: The video's natural height
|
||||||
|
*
|
||||||
|
* Since: 1.18
|
||||||
|
* Stability: unstable
|
||||||
|
*/
|
||||||
|
float
|
||||||
|
cogl_gst_video_sink_get_natural_height (CoglGstVideoSink *sink);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* CoglGstRectangle:
|
* CoglGstRectangle:
|
||||||
* @x: The X coordinate of the top left of the rectangle
|
* @x: The X coordinate of the top left of the rectangle
|
||||||
|
Loading…
Reference in New Issue
Block a user