* <refsect2>
* <title>Example launch line</title>
* |[
- * gst-launch videotestsrc ! gamma gamma=2.0 ! ffmpegcolorspace ! ximagesink
+ * gst-launch-1.0 videotestsrc ! gamma gamma=2.0 ! videoconvert ! ximagesink
* ]| This pipeline will make the image "brighter".
* |[
- * gst-launch videotestsrc ! gamma gamma=0.5 ! ffmpegcolorspace ! ximagesink
+ * gst-launch-1.0 videotestsrc ! gamma gamma=0.5 ! videoconvert ! ximagesink
* ]| This pipeline will make the image "darker".
* </refsect2>
*
#include <math.h>
#include <gst/video/video.h>
-#include <gst/controller/gstcontroller.h>
GST_DEBUG_CATEGORY_STATIC (gamma_debug);
#define GST_CAT_DEFAULT gamma_debug
static void gst_gamma_get_property (GObject * object, guint prop_id,
GValue * value, GParamSpec * pspec);
-static gboolean gst_gamma_set_caps (GstBaseTransform * base, GstCaps * incaps,
- GstCaps * outcaps);
-static GstFlowReturn gst_gamma_transform_ip (GstBaseTransform * transform,
- GstBuffer * buf);
+static gboolean gst_gamma_set_info (GstVideoFilter * vfilter, GstCaps * incaps,
+ GstVideoInfo * in_info, GstCaps * outcaps, GstVideoInfo * out_info);
+static GstFlowReturn gst_gamma_transform_frame_ip (GstVideoFilter * vfilter,
+ GstVideoFrame * frame);
static void gst_gamma_before_transform (GstBaseTransform * transform,
GstBuffer * buf);
GObjectClass *gobject_class = (GObjectClass *) g_class;
GstElementClass *gstelement_class = (GstElementClass *) g_class;
GstBaseTransformClass *trans_class = (GstBaseTransformClass *) g_class;
+ GstVideoFilterClass *vfilter_class = (GstVideoFilterClass *) g_class;
GST_DEBUG_CATEGORY_INIT (gamma_debug, "gamma", 0, "gamma");
0.01, 10, DEFAULT_PROP_GAMMA,
GST_PARAM_CONTROLLABLE | G_PARAM_STATIC_STRINGS | G_PARAM_READWRITE));
- gst_element_class_set_details_simple (gstelement_class,
+ gst_element_class_set_static_metadata (gstelement_class,
"Video gamma correction", "Filter/Effect/Video",
"Adjusts gamma on a video stream", "Arwed v. Merkatz <v.merkatz@gmx.net");
gst_element_class_add_pad_template (gstelement_class,
gst_static_pad_template_get (&gst_gamma_src_template));
- trans_class->set_caps = GST_DEBUG_FUNCPTR (gst_gamma_set_caps);
- trans_class->transform_ip = GST_DEBUG_FUNCPTR (gst_gamma_transform_ip);
trans_class->before_transform =
GST_DEBUG_FUNCPTR (gst_gamma_before_transform);
+ trans_class->transform_ip_on_passthrough = FALSE;
+
+ vfilter_class->set_info = GST_DEBUG_FUNCPTR (gst_gamma_set_info);
+ vfilter_class->transform_frame_ip =
+ GST_DEBUG_FUNCPTR (gst_gamma_transform_frame_ip);
}
static void
val);
GST_OBJECT_LOCK (gamma);
gamma->gamma = val;
- gst_gamma_calculate_tables (gamma);
GST_OBJECT_UNLOCK (gamma);
+ gst_gamma_calculate_tables (gamma);
break;
}
default:
gint n;
gdouble val;
gdouble exp;
+ gboolean passthrough = FALSE;
+ GST_OBJECT_LOCK (gamma);
if (gamma->gamma == 1.0) {
- GST_BASE_TRANSFORM (gamma)->passthrough = TRUE;
- return;
- }
- GST_BASE_TRANSFORM (gamma)->passthrough = FALSE;
-
- exp = 1.0 / gamma->gamma;
- for (n = 0; n < 256; n++) {
- val = n / 255.0;
- val = pow (val, exp);
- val = 255.0 * val;
- gamma->gamma_table[n] = (guint8) floor (val + 0.5);
+ passthrough = TRUE;
+ } else {
+ exp = 1.0 / gamma->gamma;
+ for (n = 0; n < 256; n++) {
+ val = n / 255.0;
+ val = pow (val, exp);
+ val = 255.0 * val;
+ gamma->gamma_table[n] = (guint8) floor (val + 0.5);
+ }
}
+ GST_OBJECT_UNLOCK (gamma);
+
+ gst_base_transform_set_passthrough (GST_BASE_TRANSFORM (gamma), passthrough);
}
static void
}
static gboolean
-gst_gamma_set_caps (GstBaseTransform * base, GstCaps * incaps,
- GstCaps * outcaps)
+gst_gamma_set_info (GstVideoFilter * vfilter, GstCaps * incaps,
+ GstVideoInfo * in_info, GstCaps * outcaps, GstVideoInfo * out_info)
{
- GstGamma *gamma = GST_GAMMA (base);
- GstVideoInfo info;
+ GstGamma *gamma = GST_GAMMA (vfilter);
GST_DEBUG_OBJECT (gamma,
"setting caps: in %" GST_PTR_FORMAT " out %" GST_PTR_FORMAT, incaps,
outcaps);
- if (!gst_video_info_from_caps (&info, incaps))
- goto invalid_caps;
-
- gamma->info = info;
-
- switch (GST_VIDEO_INFO_FORMAT (&info)) {
+ switch (GST_VIDEO_INFO_FORMAT (in_info)) {
case GST_VIDEO_FORMAT_I420:
case GST_VIDEO_FORMAT_YV12:
case GST_VIDEO_FORMAT_Y41B:
goto invalid_caps;
break;
}
-
return TRUE;
+ /* ERRORS */
invalid_caps:
{
GST_ERROR_OBJECT (gamma, "Invalid caps: %" GST_PTR_FORMAT, incaps);
GST_TIME_ARGS (timestamp));
if (GST_CLOCK_TIME_IS_VALID (stream_time))
- gst_object_sync_values (G_OBJECT (gamma), stream_time);
+ gst_object_sync_values (GST_OBJECT (gamma), stream_time);
}
static GstFlowReturn
-gst_gamma_transform_ip (GstBaseTransform * base, GstBuffer * outbuf)
+gst_gamma_transform_frame_ip (GstVideoFilter * vfilter, GstVideoFrame * frame)
{
- GstGamma *gamma = GST_GAMMA (base);
- GstVideoFrame frame;
+ GstGamma *gamma = GST_GAMMA (vfilter);
if (!gamma->process)
goto not_negotiated;
- if (base->passthrough)
- goto done;
-
- if (!gst_video_frame_map (&frame, &gamma->info, outbuf, GST_MAP_READWRITE))
- goto wrong_buffer;
-
GST_OBJECT_LOCK (gamma);
- gamma->process (gamma, &frame);
+ gamma->process (gamma, frame);
GST_OBJECT_UNLOCK (gamma);
- gst_video_frame_unmap (&frame);
-
-done:
return GST_FLOW_OK;
/* ERRORS */
-wrong_buffer:
- {
- GST_ELEMENT_ERROR (gamma, STREAM, FORMAT,
- (NULL), ("Invalid buffer received"));
- return GST_FLOW_ERROR;
- }
not_negotiated:
{
GST_ERROR_OBJECT (gamma, "Not negotiated yet");