plugins: re-indent all video processing related source code.

This commit is contained in:
Gwenole Beauchesne 2014-11-24 14:10:11 +01:00
parent cf352336b3
commit 9c888b8b8e
4 changed files with 1747 additions and 1794 deletions

View file

@ -56,6 +56,7 @@ GST_DEBUG_CATEGORY_STATIC(gst_debug_vaapipostproc);
#endif #endif
/* Default templates */ /* Default templates */
/* *INDENT-OFF* */
static const char gst_vaapipostproc_sink_caps_str[] = static const char gst_vaapipostproc_sink_caps_str[] =
GST_VAAPIPOSTPROC_SURFACE_CAPS ", " GST_VAAPIPOSTPROC_SURFACE_CAPS ", "
GST_CAPS_INTERLACED_MODES "; " GST_CAPS_INTERLACED_MODES "; "
@ -68,7 +69,9 @@ static const char gst_vaapipostproc_sink_caps_str[] =
"framerate = " GST_VIDEO_FPS_RANGE ", " "framerate = " GST_VIDEO_FPS_RANGE ", "
#endif #endif
GST_CAPS_INTERLACED_MODES; GST_CAPS_INTERLACED_MODES;
/* *INDENT-ON* */
/* *INDENT-OFF* */
static const char gst_vaapipostproc_src_caps_str[] = static const char gst_vaapipostproc_src_caps_str[] =
GST_VAAPIPOSTPROC_SURFACE_CAPS ", " GST_VAAPIPOSTPROC_SURFACE_CAPS ", "
GST_CAPS_INTERLACED_FALSE "; " GST_CAPS_INTERLACED_FALSE "; "
@ -86,28 +89,29 @@ static const char gst_vaapipostproc_src_caps_str[] =
"framerate = " GST_VIDEO_FPS_RANGE ", " "framerate = " GST_VIDEO_FPS_RANGE ", "
#endif #endif
GST_CAPS_INTERLACED_FALSE; GST_CAPS_INTERLACED_FALSE;
/* *INDENT-ON* */
/* *INDENT-OFF* */
static GstStaticPadTemplate gst_vaapipostproc_sink_factory = static GstStaticPadTemplate gst_vaapipostproc_sink_factory =
GST_STATIC_PAD_TEMPLATE( GST_STATIC_PAD_TEMPLATE ("sink",
"sink",
GST_PAD_SINK, GST_PAD_SINK,
GST_PAD_ALWAYS, GST_PAD_ALWAYS,
GST_STATIC_CAPS (gst_vaapipostproc_sink_caps_str)); GST_STATIC_CAPS (gst_vaapipostproc_sink_caps_str));
/* *INDENT-ON* */
/* *INDENT-OFF* */
static GstStaticPadTemplate gst_vaapipostproc_src_factory = static GstStaticPadTemplate gst_vaapipostproc_src_factory =
GST_STATIC_PAD_TEMPLATE( GST_STATIC_PAD_TEMPLATE ("src",
"src",
GST_PAD_SRC, GST_PAD_SRC,
GST_PAD_ALWAYS, GST_PAD_ALWAYS,
GST_STATIC_CAPS (gst_vaapipostproc_src_caps_str)); GST_STATIC_CAPS (gst_vaapipostproc_src_caps_str));
/* *INDENT-ON* */
G_DEFINE_TYPE_WITH_CODE( G_DEFINE_TYPE_WITH_CODE (GstVaapiPostproc, gst_vaapipostproc,
GstVaapiPostproc, GST_TYPE_BASE_TRANSFORM, GST_VAAPI_PLUGIN_BASE_INIT_INTERFACES);
gst_vaapipostproc,
GST_TYPE_BASE_TRANSFORM,
GST_VAAPI_PLUGIN_BASE_INIT_INTERFACES)
enum { enum
{
PROP_0, PROP_0,
PROP_FORMAT, PROP_FORMAT,
@ -198,8 +202,7 @@ ds_set_surfaces(GstVaapiDeinterlaceState *ds)
break; break;
meta = gst_buffer_get_vaapi_video_meta (buf); meta = gst_buffer_get_vaapi_video_meta (buf);
ds->surfaces[ds->num_surfaces++] = ds->surfaces[ds->num_surfaces++] = gst_vaapi_video_meta_get_surface (meta);
gst_vaapi_video_meta_get_surface(meta);
} }
} }
@ -210,8 +213,7 @@ find_filter_op(GPtrArray *filter_ops, GstVaapiFilterOp op)
if (filter_ops) { if (filter_ops) {
for (i = 0; i < filter_ops->len; i++) { for (i = 0; i < filter_ops->len; i++) {
GstVaapiFilterOpInfo * const filter_op = GstVaapiFilterOpInfo *const filter_op = g_ptr_array_index (filter_ops, i);
g_ptr_array_index(filter_ops, i);
if (filter_op->op == op) if (filter_op->op == op)
return filter_op; return filter_op;
} }
@ -222,7 +224,8 @@ find_filter_op(GPtrArray *filter_ops, GstVaapiFilterOp op)
static inline gboolean static inline gboolean
gst_vaapipostproc_ensure_display (GstVaapiPostproc * postproc) gst_vaapipostproc_ensure_display (GstVaapiPostproc * postproc)
{ {
return gst_vaapi_plugin_base_ensure_display(GST_VAAPI_PLUGIN_BASE(postproc)); return
gst_vaapi_plugin_base_ensure_display (GST_VAAPI_PLUGIN_BASE (postproc));
} }
static gboolean static gboolean
@ -244,8 +247,8 @@ gst_vaapipostproc_ensure_filter(GstVaapiPostproc *postproc)
if (!gst_vaapipostproc_ensure_display (postproc)) if (!gst_vaapipostproc_ensure_display (postproc))
return FALSE; return FALSE;
postproc->filter = gst_vaapi_filter_new( postproc->filter =
GST_VAAPI_PLUGIN_BASE_DISPLAY(postproc)); gst_vaapi_filter_new (GST_VAAPI_PLUGIN_BASE_DISPLAY (postproc));
if (!postproc->filter) if (!postproc->filter)
return FALSE; return FALSE;
return TRUE; return TRUE;
@ -427,8 +430,7 @@ append_output_buffer_metadata(GstVaapiPostproc *postproc, GstBuffer *outbuf,
/* GstVideoCropMeta */ /* GstVideoCropMeta */
#if GST_CHECK_VERSION(1,0,0) #if GST_CHECK_VERSION(1,0,0)
if (!postproc->use_vpp) { if (!postproc->use_vpp) {
GstVideoCropMeta * const crop_meta = GstVideoCropMeta *const crop_meta = gst_buffer_get_video_crop_meta (inbuf);
gst_buffer_get_video_crop_meta(inbuf);
if (crop_meta) { if (crop_meta) {
GstVideoCropMeta *const out_crop_meta = GstVideoCropMeta *const out_crop_meta =
gst_buffer_add_video_crop_meta (outbuf); gst_buffer_add_video_crop_meta (outbuf);
@ -541,28 +543,23 @@ gst_vaapipostproc_process_vpp(GstBaseTransform *trans, GstBuffer *inbuf,
return GST_FLOW_NOT_SUPPORTED; return GST_FLOW_NOT_SUPPORTED;
if ((postproc->flags & GST_VAAPI_POSTPROC_FLAG_HUE) && if ((postproc->flags & GST_VAAPI_POSTPROC_FLAG_HUE) &&
!gst_vaapi_filter_set_hue(postproc->filter, !gst_vaapi_filter_set_hue (postproc->filter, postproc->hue))
postproc->hue))
return GST_FLOW_NOT_SUPPORTED; return GST_FLOW_NOT_SUPPORTED;
if ((postproc->flags & GST_VAAPI_POSTPROC_FLAG_SATURATION) && if ((postproc->flags & GST_VAAPI_POSTPROC_FLAG_SATURATION) &&
!gst_vaapi_filter_set_saturation(postproc->filter, !gst_vaapi_filter_set_saturation (postproc->filter, postproc->saturation))
postproc->saturation))
return GST_FLOW_NOT_SUPPORTED; return GST_FLOW_NOT_SUPPORTED;
if ((postproc->flags & GST_VAAPI_POSTPROC_FLAG_BRIGHTNESS) && if ((postproc->flags & GST_VAAPI_POSTPROC_FLAG_BRIGHTNESS) &&
!gst_vaapi_filter_set_brightness(postproc->filter, !gst_vaapi_filter_set_brightness (postproc->filter, postproc->brightness))
postproc->brightness))
return GST_FLOW_NOT_SUPPORTED; return GST_FLOW_NOT_SUPPORTED;
if ((postproc->flags & GST_VAAPI_POSTPROC_FLAG_CONTRAST) && if ((postproc->flags & GST_VAAPI_POSTPROC_FLAG_CONTRAST) &&
!gst_vaapi_filter_set_contrast(postproc->filter, !gst_vaapi_filter_set_contrast (postproc->filter, postproc->contrast))
postproc->contrast))
return GST_FLOW_NOT_SUPPORTED; return GST_FLOW_NOT_SUPPORTED;
if ((postproc->flags & GST_VAAPI_POSTPROC_FLAG_SCALE) && if ((postproc->flags & GST_VAAPI_POSTPROC_FLAG_SCALE) &&
!gst_vaapi_filter_set_scaling(postproc->filter, !gst_vaapi_filter_set_scaling (postproc->filter, postproc->scale_method))
postproc->scale_method))
return GST_FLOW_NOT_SUPPORTED; return GST_FLOW_NOT_SUPPORTED;
inbuf_meta = gst_buffer_get_vaapi_video_meta (inbuf); inbuf_meta = gst_buffer_get_vaapi_video_meta (inbuf);
@ -571,8 +568,7 @@ gst_vaapipostproc_process_vpp(GstBaseTransform *trans, GstBuffer *inbuf,
inbuf_surface = gst_vaapi_video_meta_get_surface (inbuf_meta); inbuf_surface = gst_vaapi_video_meta_get_surface (inbuf_meta);
#if GST_CHECK_VERSION(1,0,0) #if GST_CHECK_VERSION(1,0,0)
GstVideoCropMeta * const crop_meta = GstVideoCropMeta *const crop_meta = gst_buffer_get_video_crop_meta (inbuf);
gst_buffer_get_video_crop_meta(inbuf);
if (crop_meta) { if (crop_meta) {
crop_rect = &tmp_rect; crop_rect = &tmp_rect;
crop_rect->x = crop_meta->x; crop_rect->x = crop_meta->x;
@ -624,8 +620,9 @@ gst_vaapipostproc_process_vpp(GstBaseTransform *trans, GstBuffer *inbuf,
if (!outbuf_meta) if (!outbuf_meta)
goto error_create_meta; goto error_create_meta;
proxy = gst_vaapi_surface_proxy_new_from_pool( proxy =
GST_VAAPI_SURFACE_POOL(postproc->filter_pool)); gst_vaapi_surface_proxy_new_from_pool (GST_VAAPI_SURFACE_POOL
(postproc->filter_pool));
if (!proxy) if (!proxy)
goto error_create_proxy; goto error_create_proxy;
gst_vaapi_video_meta_set_surface_proxy (outbuf_meta, proxy); gst_vaapi_video_meta_set_surface_proxy (outbuf_meta, proxy);
@ -647,13 +644,11 @@ gst_vaapipostproc_process_vpp(GstBaseTransform *trans, GstBuffer *inbuf,
if (deint_refs) { if (deint_refs) {
ds_set_surfaces (ds); ds_set_surfaces (ds);
if (!gst_vaapi_filter_set_deinterlacing_references( if (!gst_vaapi_filter_set_deinterlacing_references (postproc->filter,
postproc->filter, ds->surfaces, ds->num_surfaces, ds->surfaces, ds->num_surfaces, NULL, 0))
NULL, 0))
goto error_op_deinterlace; goto error_op_deinterlace;
} }
} } else if (deint_changed) {
else if (deint_changed) {
// Reset internal filter to non-deinterlacing mode // Reset internal filter to non-deinterlacing mode
deint_method = GST_VAAPI_DEINTERLACE_METHOD_NONE; deint_method = GST_VAAPI_DEINTERLACE_METHOD_NONE;
if (!gst_vaapi_filter_set_deinterlacing (postproc->filter, if (!gst_vaapi_filter_set_deinterlacing (postproc->filter,
@ -681,8 +676,9 @@ gst_vaapipostproc_process_vpp(GstBaseTransform *trans, GstBuffer *inbuf,
if (!outbuf_meta) if (!outbuf_meta)
goto error_create_meta; goto error_create_meta;
proxy = gst_vaapi_surface_proxy_new_from_pool( proxy =
GST_VAAPI_SURFACE_POOL(postproc->filter_pool)); gst_vaapi_surface_proxy_new_from_pool (GST_VAAPI_SURFACE_POOL
(postproc->filter_pool));
if (!proxy) if (!proxy)
goto error_create_proxy; goto error_create_proxy;
gst_vaapi_video_meta_set_surface_proxy (outbuf_meta, proxy); gst_vaapi_video_meta_set_surface_proxy (outbuf_meta, proxy);
@ -696,12 +692,13 @@ gst_vaapipostproc_process_vpp(GstBaseTransform *trans, GstBuffer *inbuf,
deint_method, deint_flags)) deint_method, deint_flags))
goto error_op_deinterlace; goto error_op_deinterlace;
if (deint_refs && !gst_vaapi_filter_set_deinterlacing_references( if (deint_refs
postproc->filter, ds->surfaces, ds->num_surfaces, NULL, 0)) && !gst_vaapi_filter_set_deinterlacing_references (postproc->filter,
ds->surfaces, ds->num_surfaces, NULL, 0))
goto error_op_deinterlace; goto error_op_deinterlace;
} } else if (deint_changed
else if (deint_changed && !gst_vaapi_filter_set_deinterlacing( && !gst_vaapi_filter_set_deinterlacing (postproc->filter, deint_method,
postproc->filter, deint_method, 0)) 0))
goto error_op_deinterlace; goto error_op_deinterlace;
outbuf_surface = gst_vaapi_video_meta_get_surface (outbuf_meta); outbuf_surface = gst_vaapi_video_meta_get_surface (outbuf_meta);
@ -797,8 +794,7 @@ gst_vaapipostproc_process(GstBaseTransform *trans, GstBuffer *inbuf,
meta = gst_buffer_get_vaapi_video_meta (fieldbuf); meta = gst_buffer_get_vaapi_video_meta (fieldbuf);
fieldbuf_flags = flags; fieldbuf_flags = flags;
fieldbuf_flags |= deint ? ( fieldbuf_flags |= deint ? (tff ?
tff ?
GST_VAAPI_PICTURE_STRUCTURE_TOP_FIELD : GST_VAAPI_PICTURE_STRUCTURE_TOP_FIELD :
GST_VAAPI_PICTURE_STRUCTURE_BOTTOM_FIELD) : GST_VAAPI_PICTURE_STRUCTURE_BOTTOM_FIELD) :
GST_VAAPI_PICTURE_STRUCTURE_FRAME; GST_VAAPI_PICTURE_STRUCTURE_FRAME;
@ -815,8 +811,7 @@ gst_vaapipostproc_process(GstBaseTransform *trans, GstBuffer *inbuf,
meta = gst_buffer_get_vaapi_video_meta (outbuf); meta = gst_buffer_get_vaapi_video_meta (outbuf);
outbuf_flags = flags; outbuf_flags = flags;
outbuf_flags |= deint ? ( outbuf_flags |= deint ? (tff ?
tff ?
GST_VAAPI_PICTURE_STRUCTURE_BOTTOM_FIELD : GST_VAAPI_PICTURE_STRUCTURE_BOTTOM_FIELD :
GST_VAAPI_PICTURE_STRUCTURE_TOP_FIELD) : GST_VAAPI_PICTURE_STRUCTURE_TOP_FIELD) :
GST_VAAPI_PICTURE_STRUCTURE_FRAME; GST_VAAPI_PICTURE_STRUCTURE_FRAME;
@ -971,8 +966,7 @@ ensure_allowed_sinkpad_caps(GstVaapiPostproc *postproc)
if (raw_caps) { if (raw_caps) {
out_caps = gst_caps_make_writable (out_caps); out_caps = gst_caps_make_writable (out_caps);
gst_caps_append (out_caps, gst_caps_copy (raw_caps)); gst_caps_append (out_caps, gst_caps_copy (raw_caps));
} } else
else
GST_WARNING ("failed to create YUV sink caps"); GST_WARNING ("failed to create YUV sink caps");
} }
postproc->allowed_sinkpad_caps = out_caps; postproc->allowed_sinkpad_caps = out_caps;
@ -1056,19 +1050,16 @@ find_best_size(GstVaapiPostproc *postproc, GstVideoInfo *vip,
if (postproc->width && postproc->height) { if (postproc->width && postproc->height) {
width = postproc->width; width = postproc->width;
height = postproc->height; height = postproc->height;
} } else if (postproc->keep_aspect) {
else if (postproc->keep_aspect) {
const gdouble ratio = (gdouble) width / height; const gdouble ratio = (gdouble) width / height;
if (postproc->width) { if (postproc->width) {
width = postproc->width; width = postproc->width;
height = postproc->width / ratio; height = postproc->width / ratio;
} } else if (postproc->height) {
else if (postproc->height) {
height = postproc->height; height = postproc->height;
width = postproc->height * ratio; width = postproc->height * ratio;
} }
} } else if (postproc->width)
else if (postproc->width)
width = postproc->width; width = postproc->width;
else if (postproc->height) else if (postproc->height)
height = postproc->height; height = postproc->height;
@ -1138,9 +1129,11 @@ gst_vaapipostproc_transform_caps_impl(GstBaseTransform *trans,
else { else {
GstCaps *peer_caps, *filter_caps; GstCaps *peer_caps, *filter_caps;
GstVideoInfo peer_vi; GstVideoInfo peer_vi;
filter_caps = gst_caps_from_string (GST_VIDEO_CAPS_MAKE(GST_VIDEO_FORMATS_ALL)); filter_caps =
peer_caps = gst_pad_peer_query_caps( gst_caps_from_string (GST_VIDEO_CAPS_MAKE (GST_VIDEO_FORMATS_ALL));
GST_BASE_TRANSFORM_SRC_PAD(trans), filter_caps); peer_caps =
gst_pad_peer_query_caps (GST_BASE_TRANSFORM_SRC_PAD (trans),
filter_caps);
if (!gst_caps_is_fixed (peer_caps)) if (!gst_caps_is_fixed (peer_caps))
peer_caps = gst_caps_fixate (peer_caps); peer_caps = gst_caps_fixate (peer_caps);
gst_video_info_from_caps (&peer_vi, peer_caps); gst_video_info_from_caps (&peer_vi, peer_caps);
@ -1160,8 +1153,9 @@ gst_vaapipostproc_transform_caps_impl(GstBaseTransform *trans,
if (!out_caps) if (!out_caps)
return NULL; return NULL;
feature = gst_vaapi_find_preferred_caps_feature( feature =
GST_BASE_TRANSFORM_SRC_PAD(trans), out_format); gst_vaapi_find_preferred_caps_feature (GST_BASE_TRANSFORM_SRC_PAD (trans),
out_format);
if (feature) { if (feature) {
feature_str = gst_vaapi_caps_feature_to_string (feature); feature_str = gst_vaapi_caps_feature_to_string (feature);
if (feature_str) if (feature_str)
@ -1206,8 +1200,7 @@ gst_vaapipostproc_transform_caps_impl(GstBaseTransform *trans,
"framerate", GST_TYPE_FRACTION, GST_VIDEO_INFO_FPS_N (&vi), "framerate", GST_TYPE_FRACTION, GST_VIDEO_INFO_FPS_N (&vi),
GST_VIDEO_INFO_FPS_D (&vi), GST_VIDEO_INFO_FPS_D (&vi),
"pixel-aspect-ratio", GST_TYPE_FRACTION, GST_VIDEO_INFO_PAR_N (&vi), "pixel-aspect-ratio", GST_TYPE_FRACTION, GST_VIDEO_INFO_PAR_N (&vi),
GST_VIDEO_INFO_PAR_D(&vi), GST_VIDEO_INFO_PAR_D (&vi), NULL);
NULL);
gst_caps_set_interlaced (out_caps, &vi); gst_caps_set_interlaced (out_caps, &vi);
#endif #endif
@ -1223,8 +1216,7 @@ gst_vaapipostproc_transform_caps(GstBaseTransform *trans,
caps = gst_vaapipostproc_transform_caps_impl (trans, direction, caps); caps = gst_vaapipostproc_transform_caps_impl (trans, direction, caps);
if (caps && filter) { if (caps && filter) {
out_caps = gst_caps_intersect_full(caps, filter, out_caps = gst_caps_intersect_full (caps, filter, GST_CAPS_INTERSECT_FIRST);
GST_CAPS_INTERSECT_FIRST);
gst_caps_unref (caps); gst_caps_unref (caps);
return out_caps; return out_caps;
} }
@ -1263,8 +1255,9 @@ gst_vaapipostproc_transform(GstBaseTransform *trans, GstBuffer *inbuf,
GstBuffer *buf; GstBuffer *buf;
GstFlowReturn ret; GstFlowReturn ret;
ret = gst_vaapi_plugin_base_get_input_buffer( ret =
GST_VAAPI_PLUGIN_BASE(postproc), inbuf, &buf); gst_vaapi_plugin_base_get_input_buffer (GST_VAAPI_PLUGIN_BASE (postproc),
inbuf, &buf);
if (ret != GST_FLOW_OK) if (ret != GST_FLOW_OK)
return GST_FLOW_ERROR; return GST_FLOW_ERROR;
@ -1321,7 +1314,8 @@ ensure_srcpad_buffer_pool(GstVaapiPostproc *postproc, GstCaps *caps)
gst_video_info_change_format (&vi, postproc->format, gst_video_info_change_format (&vi, postproc->format,
GST_VIDEO_INFO_WIDTH (&vi), GST_VIDEO_INFO_HEIGHT (&vi)); GST_VIDEO_INFO_WIDTH (&vi), GST_VIDEO_INFO_HEIGHT (&vi));
if (postproc->filter_pool && !video_info_changed(&vi, &postproc->filter_pool_info)) if (postproc->filter_pool
&& !video_info_changed (&vi, &postproc->filter_pool_info))
return TRUE; return TRUE;
postproc->filter_pool_info = vi; postproc->filter_pool_info = vi;
@ -1369,13 +1363,15 @@ gst_vaapipostproc_query(GstBaseTransform *trans, GstPadDirection direction,
GST_INFO_OBJECT (trans, "query type `%s'", GST_QUERY_TYPE_NAME (query)); GST_INFO_OBJECT (trans, "query type `%s'", GST_QUERY_TYPE_NAME (query));
if (gst_vaapi_reply_to_query(query, GST_VAAPI_PLUGIN_BASE_DISPLAY(postproc))) { if (gst_vaapi_reply_to_query (query,
GST_VAAPI_PLUGIN_BASE_DISPLAY (postproc))) {
GST_DEBUG ("sharing display %p", GST_VAAPI_PLUGIN_BASE_DISPLAY (postproc)); GST_DEBUG ("sharing display %p", GST_VAAPI_PLUGIN_BASE_DISPLAY (postproc));
return TRUE; return TRUE;
} }
return GST_BASE_TRANSFORM_CLASS(gst_vaapipostproc_parent_class)->query( return
trans, direction, query); GST_BASE_TRANSFORM_CLASS (gst_vaapipostproc_parent_class)->query (trans,
direction, query);
} }
#if GST_CHECK_VERSION(1,0,0) #if GST_CHECK_VERSION(1,0,0)
@ -1414,12 +1410,8 @@ gst_vaapipostproc_finalize(GObject *object)
} }
static void static void
gst_vaapipostproc_set_property( gst_vaapipostproc_set_property (GObject * object,
GObject *object, guint prop_id, const GValue * value, GParamSpec * pspec)
guint prop_id,
const GValue *value,
GParamSpec *pspec
)
{ {
GstVaapiPostproc *const postproc = GST_VAAPIPOSTPROC (object); GstVaapiPostproc *const postproc = GST_VAAPIPOSTPROC (object);
@ -1477,12 +1469,8 @@ gst_vaapipostproc_set_property(
} }
static void static void
gst_vaapipostproc_get_property( gst_vaapipostproc_get_property (GObject * object,
GObject *object, guint prop_id, GValue * value, GParamSpec * pspec)
guint prop_id,
GValue *value,
GParamSpec *pspec
)
{ {
GstVaapiPostproc *const postproc = GST_VAAPIPOSTPROC (object); GstVaapiPostproc *const postproc = GST_VAAPIPOSTPROC (object);
@ -1563,15 +1551,13 @@ gst_vaapipostproc_class_init(GstVaapiPostprocClass *klass)
trans_class->decide_allocation = gst_vaapipostproc_decide_allocation; trans_class->decide_allocation = gst_vaapipostproc_decide_allocation;
#endif #endif
trans_class->prepare_output_buffer = trans_class->prepare_output_buffer = gst_vaapipostproc_prepare_output_buffer;
gst_vaapipostproc_prepare_output_buffer;
gst_element_class_set_static_metadata (element_class, gst_element_class_set_static_metadata (element_class,
"VA-API video postprocessing", "VA-API video postprocessing",
"Filter/Converter/Video;Filter/Converter/Video/Scaler;" "Filter/Converter/Video;Filter/Converter/Video/Scaler;"
"Filter/Effect/Video;Filter/Effect/Video/Deinterlace", "Filter/Effect/Video;Filter/Effect/Video/Deinterlace",
GST_PLUGIN_DESC, GST_PLUGIN_DESC, "Gwenole Beauchesne <gwenole.beauchesne@intel.com>");
"Gwenole Beauchesne <gwenole.beauchesne@intel.com>");
/* sink pad */ /* sink pad */
pad_template = gst_static_pad_template_get (&gst_vaapipostproc_sink_factory); pad_template = gst_static_pad_template_get (&gst_vaapipostproc_sink_factory);
@ -1584,9 +1570,9 @@ gst_vaapipostproc_class_init(GstVaapiPostprocClass *klass)
/** /**
* GstVaapiPostproc:deinterlace-mode: * GstVaapiPostproc:deinterlace-mode:
* *
* This selects whether the deinterlacing should always be applied or if * This selects whether the deinterlacing should always be applied
* they should only be applied on content that has the "interlaced" flag * or if they should only be applied on content that has the
* on the caps. * "interlaced" flag on the caps.
*/ */
g_object_class_install_property g_object_class_install_property
(object_class, (object_class,
@ -1640,14 +1626,13 @@ gst_vaapipostproc_class_init(GstVaapiPostprocClass *klass)
g_param_spec_uint ("width", g_param_spec_uint ("width",
"Width", "Width",
"Forced output width", "Forced output width",
0, G_MAXINT, 0, 0, G_MAXINT, 0, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
/** /**
* GstVaapiPostproc:height: * GstVaapiPostproc:height:
* *
* The forced output height in pixels. If set to zero, the height * The forced output height in pixels. If set to zero, the height is
* is calculated from the width if aspect ration is preserved, or * calculated from the width if aspect ration is preserved, or
* inherited from the sink caps height * inherited from the sink caps height
*/ */
g_object_class_install_property g_object_class_install_property
@ -1656,15 +1641,13 @@ gst_vaapipostproc_class_init(GstVaapiPostprocClass *klass)
g_param_spec_uint ("height", g_param_spec_uint ("height",
"Height", "Height",
"Forced output height", "Forced output height",
0, G_MAXINT, 0, 0, G_MAXINT, 0, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
/** /**
* GstVaapiPostproc:force-aspect-ratio: * GstVaapiPostproc:force-aspect-ratio:
* *
* When enabled, scaling respects video aspect ratio; when * When enabled, scaling respects video aspect ratio; when disabled,
* disabled, the video is distorted to fit the width and height * the video is distorted to fit the width and height properties.
* properties.
*/ */
g_object_class_install_property g_object_class_install_property
(object_class, (object_class,
@ -1672,8 +1655,7 @@ gst_vaapipostproc_class_init(GstVaapiPostprocClass *klass)
g_param_spec_boolean ("force-aspect-ratio", g_param_spec_boolean ("force-aspect-ratio",
"Force aspect ratio", "Force aspect ratio",
"When enabled, scaling will respect original aspect ratio", "When enabled, scaling will respect original aspect ratio",
TRUE, TRUE, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
/** /**
* GstVaapiPostproc:denoise: * GstVaapiPostproc:denoise:
@ -1704,14 +1686,13 @@ gst_vaapipostproc_class_init(GstVaapiPostprocClass *klass)
*/ */
filter_op = find_filter_op (filter_ops, GST_VAAPI_FILTER_OP_HUE); filter_op = find_filter_op (filter_ops, GST_VAAPI_FILTER_OP_HUE);
if (filter_op) if (filter_op)
g_object_class_install_property(object_class, g_object_class_install_property (object_class, PROP_HUE, filter_op->pspec);
PROP_HUE, filter_op->pspec);
/** /**
* GstVaapiPostproc:saturation: * GstVaapiPostproc:saturation:
* *
* The color saturation, expressed as a float value. Range is 0.0 * The color saturation, expressed as a float value. Range is 0.0 to
* to 2.0. Default value is 1.0 and represents no modification. * 2.0. Default value is 1.0 and represents no modification.
*/ */
filter_op = find_filter_op (filter_ops, GST_VAAPI_FILTER_OP_SATURATION); filter_op = find_filter_op (filter_ops, GST_VAAPI_FILTER_OP_SATURATION);
if (filter_op) if (filter_op)
@ -1757,7 +1738,8 @@ gst_vaapipostproc_class_init(GstVaapiPostprocClass *klass)
static void static void
gst_vaapipostproc_init (GstVaapiPostproc * postproc) gst_vaapipostproc_init (GstVaapiPostproc * postproc)
{ {
gst_vaapi_plugin_base_init(GST_VAAPI_PLUGIN_BASE(postproc), GST_CAT_DEFAULT); gst_vaapi_plugin_base_init (GST_VAAPI_PLUGIN_BASE (postproc),
GST_CAT_DEFAULT);
postproc->format = DEFAULT_FORMAT; postproc->format = DEFAULT_FORMAT;
postproc->deinterlace_mode = DEFAULT_DEINTERLACE_MODE; postproc->deinterlace_mode = DEFAULT_DEINTERLACE_MODE;

View file

@ -32,26 +32,17 @@ G_BEGIN_DECLS
#define GST_TYPE_VAAPIPOSTPROC \ #define GST_TYPE_VAAPIPOSTPROC \
(gst_vaapipostproc_get_type ()) (gst_vaapipostproc_get_type ())
#define GST_VAAPIPOSTPROC(obj) \ #define GST_VAAPIPOSTPROC(obj) \
(G_TYPE_CHECK_INSTANCE_CAST((obj), \ (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_VAAPIPOSTPROC, GstVaapiPostproc))
GST_TYPE_VAAPIPOSTPROC, \
GstVaapiPostproc))
#define GST_VAAPIPOSTPROC_CLASS(klass) \ #define GST_VAAPIPOSTPROC_CLASS(klass) \
(G_TYPE_CHECK_CLASS_CAST((klass), \ (G_TYPE_CHECK_CLASS_CAST ((klass), GST_TYPE_VAAPIPOSTPROC, \
GST_TYPE_VAAPIPOSTPROC, \
GstVaapiPostprocClass)) GstVaapiPostprocClass))
#define GST_IS_VAAPIPOSTPROC(obj) \ #define GST_IS_VAAPIPOSTPROC(obj) \
(G_TYPE_CHECK_INSTANCE_TYPE((obj), GST_TYPE_VAAPIPOSTPROC)) (G_TYPE_CHECK_INSTANCE_TYPE((obj), GST_TYPE_VAAPIPOSTPROC))
#define GST_IS_VAAPIPOSTPROC_CLASS(klass) \ #define GST_IS_VAAPIPOSTPROC_CLASS(klass) \
(G_TYPE_CHECK_CLASS_TYPE((klass), GST_TYPE_VAAPIPOSTPROC)) (G_TYPE_CHECK_CLASS_TYPE((klass), GST_TYPE_VAAPIPOSTPROC))
#define GST_VAAPIPOSTPROC_GET_CLASS(obj) \ #define GST_VAAPIPOSTPROC_GET_CLASS(obj) \
(G_TYPE_INSTANCE_GET_CLASS((obj), \ (G_TYPE_INSTANCE_GET_CLASS((obj), GST_TYPE_VAAPIPOSTPROC, \
GST_TYPE_VAAPIPOSTPROC, \
GstVaapiPostprocClass)) GstVaapiPostprocClass))
typedef struct _GstVaapiPostproc GstVaapiPostproc; typedef struct _GstVaapiPostproc GstVaapiPostproc;
@ -64,7 +55,8 @@ typedef struct _GstVaapiDeinterlaceState GstVaapiDeinterlaceState;
* @GST_VAAPI_DEINTERLACE_MODE_INTERLACED: Force deinterlacing. * @GST_VAAPI_DEINTERLACE_MODE_INTERLACED: Force deinterlacing.
* @GST_VAAPI_DEINTERLACE_MODE_DISABLED: Never perform deinterlacing. * @GST_VAAPI_DEINTERLACE_MODE_DISABLED: Never perform deinterlacing.
*/ */
typedef enum { typedef enum
{
GST_VAAPI_DEINTERLACE_MODE_AUTO = 0, GST_VAAPI_DEINTERLACE_MODE_AUTO = 0,
GST_VAAPI_DEINTERLACE_MODE_INTERLACED, GST_VAAPI_DEINTERLACE_MODE_INTERLACED,
GST_VAAPI_DEINTERLACE_MODE_DISABLED, GST_VAAPI_DEINTERLACE_MODE_DISABLED,
@ -97,7 +89,8 @@ typedef enum {
* *
* The set of operations that are to be performed for each frame. * The set of operations that are to be performed for each frame.
*/ */
typedef enum { typedef enum
{
GST_VAAPI_POSTPROC_FLAG_FORMAT = 1 << GST_VAAPI_FILTER_OP_FORMAT, GST_VAAPI_POSTPROC_FLAG_FORMAT = 1 << GST_VAAPI_FILTER_OP_FORMAT,
GST_VAAPI_POSTPROC_FLAG_DENOISE = 1 << GST_VAAPI_FILTER_OP_DENOISE, GST_VAAPI_POSTPROC_FLAG_DENOISE = 1 << GST_VAAPI_FILTER_OP_DENOISE,
GST_VAAPI_POSTPROC_FLAG_SHARPEN = 1 << GST_VAAPI_FILTER_OP_SHARPEN, GST_VAAPI_POSTPROC_FLAG_SHARPEN = 1 << GST_VAAPI_FILTER_OP_SHARPEN,
@ -124,7 +117,8 @@ typedef enum {
* *
* Context used to maintain deinterlacing state. * Context used to maintain deinterlacing state.
*/ */
struct _GstVaapiDeinterlaceState { struct _GstVaapiDeinterlaceState
{
GstBuffer *buffers[GST_VAAPI_DEINTERLACE_MAX_REFERENCES]; GstBuffer *buffers[GST_VAAPI_DEINTERLACE_MAX_REFERENCES];
guint buffers_index; guint buffers_index;
GstVaapiSurface *surfaces[GST_VAAPI_DEINTERLACE_MAX_REFERENCES]; GstVaapiSurface *surfaces[GST_VAAPI_DEINTERLACE_MAX_REFERENCES];
@ -133,7 +127,8 @@ struct _GstVaapiDeinterlaceState {
guint tff:1; guint tff:1;
}; };
struct _GstVaapiPostproc { struct _GstVaapiPostproc
{
/*< private >*/ /*< private >*/
GstVaapiPluginBase parent_instance; GstVaapiPluginBase parent_instance;
@ -176,7 +171,8 @@ struct _GstVaapiPostproc {
guint keep_aspect:1; guint keep_aspect:1;
}; };
struct _GstVaapiPostprocClass { struct _GstVaapiPostprocClass
{
/*< private >*/ /*< private >*/
GstVaapiPluginBaseClass parent_class; GstVaapiPluginBaseClass parent_class;
}; };

View file

@ -39,17 +39,16 @@
GST_DEBUG_CATEGORY_STATIC (gst_debug_vaapi_uploader); GST_DEBUG_CATEGORY_STATIC (gst_debug_vaapi_uploader);
#define GST_CAT_DEFAULT gst_debug_vaapi_uploader #define GST_CAT_DEFAULT gst_debug_vaapi_uploader
G_DEFINE_TYPE(GstVaapiUploader, gst_vaapi_uploader, G_TYPE_OBJECT) G_DEFINE_TYPE (GstVaapiUploader, gst_vaapi_uploader, G_TYPE_OBJECT);
#define GST_VAAPI_UPLOADER_CAST(obj) \ #define GST_VAAPI_UPLOADER_CAST(obj) \
((GstVaapiUploader *)(obj)) ((GstVaapiUploader *)(obj))
#define GST_VAAPI_UPLOADER_GET_PRIVATE(obj) \ #define GST_VAAPI_UPLOADER_GET_PRIVATE(obj) \
(G_TYPE_INSTANCE_GET_PRIVATE((obj), \ (G_TYPE_INSTANCE_GET_PRIVATE ((obj), GST_VAAPI_TYPE_UPLOADER, \
GST_VAAPI_TYPE_UPLOADER, \
GstVaapiUploaderPrivate)) GstVaapiUploaderPrivate))
struct _GstVaapiUploaderPrivate { struct _GstVaapiUploaderPrivate
{
GstVaapiDisplay *display; GstVaapiDisplay *display;
GstCaps *allowed_caps; GstCaps *allowed_caps;
GstVaapiVideoPool *images; GstVaapiVideoPool *images;
@ -59,7 +58,8 @@ struct _GstVaapiUploaderPrivate {
guint direct_rendering; guint direct_rendering;
}; };
enum { enum
{
PROP_0, PROP_0,
PROP_DISPLAY, PROP_DISPLAY,
@ -118,7 +118,8 @@ ensure_allowed_caps(GstVaapiUploader *uploader)
guint i; guint i;
gboolean success = FALSE; gboolean success = FALSE;
enum { WIDTH = 64, HEIGHT = 64 }; enum
{ WIDTH = 64, HEIGHT = 64 };
if (priv->allowed_caps) if (priv->allowed_caps)
return TRUE; return TRUE;
@ -138,8 +139,7 @@ ensure_allowed_caps(GstVaapiUploader *uploader)
goto cleanup; goto cleanup;
for (i = 0; i < formats->len; i++) { for (i = 0; i < formats->len; i++) {
const GstVideoFormat format = const GstVideoFormat format = g_array_index (formats, GstVideoFormat, i);
g_array_index(formats, GstVideoFormat, i);
GstVaapiImage *image; GstVaapiImage *image;
if (format == GST_VIDEO_FORMAT_UNKNOWN) if (format == GST_VIDEO_FORMAT_UNKNOWN)
@ -307,11 +307,9 @@ gst_vaapi_uploader_class_init(GstVaapiUploaderClass *klass)
object_class->set_property = gst_vaapi_uploader_set_property; object_class->set_property = gst_vaapi_uploader_set_property;
object_class->get_property = gst_vaapi_uploader_get_property; object_class->get_property = gst_vaapi_uploader_get_property;
g_object_class_install_property( g_object_class_install_property (object_class,
object_class,
PROP_DISPLAY, PROP_DISPLAY,
g_param_spec_pointer( g_param_spec_pointer ("display",
"display",
"Display", "Display",
"The GstVaapiDisplay this object is bound to", "The GstVaapiDisplay this object is bound to",
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
@ -336,10 +334,8 @@ gst_vaapi_uploader_new(GstVaapiDisplay *display)
} }
gboolean gboolean
gst_vaapi_uploader_ensure_display( gst_vaapi_uploader_ensure_display (GstVaapiUploader * uploader,
GstVaapiUploader *uploader, GstVaapiDisplay * display)
GstVaapiDisplay *display
)
{ {
g_return_val_if_fail (GST_VAAPI_IS_UPLOADER (uploader), FALSE); g_return_val_if_fail (GST_VAAPI_IS_UPLOADER (uploader), FALSE);
g_return_val_if_fail (display != NULL, FALSE); g_return_val_if_fail (display != NULL, FALSE);
@ -348,11 +344,8 @@ gst_vaapi_uploader_ensure_display(
} }
gboolean gboolean
gst_vaapi_uploader_ensure_caps( gst_vaapi_uploader_ensure_caps (GstVaapiUploader * uploader,
GstVaapiUploader *uploader, GstCaps * src_caps, GstCaps * out_caps)
GstCaps *src_caps,
GstCaps *out_caps
)
{ {
GstVaapiUploaderPrivate *priv; GstVaapiUploaderPrivate *priv;
GstVaapiImage *image; GstVaapiImage *image;
@ -391,11 +384,8 @@ gst_vaapi_uploader_ensure_caps(
} }
gboolean gboolean
gst_vaapi_uploader_process( gst_vaapi_uploader_process (GstVaapiUploader * uploader,
GstVaapiUploader *uploader, GstBuffer * src_buffer, GstBuffer * out_buffer)
GstBuffer *src_buffer,
GstBuffer *out_buffer
)
{ {
GstVaapiVideoMeta *src_meta, *out_meta; GstVaapiVideoMeta *src_meta, *out_meta;
GstVaapiSurface *surface; GstVaapiSurface *surface;
@ -418,8 +408,7 @@ gst_vaapi_uploader_process(
image = gst_vaapi_video_meta_get_image (src_meta); image = gst_vaapi_video_meta_get_image (src_meta);
if (!image || !gst_vaapi_image_unmap (image)) if (!image || !gst_vaapi_image_unmap (image))
return FALSE; return FALSE;
} } else {
else {
/* Regular GstBuffer that needs to be uploaded to a VA image */ /* Regular GstBuffer that needs to be uploaded to a VA image */
image = gst_vaapi_video_meta_get_image (out_meta); image = gst_vaapi_video_meta_get_image (out_meta);
if (!image) { if (!image) {
@ -473,8 +462,9 @@ gst_vaapi_uploader_get_buffer(GstVaapiUploader *uploader)
goto error; goto error;
} }
proxy = gst_vaapi_surface_proxy_new_from_pool( proxy =
GST_VAAPI_SURFACE_POOL(priv->surfaces)); gst_vaapi_surface_proxy_new_from_pool (GST_VAAPI_SURFACE_POOL
(priv->surfaces));
if (!proxy) { if (!proxy) {
GST_WARNING ("failed to allocate VA surface"); GST_WARNING ("failed to allocate VA surface");
goto error; goto error;
@ -489,7 +479,6 @@ gst_vaapi_uploader_get_buffer(GstVaapiUploader *uploader)
GST_WARNING ("failed to map VA image"); GST_WARNING ("failed to map VA image");
goto error; goto error;
} }
#if !GST_CHECK_VERSION(1,0,0) #if !GST_CHECK_VERSION(1,0,0)
GST_BUFFER_DATA (buffer) = gst_vaapi_image_get_plane (image, 0); GST_BUFFER_DATA (buffer) = gst_vaapi_image_get_plane (image, 0);
GST_BUFFER_SIZE (buffer) = gst_vaapi_image_get_data_size (image); GST_BUFFER_SIZE (buffer) = gst_vaapi_image_get_data_size (image);

View file

@ -31,40 +31,34 @@ G_BEGIN_DECLS
#define GST_VAAPI_TYPE_UPLOADER \ #define GST_VAAPI_TYPE_UPLOADER \
(gst_vaapi_uploader_get_type ()) (gst_vaapi_uploader_get_type ())
#define GST_VAAPI_UPLOADER(obj) \ #define GST_VAAPI_UPLOADER(obj) \
(G_TYPE_CHECK_INSTANCE_CAST((obj), \ (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_VAAPI_TYPE_UPLOADER, \
GST_VAAPI_TYPE_UPLOADER, \
GstVaapiUploader)) GstVaapiUploader))
#define GST_VAAPI_UPLOADER_CLASS(klass) \ #define GST_VAAPI_UPLOADER_CLASS(klass) \
(G_TYPE_CHECK_CLASS_CAST((klass), \ (G_TYPE_CHECK_CLASS_CAST ((klass), GST_VAAPI_TYPE_UPLOADER, \
GST_VAAPI_TYPE_UPLOADER, \
GstVaapiUploaderClass)) GstVaapiUploaderClass))
#define GST_VAAPI_IS_UPLOADER(obj) \ #define GST_VAAPI_IS_UPLOADER(obj) \
(G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_VAAPI_TYPE_UPLOADER)) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_VAAPI_TYPE_UPLOADER))
#define GST_VAAPI_IS_UPLOADER_CLASS(klass) \ #define GST_VAAPI_IS_UPLOADER_CLASS(klass) \
(G_TYPE_CHECK_CLASS_TYPE ((klass), GST_VAAPI_TYPE_UPLOADER)) (G_TYPE_CHECK_CLASS_TYPE ((klass), GST_VAAPI_TYPE_UPLOADER))
#define GST_VAAPI_UPLOADER_GET_CLASS(obj) \ #define GST_VAAPI_UPLOADER_GET_CLASS(obj) \
(G_TYPE_INSTANCE_GET_CLASS((obj), \ (G_TYPE_INSTANCE_GET_CLASS ((obj), GST_VAAPI_TYPE_UPLOADER, \
GST_VAAPI_TYPE_UPLOADER, \
GstVaapiUploaderClass)) GstVaapiUploaderClass))
typedef struct _GstVaapiUploader GstVaapiUploader; typedef struct _GstVaapiUploader GstVaapiUploader;
typedef struct _GstVaapiUploaderPrivate GstVaapiUploaderPrivate; typedef struct _GstVaapiUploaderPrivate GstVaapiUploaderPrivate;
typedef struct _GstVaapiUploaderClass GstVaapiUploaderClass; typedef struct _GstVaapiUploaderClass GstVaapiUploaderClass;
struct _GstVaapiUploader { struct _GstVaapiUploader
{
/*< private >*/ /*< private >*/
GObject parent_instance; GObject parent_instance;
GstVaapiUploaderPrivate *priv; GstVaapiUploaderPrivate *priv;
}; };
struct _GstVaapiUploaderClass { struct _GstVaapiUploaderClass
{
/*< private >*/ /*< private >*/
GObjectClass parent_class; GObjectClass parent_class;
}; };
@ -79,26 +73,18 @@ gst_vaapi_uploader_new(GstVaapiDisplay *display);
G_GNUC_INTERNAL G_GNUC_INTERNAL
gboolean gboolean
gst_vaapi_uploader_ensure_display( gst_vaapi_uploader_ensure_display (GstVaapiUploader * uploader,
GstVaapiUploader *uploader, GstVaapiDisplay * display);
GstVaapiDisplay *display
);
G_GNUC_INTERNAL G_GNUC_INTERNAL
gboolean gboolean
gst_vaapi_uploader_ensure_caps( gst_vaapi_uploader_ensure_caps (GstVaapiUploader * uploader,
GstVaapiUploader *uploader, GstCaps * src_caps, GstCaps * out_caps);
GstCaps *src_caps,
GstCaps *out_caps
);
G_GNUC_INTERNAL G_GNUC_INTERNAL
gboolean gboolean
gst_vaapi_uploader_process( gst_vaapi_uploader_process (GstVaapiUploader * uploader,
GstVaapiUploader *uploader, GstBuffer * src_buffer, GstBuffer * out_buffer);
GstBuffer *src_buffer,
GstBuffer *out_buffer
);
G_GNUC_INTERNAL G_GNUC_INTERNAL
GstCaps * GstCaps *