pluginutil: add gst_video_info_changed() helper

This function is shared among different elements, so let factorized it.

https://bugzilla.gnome.org/show_bug.cgi?id=765435
This commit is contained in:
Víctor Manuel Jáquez Leal 2016-05-20 14:15:53 +02:00
parent 08ee0f9e78
commit 2562cd51be
4 changed files with 29 additions and 10 deletions

View file

@ -670,6 +670,28 @@ gst_video_info_change_format (GstVideoInfo * vip, GstVideoFormat format,
GST_VIDEO_INFO_MULTIVIEW_FLAGS (vip) = GST_VIDEO_INFO_MULTIVIEW_FLAGS (&vi);
}
/**
* gst_video_info_changed:
* @old: old #GstVideoInfo
* @new: new #GstVideoInfo
*
* Compares @old and @new
*
* Returns: %TRUE if @old has different format/width/height than
* @new. Otherwise, %FALSE.
**/
gboolean
gst_video_info_changed (GstVideoInfo * old, GstVideoInfo * new)
{
if (GST_VIDEO_INFO_FORMAT (old) != GST_VIDEO_INFO_FORMAT (new))
return TRUE;
if (GST_VIDEO_INFO_WIDTH (old) != GST_VIDEO_INFO_WIDTH (new))
return TRUE;
if (GST_VIDEO_INFO_HEIGHT (old) != GST_VIDEO_INFO_HEIGHT (new))
return TRUE;
return FALSE;
}
/**
* gst_vaapi_create_test_display:
*

View file

@ -123,6 +123,10 @@ void
gst_video_info_change_format (GstVideoInfo * vip, GstVideoFormat format,
guint width, guint height);
G_GNUC_INTERNAL
gboolean
gst_video_info_changed (GstVideoInfo * old, GstVideoInfo * new);
G_GNUC_INTERNAL
GstVaapiDisplay *
gst_vaapi_create_test_display (void);

View file

@ -833,15 +833,11 @@ error_invalid_buffer:
static gboolean
video_info_changed (GstVideoInfo * old_vip, GstVideoInfo * new_vip)
{
if (GST_VIDEO_INFO_FORMAT (old_vip) != GST_VIDEO_INFO_FORMAT (new_vip))
if (gst_video_info_changed (old_vip, new_vip))
return TRUE;
if (GST_VIDEO_INFO_INTERLACE_MODE (old_vip) !=
GST_VIDEO_INFO_INTERLACE_MODE (new_vip))
return TRUE;
if (GST_VIDEO_INFO_WIDTH (old_vip) != GST_VIDEO_INFO_WIDTH (new_vip))
return TRUE;
if (GST_VIDEO_INFO_HEIGHT (old_vip) != GST_VIDEO_INFO_HEIGHT (new_vip))
return TRUE;
return FALSE;
}

View file

@ -24,6 +24,7 @@
#include "gstvaapivideobufferpool.h"
#include "gstvaapivideobuffer.h"
#include "gstvaapivideomemory.h"
#include "gstvaapipluginutil.h"
#if (USE_GLX || USE_EGL)
#include "gstvaapivideometa_texture.h"
#endif
@ -157,11 +158,7 @@ gst_vaapi_video_buffer_pool_set_config (GstBufferPool * pool,
g_clear_object (&priv->allocator);
}
changed_caps = !priv->allocator ||
GST_VIDEO_INFO_FORMAT (cur_vip) != GST_VIDEO_INFO_FORMAT (new_vip) ||
GST_VIDEO_INFO_WIDTH (cur_vip) != GST_VIDEO_INFO_WIDTH (new_vip) ||
GST_VIDEO_INFO_HEIGHT (cur_vip) != GST_VIDEO_INFO_HEIGHT (new_vip);
changed_caps = !priv->allocator || gst_video_info_changed (cur_vip, new_vip);
if (changed_caps) {
const GstVideoInfo *alloc_vip;
guint flags = 0;