mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-17 22:06:41 +00:00
coloreffects: port to 0.11
This commit is contained in:
parent
5d2b52697c
commit
4d1bd12ff8
5 changed files with 109 additions and 178 deletions
|
@ -301,7 +301,7 @@ dnl *** plug-ins to include ***
|
|||
dnl Non ported plugins (non-dependant, then dependant)
|
||||
dnl Make sure you have a space before and after all plugins
|
||||
GST_PLUGINS_NONPORTED=" aiff \
|
||||
camerabin cdxaparse coloreffects \
|
||||
camerabin cdxaparse \
|
||||
dccp faceoverlay festival \
|
||||
fieldanalysis freeverb freeze frei0r gaudieffects \
|
||||
hdvparse id3tag inter interlace ivfparse jpegformat jp2kdecimator \
|
||||
|
|
|
@ -69,23 +69,19 @@ enum
|
|||
};
|
||||
|
||||
static GstStaticPadTemplate gst_chroma_hold_src_template =
|
||||
GST_STATIC_PAD_TEMPLATE ("src",
|
||||
GST_STATIC_PAD_TEMPLATE ("src",
|
||||
GST_PAD_SRC,
|
||||
GST_PAD_ALWAYS,
|
||||
GST_STATIC_CAPS (GST_VIDEO_CAPS_ARGB ";" GST_VIDEO_CAPS_BGRA ";"
|
||||
GST_VIDEO_CAPS_ABGR ";" GST_VIDEO_CAPS_RGBA
|
||||
";" GST_VIDEO_CAPS_xRGB ";" GST_VIDEO_CAPS_BGRx ";" GST_VIDEO_CAPS_xBGR
|
||||
";" GST_VIDEO_CAPS_RGBx)
|
||||
GST_STATIC_CAPS (GST_VIDEO_CAPS_MAKE
|
||||
("{ ARGB, BGRA, ABGR, RGBA, xRGB, BGRx, xBGR, RGBx}"))
|
||||
);
|
||||
|
||||
static GstStaticPadTemplate gst_chroma_hold_sink_template =
|
||||
GST_STATIC_PAD_TEMPLATE ("sink",
|
||||
GST_STATIC_PAD_TEMPLATE ("sink",
|
||||
GST_PAD_SINK,
|
||||
GST_PAD_ALWAYS,
|
||||
GST_STATIC_CAPS (GST_VIDEO_CAPS_ARGB ";" GST_VIDEO_CAPS_BGRA ";"
|
||||
GST_VIDEO_CAPS_ABGR ";" GST_VIDEO_CAPS_RGBA
|
||||
";" GST_VIDEO_CAPS_xRGB ";" GST_VIDEO_CAPS_BGRx ";" GST_VIDEO_CAPS_xBGR
|
||||
";" GST_VIDEO_CAPS_RGBx)
|
||||
GST_STATIC_CAPS (GST_VIDEO_CAPS_MAKE
|
||||
("{ ARGB, BGRA, ABGR, RGBA, xRGB, BGRx, xBGR, RGBx}"))
|
||||
);
|
||||
|
||||
#define GST_CHROMA_HOLD_LOCK(self) G_STMT_START { \
|
||||
|
@ -101,12 +97,11 @@ static GstStaticPadTemplate gst_chroma_hold_sink_template =
|
|||
} G_STMT_END
|
||||
|
||||
static gboolean gst_chroma_hold_start (GstBaseTransform * trans);
|
||||
static gboolean gst_chroma_hold_get_unit_size (GstBaseTransform * btrans,
|
||||
GstCaps * caps, guint * size);
|
||||
static gboolean gst_chroma_hold_set_caps (GstBaseTransform * btrans,
|
||||
GstCaps * incaps, GstCaps * outcaps);
|
||||
static GstFlowReturn gst_chroma_hold_transform_ip (GstBaseTransform * btrans,
|
||||
GstBuffer * buf);
|
||||
static gboolean gst_chroma_hold_set_info (GstVideoFilter * vfilter,
|
||||
GstCaps * incaps, GstVideoInfo * in_info, GstCaps * outcaps,
|
||||
GstVideoInfo * out_info);
|
||||
static GstFlowReturn gst_chroma_hold_transform_frame_ip (GstVideoFilter *
|
||||
vfilter, GstVideoFrame * frame);
|
||||
static void gst_chroma_hold_before_transform (GstBaseTransform * btrans,
|
||||
GstBuffer * buf);
|
||||
|
||||
|
@ -119,33 +114,16 @@ static void gst_chroma_hold_get_property (GObject * object, guint prop_id,
|
|||
GValue * value, GParamSpec * pspec);
|
||||
static void gst_chroma_hold_finalize (GObject * object);
|
||||
|
||||
GST_BOILERPLATE (GstChromaHold, gst_chroma_hold, GstVideoFilter,
|
||||
GST_TYPE_VIDEO_FILTER);
|
||||
|
||||
static void
|
||||
gst_chroma_hold_base_init (gpointer g_class)
|
||||
{
|
||||
GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
|
||||
|
||||
gst_element_class_set_details_simple (element_class, "Chroma hold filter",
|
||||
"Filter/Effect/Video",
|
||||
"Removes all color information except for one color",
|
||||
"Sebastian Dröge <sebastian.droege@collabora.co.uk>");
|
||||
|
||||
gst_element_class_add_pad_template (element_class,
|
||||
gst_static_pad_template_get (&gst_chroma_hold_sink_template));
|
||||
gst_element_class_add_pad_template (element_class,
|
||||
gst_static_pad_template_get (&gst_chroma_hold_src_template));
|
||||
|
||||
GST_DEBUG_CATEGORY_INIT (gst_chroma_hold_debug, "chromahold", 0,
|
||||
"chromahold - Removes all color information except for one color");
|
||||
}
|
||||
#define gst_chroma_hold_parent_class parent_class
|
||||
G_DEFINE_TYPE (GstChromaHold, gst_chroma_hold, GST_TYPE_VIDEO_FILTER);
|
||||
|
||||
static void
|
||||
gst_chroma_hold_class_init (GstChromaHoldClass * klass)
|
||||
{
|
||||
GObjectClass *gobject_class = (GObjectClass *) klass;
|
||||
GstElementClass *gstelement_class = (GstElementClass *) klass;
|
||||
GstBaseTransformClass *btrans_class = (GstBaseTransformClass *) klass;
|
||||
GstVideoFilterClass *vfilter_class = (GstVideoFilterClass *) klass;
|
||||
|
||||
gobject_class->set_property = gst_chroma_hold_set_property;
|
||||
gobject_class->get_property = gst_chroma_hold_get_property;
|
||||
|
@ -169,16 +147,29 @@ gst_chroma_hold_class_init (GstChromaHoldClass * klass)
|
|||
G_PARAM_READWRITE | GST_PARAM_CONTROLLABLE | G_PARAM_STATIC_STRINGS));
|
||||
|
||||
btrans_class->start = GST_DEBUG_FUNCPTR (gst_chroma_hold_start);
|
||||
btrans_class->transform_ip = GST_DEBUG_FUNCPTR (gst_chroma_hold_transform_ip);
|
||||
btrans_class->before_transform =
|
||||
GST_DEBUG_FUNCPTR (gst_chroma_hold_before_transform);
|
||||
btrans_class->get_unit_size =
|
||||
GST_DEBUG_FUNCPTR (gst_chroma_hold_get_unit_size);
|
||||
btrans_class->set_caps = GST_DEBUG_FUNCPTR (gst_chroma_hold_set_caps);
|
||||
|
||||
vfilter_class->transform_frame_ip =
|
||||
GST_DEBUG_FUNCPTR (gst_chroma_hold_transform_frame_ip);
|
||||
vfilter_class->set_info = GST_DEBUG_FUNCPTR (gst_chroma_hold_set_info);
|
||||
|
||||
gst_element_class_set_details_simple (gstelement_class, "Chroma hold filter",
|
||||
"Filter/Effect/Video",
|
||||
"Removes all color information except for one color",
|
||||
"Sebastian Dröge <sebastian.droege@collabora.co.uk>");
|
||||
|
||||
gst_element_class_add_pad_template (gstelement_class,
|
||||
gst_static_pad_template_get (&gst_chroma_hold_sink_template));
|
||||
gst_element_class_add_pad_template (gstelement_class,
|
||||
gst_static_pad_template_get (&gst_chroma_hold_src_template));
|
||||
|
||||
GST_DEBUG_CATEGORY_INIT (gst_chroma_hold_debug, "chromahold", 0,
|
||||
"chromahold - Removes all color information except for one color");
|
||||
}
|
||||
|
||||
static void
|
||||
gst_chroma_hold_init (GstChromaHold * self, GstChromaHoldClass * klass)
|
||||
gst_chroma_hold_init (GstChromaHold * self)
|
||||
{
|
||||
self->target_r = DEFAULT_TARGET_R;
|
||||
self->target_g = DEFAULT_TARGET_G;
|
||||
|
@ -255,43 +246,20 @@ gst_chroma_hold_get_property (GObject * object, guint prop_id, GValue * value,
|
|||
}
|
||||
|
||||
static gboolean
|
||||
gst_chroma_hold_get_unit_size (GstBaseTransform * btrans,
|
||||
GstCaps * caps, guint * size)
|
||||
gst_chroma_hold_set_info (GstVideoFilter * vfilter, GstCaps * incaps,
|
||||
GstVideoInfo * in_info, GstCaps * outcaps, GstVideoInfo * out_info)
|
||||
{
|
||||
GstVideoFormat format;
|
||||
gint width, height;
|
||||
|
||||
if (!gst_video_format_parse_caps (caps, &format, &width, &height))
|
||||
return FALSE;
|
||||
|
||||
*size = gst_video_format_get_size (format, width, height);
|
||||
|
||||
GST_DEBUG_OBJECT (btrans, "unit size = %d for format %d w %d height %d",
|
||||
*size, format, width, height);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gst_chroma_hold_set_caps (GstBaseTransform * btrans,
|
||||
GstCaps * incaps, GstCaps * outcaps)
|
||||
{
|
||||
GstChromaHold *self = GST_CHROMA_HOLD (btrans);
|
||||
GstChromaHold *self = GST_CHROMA_HOLD (vfilter);
|
||||
|
||||
GST_CHROMA_HOLD_LOCK (self);
|
||||
|
||||
if (!gst_video_format_parse_caps (outcaps, &self->format,
|
||||
&self->width, &self->height)) {
|
||||
GST_WARNING_OBJECT (self,
|
||||
"Failed to parse caps %" GST_PTR_FORMAT " -> %" GST_PTR_FORMAT, incaps,
|
||||
outcaps);
|
||||
GST_CHROMA_HOLD_UNLOCK (self);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
GST_DEBUG_OBJECT (self,
|
||||
"Setting caps %" GST_PTR_FORMAT " -> %" GST_PTR_FORMAT, incaps, outcaps);
|
||||
|
||||
self->format = GST_VIDEO_INFO_FORMAT (in_info);
|
||||
self->width = GST_VIDEO_INFO_WIDTH (in_info);
|
||||
self->height = GST_VIDEO_INFO_HEIGHT (in_info);
|
||||
|
||||
if (!gst_chroma_hold_set_process_function (self)) {
|
||||
GST_WARNING_OBJECT (self, "No processing function for this caps");
|
||||
GST_CHROMA_HOLD_UNLOCK (self);
|
||||
|
@ -350,7 +318,7 @@ hue_dist (gint h1, gint h2)
|
|||
}
|
||||
|
||||
static void
|
||||
gst_chroma_hold_process_xrgb (guint8 * dest, gint width,
|
||||
gst_chroma_hold_process_xrgb (GstVideoFrame * frame, gint width,
|
||||
gint height, GstChromaHold * self)
|
||||
{
|
||||
gint i, j;
|
||||
|
@ -360,11 +328,15 @@ gst_chroma_hold_process_xrgb (guint8 * dest, gint width,
|
|||
gint tolerance = self->tolerance;
|
||||
gint p[4];
|
||||
gint diff;
|
||||
gint row_wrap;
|
||||
guint8 *dest;
|
||||
|
||||
p[0] = gst_video_format_get_component_offset (self->format, 3, width, height);
|
||||
p[1] = gst_video_format_get_component_offset (self->format, 0, width, height);
|
||||
p[2] = gst_video_format_get_component_offset (self->format, 1, width, height);
|
||||
p[3] = gst_video_format_get_component_offset (self->format, 2, width, height);
|
||||
dest = GST_VIDEO_FRAME_PLANE_DATA (frame, 0);
|
||||
p[0] = GST_VIDEO_FRAME_COMP_POFFSET (frame, 3);
|
||||
p[1] = GST_VIDEO_FRAME_COMP_POFFSET (frame, 0);
|
||||
p[2] = GST_VIDEO_FRAME_COMP_POFFSET (frame, 1);
|
||||
p[3] = GST_VIDEO_FRAME_COMP_POFFSET (frame, 2);
|
||||
row_wrap = GST_VIDEO_FRAME_PLANE_STRIDE (frame, 0) - 4 * width;
|
||||
|
||||
h1 = self->hue;
|
||||
|
||||
|
@ -386,6 +358,7 @@ gst_chroma_hold_process_xrgb (guint8 * dest, gint width,
|
|||
|
||||
dest += 4;
|
||||
}
|
||||
dest += row_wrap;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -445,10 +418,10 @@ gst_chroma_hold_before_transform (GstBaseTransform * btrans, GstBuffer * buf)
|
|||
}
|
||||
|
||||
static GstFlowReturn
|
||||
gst_chroma_hold_transform_ip (GstBaseTransform * btrans, GstBuffer * buf)
|
||||
gst_chroma_hold_transform_frame_ip (GstVideoFilter * vfilter,
|
||||
GstVideoFrame * frame)
|
||||
{
|
||||
GstChromaHold *self = GST_CHROMA_HOLD (btrans);
|
||||
gint width, height;
|
||||
GstChromaHold *self = GST_CHROMA_HOLD (vfilter);
|
||||
|
||||
GST_CHROMA_HOLD_LOCK (self);
|
||||
|
||||
|
@ -458,10 +431,7 @@ gst_chroma_hold_transform_ip (GstBaseTransform * btrans, GstBuffer * buf)
|
|||
return GST_FLOW_NOT_NEGOTIATED;
|
||||
}
|
||||
|
||||
width = self->width;
|
||||
height = self->height;
|
||||
|
||||
self->process (GST_BUFFER_DATA (buf), width, height, self);
|
||||
self->process (frame, self->width, self->height, self);
|
||||
|
||||
GST_CHROMA_HOLD_UNLOCK (self);
|
||||
|
||||
|
|
|
@ -28,7 +28,6 @@
|
|||
#include <gst/gst.h>
|
||||
#include <gst/video/video.h>
|
||||
#include <gst/video/gstvideofilter.h>
|
||||
#include <gst/controller/gstcontroller.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
#define GST_TYPE_CHROMA_HOLD \
|
||||
|
@ -62,7 +61,7 @@ struct _GstChromaHold
|
|||
guint tolerance;
|
||||
|
||||
/* processing function */
|
||||
void (*process) (guint8 * dest, gint width, gint height,
|
||||
void (*process) (GstVideoFrame * frame, gint width, gint height,
|
||||
GstChromaHold * chroma_hold);
|
||||
|
||||
/* pre-calculated values */
|
||||
|
|
|
@ -49,15 +49,11 @@ enum
|
|||
PROP_PRESET
|
||||
};
|
||||
|
||||
GST_BOILERPLATE (GstColorEffects, gst_color_effects, GstVideoFilter,
|
||||
GST_TYPE_VIDEO_FILTER);
|
||||
#define gst_color_effects_parent_class parent_class
|
||||
G_DEFINE_TYPE (GstColorEffects, gst_color_effects, GST_TYPE_VIDEO_FILTER);
|
||||
|
||||
#define CAPS_STR GST_VIDEO_CAPS_ARGB ";" GST_VIDEO_CAPS_BGRA ";"\
|
||||
GST_VIDEO_CAPS_ABGR ";" GST_VIDEO_CAPS_RGBA ";"\
|
||||
GST_VIDEO_CAPS_xRGB ";" GST_VIDEO_CAPS_RGBx ";"\
|
||||
GST_VIDEO_CAPS_xBGR ";" GST_VIDEO_CAPS_BGRx ";"\
|
||||
GST_VIDEO_CAPS_RGB ";" GST_VIDEO_CAPS_BGR ";" \
|
||||
GST_VIDEO_CAPS_YUV ("AYUV") ";"
|
||||
#define CAPS_STR GST_VIDEO_CAPS_MAKE ("{ " \
|
||||
"ARGB, BGRA, ABGR, RGBA, xRGB, BGRx, xBGR, RGBx, RGB, BGR, AYUV }")
|
||||
|
||||
static GstStaticPadTemplate gst_color_effects_src_template =
|
||||
GST_STATIC_PAD_TEMPLATE ("src",
|
||||
|
@ -303,7 +299,8 @@ static const gint cog_rgb_to_ycbcr_matrix_8bit_sdtv[] = {
|
|||
m[o*4+2] * v3 + m[o*4+3]) >> 8)
|
||||
|
||||
static void
|
||||
gst_color_effects_transform_rgb (GstColorEffects * filter, guint8 * data)
|
||||
gst_color_effects_transform_rgb (GstColorEffects * filter,
|
||||
GstVideoFrame * frame)
|
||||
{
|
||||
gint i, j;
|
||||
gint width, height;
|
||||
|
@ -311,23 +308,18 @@ gst_color_effects_transform_rgb (GstColorEffects * filter, guint8 * data)
|
|||
guint32 r, g, b;
|
||||
guint32 luma;
|
||||
gint offsets[3];
|
||||
guint8 *data;
|
||||
|
||||
/* videoformat fun copied from videobalance */
|
||||
data = GST_VIDEO_FRAME_PLANE_DATA (frame, 0);
|
||||
offsets[0] = GST_VIDEO_FRAME_COMP_POFFSET (frame, 0);
|
||||
offsets[1] = GST_VIDEO_FRAME_COMP_POFFSET (frame, 1);
|
||||
offsets[2] = GST_VIDEO_FRAME_COMP_POFFSET (frame, 2);
|
||||
|
||||
offsets[0] = gst_video_format_get_component_offset (filter->format, 0,
|
||||
filter->width, filter->height);
|
||||
offsets[1] = gst_video_format_get_component_offset (filter->format, 1,
|
||||
filter->width, filter->height);
|
||||
offsets[2] = gst_video_format_get_component_offset (filter->format, 2,
|
||||
filter->width, filter->height);
|
||||
width = GST_VIDEO_FRAME_WIDTH (frame);
|
||||
height = GST_VIDEO_FRAME_HEIGHT (frame);
|
||||
|
||||
width =
|
||||
gst_video_format_get_component_width (filter->format, 0, filter->width);
|
||||
height =
|
||||
gst_video_format_get_component_height (filter->format, 0, filter->height);
|
||||
row_stride =
|
||||
gst_video_format_get_row_stride (filter->format, 0, filter->width);
|
||||
pixel_stride = gst_video_format_get_pixel_stride (filter->format, 0);
|
||||
row_stride = GST_VIDEO_FRAME_PLANE_STRIDE (frame, 0);
|
||||
pixel_stride = GST_VIDEO_FRAME_COMP_PSTRIDE (frame, 0);
|
||||
row_wrap = row_stride - pixel_stride * width;
|
||||
|
||||
/* transform */
|
||||
|
@ -365,7 +357,8 @@ gst_color_effects_transform_rgb (GstColorEffects * filter, guint8 * data)
|
|||
}
|
||||
|
||||
static void
|
||||
gst_color_effects_transform_ayuv (GstColorEffects * filter, guint8 * data)
|
||||
gst_color_effects_transform_ayuv (GstColorEffects * filter,
|
||||
GstVideoFrame * frame)
|
||||
{
|
||||
gint i, j;
|
||||
gint width, height;
|
||||
|
@ -373,23 +366,18 @@ gst_color_effects_transform_ayuv (GstColorEffects * filter, guint8 * data)
|
|||
gint r, g, b;
|
||||
gint y, u, v;
|
||||
gint offsets[3];
|
||||
guint8 *data;
|
||||
|
||||
/* videoformat fun copied from videobalance */
|
||||
data = GST_VIDEO_FRAME_PLANE_DATA (frame, 0);
|
||||
offsets[0] = GST_VIDEO_FRAME_COMP_POFFSET (frame, 0);
|
||||
offsets[1] = GST_VIDEO_FRAME_COMP_POFFSET (frame, 1);
|
||||
offsets[2] = GST_VIDEO_FRAME_COMP_POFFSET (frame, 2);
|
||||
|
||||
offsets[0] = gst_video_format_get_component_offset (filter->format, 0,
|
||||
filter->width, filter->height);
|
||||
offsets[1] = gst_video_format_get_component_offset (filter->format, 1,
|
||||
filter->width, filter->height);
|
||||
offsets[2] = gst_video_format_get_component_offset (filter->format, 2,
|
||||
filter->width, filter->height);
|
||||
width = GST_VIDEO_FRAME_WIDTH (frame);
|
||||
height = GST_VIDEO_FRAME_HEIGHT (frame);
|
||||
|
||||
width =
|
||||
gst_video_format_get_component_width (filter->format, 0, filter->width);
|
||||
height =
|
||||
gst_video_format_get_component_height (filter->format, 0, filter->height);
|
||||
row_stride =
|
||||
gst_video_format_get_row_stride (filter->format, 0, filter->width);
|
||||
pixel_stride = gst_video_format_get_pixel_stride (filter->format, 0);
|
||||
row_stride = GST_VIDEO_FRAME_PLANE_STRIDE (frame, 0);
|
||||
pixel_stride = GST_VIDEO_FRAME_COMP_PSTRIDE (frame, 0);
|
||||
row_wrap = row_stride - pixel_stride * width;
|
||||
|
||||
for (i = 0; i < height; i++) {
|
||||
|
@ -445,25 +433,22 @@ gst_color_effects_transform_ayuv (GstColorEffects * filter, guint8 * data)
|
|||
}
|
||||
|
||||
static gboolean
|
||||
gst_color_effects_set_caps (GstBaseTransform * btrans, GstCaps * incaps,
|
||||
GstCaps * outcaps)
|
||||
gst_color_effects_set_info (GstVideoFilter * vfilter, GstCaps * incaps,
|
||||
GstVideoInfo * in_info, GstCaps * outcaps, GstVideoInfo * out_info)
|
||||
{
|
||||
GstColorEffects *filter = GST_COLOR_EFFECTS (btrans);
|
||||
GstColorEffects *filter = GST_COLOR_EFFECTS (vfilter);
|
||||
|
||||
GST_DEBUG_OBJECT (filter,
|
||||
"in %" GST_PTR_FORMAT " out %" GST_PTR_FORMAT, incaps, outcaps);
|
||||
|
||||
filter->process = NULL;
|
||||
|
||||
if (!gst_video_format_parse_caps (incaps, &filter->format,
|
||||
&filter->width, &filter->height))
|
||||
goto invalid_caps;
|
||||
filter->format = GST_VIDEO_INFO_FORMAT (in_info);
|
||||
filter->width = GST_VIDEO_INFO_WIDTH (in_info);
|
||||
filter->height = GST_VIDEO_INFO_HEIGHT (in_info);
|
||||
|
||||
GST_OBJECT_LOCK (filter);
|
||||
|
||||
filter->size =
|
||||
gst_video_format_get_size (filter->format, filter->width, filter->height);
|
||||
|
||||
switch (filter->format) {
|
||||
case GST_VIDEO_FORMAT_AYUV:
|
||||
filter->process = gst_color_effects_transform_ayuv;
|
||||
|
@ -487,65 +472,32 @@ gst_color_effects_set_caps (GstBaseTransform * btrans, GstCaps * incaps,
|
|||
GST_OBJECT_UNLOCK (filter);
|
||||
|
||||
return filter->process != NULL;
|
||||
|
||||
invalid_caps:
|
||||
GST_ERROR_OBJECT (filter, "Invalid caps: %" GST_PTR_FORMAT, incaps);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static GstFlowReturn
|
||||
gst_color_effects_transform_ip (GstBaseTransform * trans, GstBuffer * out)
|
||||
gst_color_effects_transform_frame_ip (GstVideoFilter * vfilter,
|
||||
GstVideoFrame * out)
|
||||
{
|
||||
GstColorEffects *filter = GST_COLOR_EFFECTS (trans);
|
||||
guint8 *data;
|
||||
gint size;
|
||||
GstColorEffects *filter = GST_COLOR_EFFECTS (vfilter);
|
||||
|
||||
if (!filter->process)
|
||||
goto not_negotiated;
|
||||
|
||||
data = GST_BUFFER_DATA (out);
|
||||
size = GST_BUFFER_SIZE (out);
|
||||
|
||||
if (size != filter->size)
|
||||
goto wrong_size;
|
||||
|
||||
/* do nothing if there is no table ("none" preset) */
|
||||
if (filter->table == NULL)
|
||||
return GST_FLOW_OK;
|
||||
|
||||
GST_OBJECT_LOCK (filter);
|
||||
filter->process (filter, data);
|
||||
filter->process (filter, out);
|
||||
GST_OBJECT_UNLOCK (filter);
|
||||
|
||||
return GST_FLOW_OK;
|
||||
|
||||
wrong_size:
|
||||
{
|
||||
GST_ELEMENT_ERROR (filter, STREAM, FORMAT,
|
||||
(NULL), ("Invalid buffer size %d, expected %d", size, filter->size));
|
||||
return GST_FLOW_ERROR;
|
||||
}
|
||||
not_negotiated:
|
||||
GST_ERROR_OBJECT (filter, "Not negotiated yet");
|
||||
return GST_FLOW_NOT_NEGOTIATED;
|
||||
}
|
||||
|
||||
static void
|
||||
gst_color_effects_base_init (gpointer g_class)
|
||||
{
|
||||
GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
|
||||
|
||||
gst_element_class_set_details_simple (element_class,
|
||||
"Color Look-up Table filter", "Filter/Effect/Video",
|
||||
"Color Look-up Table filter",
|
||||
"Filippo Argiolas <filippo.argiolas@gmail.com>");
|
||||
|
||||
gst_element_class_add_pad_template (element_class,
|
||||
gst_static_pad_template_get (&gst_color_effects_sink_template));
|
||||
gst_element_class_add_pad_template (element_class,
|
||||
gst_static_pad_template_get (&gst_color_effects_src_template));
|
||||
}
|
||||
|
||||
static void
|
||||
gst_color_effects_set_property (GObject * object, guint prop_id,
|
||||
const GValue * value, GParamSpec * pspec)
|
||||
|
@ -615,7 +567,8 @@ static void
|
|||
gst_color_effects_class_init (GstColorEffectsClass * klass)
|
||||
{
|
||||
GObjectClass *gobject_class = (GObjectClass *) klass;
|
||||
GstBaseTransformClass *trans_class = (GstBaseTransformClass *) klass;
|
||||
GstElementClass *element_class = (GstElementClass *) klass;
|
||||
GstVideoFilterClass *vfilter_class = (GstVideoFilterClass *) klass;
|
||||
|
||||
GST_DEBUG_CATEGORY_INIT (coloreffects_debug, "coloreffects", 0,
|
||||
"coloreffects");
|
||||
|
@ -628,13 +581,23 @@ gst_color_effects_class_init (GstColorEffectsClass * klass)
|
|||
GST_TYPE_COLOR_EFFECTS_PRESET, DEFAULT_PROP_PRESET,
|
||||
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
|
||||
|
||||
trans_class->set_caps = GST_DEBUG_FUNCPTR (gst_color_effects_set_caps);
|
||||
trans_class->transform_ip =
|
||||
GST_DEBUG_FUNCPTR (gst_color_effects_transform_ip);
|
||||
vfilter_class->set_info = GST_DEBUG_FUNCPTR (gst_color_effects_set_info);
|
||||
vfilter_class->transform_frame_ip =
|
||||
GST_DEBUG_FUNCPTR (gst_color_effects_transform_frame_ip);
|
||||
|
||||
gst_element_class_set_details_simple (element_class,
|
||||
"Color Look-up Table filter", "Filter/Effect/Video",
|
||||
"Color Look-up Table filter",
|
||||
"Filippo Argiolas <filippo.argiolas@gmail.com>");
|
||||
|
||||
gst_element_class_add_pad_template (element_class,
|
||||
gst_static_pad_template_get (&gst_color_effects_sink_template));
|
||||
gst_element_class_add_pad_template (element_class,
|
||||
gst_static_pad_template_get (&gst_color_effects_src_template));
|
||||
}
|
||||
|
||||
static void
|
||||
gst_color_effects_init (GstColorEffects * filter, GstColorEffectsClass * klass)
|
||||
gst_color_effects_init (GstColorEffects * filter)
|
||||
{
|
||||
filter->preset = GST_COLOR_EFFECTS_PRESET_NONE;
|
||||
filter->table = NULL;
|
||||
|
|
|
@ -77,9 +77,8 @@ struct _GstColorEffects
|
|||
GstVideoFormat format;
|
||||
gint width;
|
||||
gint height;
|
||||
gint size;
|
||||
|
||||
void (*process) (GstColorEffects * filter, guint8 * data);
|
||||
void (*process) (GstColorEffects * filter, GstVideoFrame * frame);
|
||||
};
|
||||
|
||||
struct _GstColorEffectsClass
|
||||
|
|
Loading…
Reference in a new issue