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");
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);
+
+ 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);
}
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)
+ if (gst_base_transform_is_passthrough (GST_BASE_TRANSFORM (vfilter)))
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");