summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVíctor Manuel Jáquez Leal <victorx.jaquez@intel.com>2015-11-16 17:49:01 +0100
committerVíctor Manuel Jáquez Leal <victorx.jaquez@intel.com>2015-11-19 12:23:22 +0100
commit757833230bc73b8e3b4e31649e4618ba802bea51 (patch)
treee46fa234a6aa158919432bf4e8b84f5e031f94d5
parentfc958520c328641b74ca04b6a416f0c77b8fddc7 (diff)
downloadgst-vaapi-757833230bc73b8e3b4e31649e4618ba802bea51.tar.gz
vaapipostproc: don't set caps change at first set
When the source caps change, the filter is destroyed and recreated. Nonetheless, this happens every time the vaapipostproc starts, since the caps change detection algorithm does not take in consideration when the caps are set by first time. This patch intents to be an optimization, to avoid a useless filter destroy-creation cycle when the sources caps are set for first time. The new helper function video_info_update() is a refactorization to avoid duplicated code. Signed-off-by: Víctor Manuel Jáquez Leal <victorx.jaquez@intel.com> https://bugzilla.gnome.org/show_bug.cgi?id=758007
-rw-r--r--gst/vaapi/gstvaapipostproc.c39
1 files changed, 29 insertions, 10 deletions
diff --git a/gst/vaapi/gstvaapipostproc.c b/gst/vaapi/gstvaapipostproc.c
index 18f3474b..982b69e8 100644
--- a/gst/vaapi/gstvaapipostproc.c
+++ b/gst/vaapi/gstvaapipostproc.c
@@ -855,6 +855,32 @@ video_info_changed (GstVideoInfo * old_vip, GstVideoInfo * new_vip)
return FALSE;
}
+static inline gboolean
+video_info_is_filled (GstVideoInfo * info)
+{
+ return (GST_VIDEO_INFO_FORMAT (info) > GST_VIDEO_FORMAT_UNKNOWN
+ && GST_VIDEO_INFO_WIDTH (info) > 0
+ && GST_VIDEO_INFO_HEIGHT (info) > 0);
+}
+
+static gboolean
+video_info_update (GstCaps * caps, GstVideoInfo * info,
+ gboolean * caps_changed_ptr)
+{
+ GstVideoInfo vi;
+
+ if (!gst_video_info_from_caps (&vi, caps))
+ return FALSE;
+
+ *caps_changed_ptr = FALSE;
+ if (video_info_changed (info, &vi)) {
+ *caps_changed_ptr = video_info_is_filled (info);
+ *info = vi;
+ }
+
+ return TRUE;
+}
+
static gboolean
gst_vaapipostproc_update_sink_caps (GstVaapiPostproc * postproc, GstCaps * caps,
gboolean * caps_changed_ptr)
@@ -864,12 +890,10 @@ gst_vaapipostproc_update_sink_caps (GstVaapiPostproc * postproc, GstCaps * caps,
GST_INFO_OBJECT (postproc, "new sink caps = %" GST_PTR_FORMAT, caps);
- if (!gst_video_info_from_caps (&vi, caps))
+ if (!video_info_update (caps, &postproc->sinkpad_info, caps_changed_ptr))
return FALSE;
- if (video_info_changed (&postproc->sinkpad_info, &vi))
- postproc->sinkpad_info = vi, *caps_changed_ptr = TRUE;
-
+ vi = postproc->sinkpad_info;
deinterlace = is_deinterlace_enabled (postproc, &vi);
if (deinterlace)
postproc->flags |= GST_VAAPI_POSTPROC_FLAG_DEINTERLACE;
@@ -885,16 +909,11 @@ static gboolean
gst_vaapipostproc_update_src_caps (GstVaapiPostproc * postproc, GstCaps * caps,
gboolean * caps_changed_ptr)
{
- GstVideoInfo vi;
-
GST_INFO_OBJECT (postproc, "new src caps = %" GST_PTR_FORMAT, caps);
- if (!gst_video_info_from_caps (&vi, caps))
+ if (!video_info_update (caps, &postproc->srcpad_info, caps_changed_ptr))
return FALSE;
- if (video_info_changed (&postproc->srcpad_info, &vi))
- postproc->srcpad_info = vi, *caps_changed_ptr = TRUE;
-
if (postproc->format != GST_VIDEO_INFO_FORMAT (&postproc->sinkpad_info) &&
postproc->format != DEFAULT_FORMAT)
postproc->flags |= GST_VAAPI_POSTPROC_FLAG_FORMAT;