mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-23 16:50:47 +00:00
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.
This commit is contained in:
parent
b242c5874b
commit
393e86e3d0
4 changed files with 36 additions and 35 deletions
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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 */
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue