mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-26 03:31:05 +00:00
ges/videourisource: handle non-1/1 PAR source videos
The automatic scaling done by framepositioner does not account for the par of the video source. Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/2423>
This commit is contained in:
parent
ca7081c482
commit
2b94359765
1 changed files with 24 additions and 5 deletions
|
@ -108,6 +108,7 @@ ges_video_uri_source_get_natural_size (GESVideoSource * source, gint * width,
|
|||
const GstTagList *tags = NULL;
|
||||
gchar *rotation_info = NULL;
|
||||
gint videoflip_method, rotate_angle;
|
||||
guint par_n, par_d;
|
||||
GstDiscovererVideoInfo *info =
|
||||
_get_video_stream_info (GES_VIDEO_URI_SOURCE (source));
|
||||
|
||||
|
@ -116,6 +117,21 @@ ges_video_uri_source_get_natural_size (GESVideoSource * source, gint * width,
|
|||
|
||||
*width = gst_discoverer_video_info_get_width (info);
|
||||
*height = gst_discoverer_video_info_get_height (info);
|
||||
|
||||
/* account for source video PAR being not 1/1 */
|
||||
par_n = gst_discoverer_video_info_get_par_num (info);
|
||||
par_d = gst_discoverer_video_info_get_par_denom (info);
|
||||
|
||||
if (par_n > 0 && par_d > 0) {
|
||||
if (*height % par_n == 0) {
|
||||
*height = gst_util_uint64_scale_int (*height, par_d, par_n);
|
||||
} else if (*width % par_d == 0) {
|
||||
*height = gst_util_uint64_scale_int (*width, par_n, par_d);
|
||||
} else {
|
||||
*width = gst_util_uint64_scale_int (*height, par_d, par_n);
|
||||
}
|
||||
}
|
||||
|
||||
if (!ges_timeline_element_lookup_child (GES_TIMELINE_ELEMENT (source),
|
||||
"GstVideoFlip::video-direction", NULL, NULL))
|
||||
goto done;
|
||||
|
@ -151,11 +167,14 @@ done:
|
|||
return TRUE;
|
||||
|
||||
rotate:
|
||||
GST_INFO_OBJECT (source, "Stream is rotated, taking that into account");
|
||||
*width =
|
||||
gst_discoverer_video_info_get_height (GST_DISCOVERER_VIDEO_INFO (info));
|
||||
*height =
|
||||
gst_discoverer_video_info_get_width (GST_DISCOVERER_VIDEO_INFO (info));
|
||||
{
|
||||
gint tmp;
|
||||
|
||||
GST_INFO_OBJECT (source, "Stream is rotated, taking that into account");
|
||||
tmp = *width;
|
||||
*width = *height;
|
||||
*height = tmp;
|
||||
}
|
||||
|
||||
goto done;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue