From 393e86e3d0a8e8431e44979faffcb075a97b92ae Mon Sep 17 00:00:00 2001 From: Gwenole Beauchesne Date: Fri, 4 Oct 2013 19:30:36 +0200 Subject: [PATCH] plugins: add helper function to disable deinterlacing in caps. Add gst_caps_set_interlaced() helper function that would reset the interlace-mode field to "progressive" for GStreamer >= 1.0, or the interlaced field to "false" for GStreamer 0.10. --- gst/vaapi/gstvaapidecode.c | 6 +----- gst/vaapi/gstvaapipluginutil.c | 29 +++++++++++++++++++++++++++++ gst/vaapi/gstvaapipluginutil.h | 30 ++++-------------------------- gst/vaapi/gstvaapipostproc.c | 6 ++---- 4 files changed, 36 insertions(+), 35 deletions(-) diff --git a/gst/vaapi/gstvaapidecode.c b/gst/vaapi/gstvaapidecode.c index 2f17a3bf05..1b926f8594 100644 --- a/gst/vaapi/gstvaapidecode.c +++ b/gst/vaapi/gstvaapidecode.c @@ -209,11 +209,7 @@ gst_vaapidecode_update_src_caps(GstVaapiDecode *decode, "pixel-aspect-ratio", GST_TYPE_FRACTION, vi->par_n, vi->par_d, NULL); - if (GST_VIDEO_INFO_IS_INTERLACED(vi)) { - GstStructure * const structure = - gst_caps_get_structure(state->caps, 0); - gst_structure_set_interlaced(structure, TRUE); - } + gst_caps_set_interlaced(state->caps, vi); #endif gst_caps_replace(&decode->srcpad_caps, state->caps); return TRUE; diff --git a/gst/vaapi/gstvaapipluginutil.c b/gst/vaapi/gstvaapipluginutil.c index ec1c99c9a1..e30dce2c31 100644 --- a/gst/vaapi/gstvaapipluginutil.c +++ b/gst/vaapi/gstvaapipluginutil.c @@ -380,3 +380,32 @@ gst_vaapi_apply_composition(GstVaapiSurface *surface, GstBuffer *buffer) return gst_vaapi_surface_set_subpictures_from_composition(surface, composition, TRUE); } + +gboolean +gst_caps_set_interlaced(GstCaps *caps, GstVideoInfo *vip) +{ +#if GST_CHECK_VERSION(1,0,0) + GstVideoInterlaceMode mode; + const gchar *mode_str; + + mode = vip ? GST_VIDEO_INFO_INTERLACE_MODE(vip) : + GST_VIDEO_INTERLACE_MODE_PROGRESSIVE; + switch (mode) { + case GST_VIDEO_INTERLACE_MODE_PROGRESSIVE: + mode_str = "progressive"; + break; + case GST_VIDEO_INTERLACE_MODE_INTERLEAVED: + mode_str = "interleaved"; + break; + default: + GST_ERROR("unsupported `interlace-mode' %d", mode); + return FALSE; + } + + gst_caps_set_simple(caps, "interlace-mode", G_TYPE_STRING, mode_str, NULL); +#else + gst_caps_set_simple(caps, "interlaced", G_TYPE_BOOLEAN, + vip ? GST_VIDEO_INFO_IS_INTERLACED(vip) : FALSE, NULL); +#endif + return TRUE; +} diff --git a/gst/vaapi/gstvaapipluginutil.h b/gst/vaapi/gstvaapipluginutil.h index 6212a9d648..a2838197ac 100644 --- a/gst/vaapi/gstvaapipluginutil.h +++ b/gst/vaapi/gstvaapipluginutil.h @@ -67,37 +67,15 @@ gst_vaapi_apply_composition(GstVaapiSurface *surface, GstBuffer *buffer); "interlace-mode = (string){ progressive, interleaved }" # define GST_CAPS_INTERLACED_FALSE \ "interlace-mode = (string)progressive" - -static inline void -gst_structure_remove_interlaced_field(GstStructure *structure) -{ - gst_structure_remove_field(structure, "interlace-mode"); -} - -static inline void -gst_structure_set_interlaced(GstStructure *structure, gboolean interlaced) -{ - gst_structure_set(structure, "interlace-mode", - G_TYPE_STRING, interlaced ? "interleaved" : "progressive", NULL); -} #else # define GST_CAPS_INTERLACED_MODES \ "interlaced = (boolean){ true, false }" # define GST_CAPS_INTERLACED_FALSE \ "interlaced = (boolean)false" - -static inline void -gst_structure_remove_interlaced_field(GstStructure *structure) -{ - gst_structure_remove_field(structure, "interlaced"); -} - -static inline void -gst_structure_set_interlaced(GstStructure *structure, gboolean interlaced) -{ - gst_structure_set(structure, "interlaced", - G_TYPE_BOOLEAN, interlaced, NULL); -} #endif +G_GNUC_INTERNAL +gboolean +gst_caps_set_interlaced(GstCaps *caps, GstVideoInfo *vip); + #endif /* GST_VAAPI_PLUGIN_UTIL_H */ diff --git a/gst/vaapi/gstvaapipostproc.c b/gst/vaapi/gstvaapipostproc.c index 2504fb6b10..ad082cbb29 100755 --- a/gst/vaapi/gstvaapipostproc.c +++ b/gst/vaapi/gstvaapipostproc.c @@ -376,9 +376,7 @@ gst_vaapipostproc_update_src_caps(GstVaapiPostproc *postproc, GstCaps *caps) gst_structure_set(structure, "type", G_TYPE_STRING, "vaapi", NULL); gst_structure_set(structure, "opengl", G_TYPE_BOOLEAN, USE_GLX, NULL); - if (!postproc->deinterlace) - gst_structure_remove_interlaced_field(structure); - else { + if (postproc->deinterlace) { /* Set double framerate in interlaced mode */ if (!gst_util_fraction_multiply(postproc->fps_n, postproc->fps_d, 2, 1, @@ -387,8 +385,8 @@ gst_vaapipostproc_update_src_caps(GstVaapiPostproc *postproc, GstCaps *caps) gst_structure_set(structure, "framerate", GST_TYPE_FRACTION, fps_n, fps_d, NULL); - gst_structure_set_interlaced(structure, FALSE); } + gst_caps_set_interlaced(src_caps, NULL); return gst_pad_set_caps(postproc->srcpad, src_caps); }