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 Non ported plugins (non-dependant, then dependant)
|
||||||
dnl Make sure you have a space before and after all plugins
|
dnl Make sure you have a space before and after all plugins
|
||||||
GST_PLUGINS_NONPORTED=" aiff \
|
GST_PLUGINS_NONPORTED=" aiff \
|
||||||
camerabin cdxaparse coloreffects \
|
camerabin cdxaparse \
|
||||||
dccp faceoverlay festival \
|
dccp faceoverlay festival \
|
||||||
fieldanalysis freeverb freeze frei0r gaudieffects \
|
fieldanalysis freeverb freeze frei0r gaudieffects \
|
||||||
hdvparse id3tag inter interlace ivfparse jpegformat jp2kdecimator \
|
hdvparse id3tag inter interlace ivfparse jpegformat jp2kdecimator \
|
||||||
|
|
|
@ -69,23 +69,19 @@ enum
|
||||||
};
|
};
|
||||||
|
|
||||||
static GstStaticPadTemplate gst_chroma_hold_src_template =
|
static GstStaticPadTemplate gst_chroma_hold_src_template =
|
||||||
GST_STATIC_PAD_TEMPLATE ("src",
|
GST_STATIC_PAD_TEMPLATE ("src",
|
||||||
GST_PAD_SRC,
|
GST_PAD_SRC,
|
||||||
GST_PAD_ALWAYS,
|
GST_PAD_ALWAYS,
|
||||||
GST_STATIC_CAPS (GST_VIDEO_CAPS_ARGB ";" GST_VIDEO_CAPS_BGRA ";"
|
GST_STATIC_CAPS (GST_VIDEO_CAPS_MAKE
|
||||||
GST_VIDEO_CAPS_ABGR ";" GST_VIDEO_CAPS_RGBA
|
("{ ARGB, BGRA, ABGR, RGBA, xRGB, BGRx, xBGR, RGBx}"))
|
||||||
";" GST_VIDEO_CAPS_xRGB ";" GST_VIDEO_CAPS_BGRx ";" GST_VIDEO_CAPS_xBGR
|
|
||||||
";" GST_VIDEO_CAPS_RGBx)
|
|
||||||
);
|
);
|
||||||
|
|
||||||
static GstStaticPadTemplate gst_chroma_hold_sink_template =
|
static GstStaticPadTemplate gst_chroma_hold_sink_template =
|
||||||
GST_STATIC_PAD_TEMPLATE ("sink",
|
GST_STATIC_PAD_TEMPLATE ("sink",
|
||||||
GST_PAD_SINK,
|
GST_PAD_SINK,
|
||||||
GST_PAD_ALWAYS,
|
GST_PAD_ALWAYS,
|
||||||
GST_STATIC_CAPS (GST_VIDEO_CAPS_ARGB ";" GST_VIDEO_CAPS_BGRA ";"
|
GST_STATIC_CAPS (GST_VIDEO_CAPS_MAKE
|
||||||
GST_VIDEO_CAPS_ABGR ";" GST_VIDEO_CAPS_RGBA
|
("{ ARGB, BGRA, ABGR, RGBA, xRGB, BGRx, xBGR, RGBx}"))
|
||||||
";" GST_VIDEO_CAPS_xRGB ";" GST_VIDEO_CAPS_BGRx ";" GST_VIDEO_CAPS_xBGR
|
|
||||||
";" GST_VIDEO_CAPS_RGBx)
|
|
||||||
);
|
);
|
||||||
|
|
||||||
#define GST_CHROMA_HOLD_LOCK(self) G_STMT_START { \
|
#define GST_CHROMA_HOLD_LOCK(self) G_STMT_START { \
|
||||||
|
@ -101,12 +97,11 @@ static GstStaticPadTemplate gst_chroma_hold_sink_template =
|
||||||
} G_STMT_END
|
} G_STMT_END
|
||||||
|
|
||||||
static gboolean gst_chroma_hold_start (GstBaseTransform * trans);
|
static gboolean gst_chroma_hold_start (GstBaseTransform * trans);
|
||||||
static gboolean gst_chroma_hold_get_unit_size (GstBaseTransform * btrans,
|
static gboolean gst_chroma_hold_set_info (GstVideoFilter * vfilter,
|
||||||
GstCaps * caps, guint * size);
|
GstCaps * incaps, GstVideoInfo * in_info, GstCaps * outcaps,
|
||||||
static gboolean gst_chroma_hold_set_caps (GstBaseTransform * btrans,
|
GstVideoInfo * out_info);
|
||||||
GstCaps * incaps, GstCaps * outcaps);
|
static GstFlowReturn gst_chroma_hold_transform_frame_ip (GstVideoFilter *
|
||||||
static GstFlowReturn gst_chroma_hold_transform_ip (GstBaseTransform * btrans,
|
vfilter, GstVideoFrame * frame);
|
||||||
GstBuffer * buf);
|
|
||||||
static void gst_chroma_hold_before_transform (GstBaseTransform * btrans,
|
static void gst_chroma_hold_before_transform (GstBaseTransform * btrans,
|
||||||
GstBuffer * buf);
|
GstBuffer * buf);
|
||||||
|
|
||||||
|
@ -119,33 +114,16 @@ static void gst_chroma_hold_get_property (GObject * object, guint prop_id,
|
||||||
GValue * value, GParamSpec * pspec);
|
GValue * value, GParamSpec * pspec);
|
||||||
static void gst_chroma_hold_finalize (GObject * object);
|
static void gst_chroma_hold_finalize (GObject * object);
|
||||||
|
|
||||||
GST_BOILERPLATE (GstChromaHold, gst_chroma_hold, GstVideoFilter,
|
#define gst_chroma_hold_parent_class parent_class
|
||||||
GST_TYPE_VIDEO_FILTER);
|
G_DEFINE_TYPE (GstChromaHold, gst_chroma_hold, 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");
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gst_chroma_hold_class_init (GstChromaHoldClass * klass)
|
gst_chroma_hold_class_init (GstChromaHoldClass * klass)
|
||||||
{
|
{
|
||||||
GObjectClass *gobject_class = (GObjectClass *) klass;
|
GObjectClass *gobject_class = (GObjectClass *) klass;
|
||||||
|
GstElementClass *gstelement_class = (GstElementClass *) klass;
|
||||||
GstBaseTransformClass *btrans_class = (GstBaseTransformClass *) klass;
|
GstBaseTransformClass *btrans_class = (GstBaseTransformClass *) klass;
|
||||||
|
GstVideoFilterClass *vfilter_class = (GstVideoFilterClass *) klass;
|
||||||
|
|
||||||
gobject_class->set_property = gst_chroma_hold_set_property;
|
gobject_class->set_property = gst_chroma_hold_set_property;
|
||||||
gobject_class->get_property = gst_chroma_hold_get_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));
|
G_PARAM_READWRITE | GST_PARAM_CONTROLLABLE | G_PARAM_STATIC_STRINGS));
|
||||||
|
|
||||||
btrans_class->start = GST_DEBUG_FUNCPTR (gst_chroma_hold_start);
|
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 =
|
btrans_class->before_transform =
|
||||||
GST_DEBUG_FUNCPTR (gst_chroma_hold_before_transform);
|
GST_DEBUG_FUNCPTR (gst_chroma_hold_before_transform);
|
||||||
btrans_class->get_unit_size =
|
|
||||||
GST_DEBUG_FUNCPTR (gst_chroma_hold_get_unit_size);
|
vfilter_class->transform_frame_ip =
|
||||||
btrans_class->set_caps = GST_DEBUG_FUNCPTR (gst_chroma_hold_set_caps);
|
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
|
static void
|
||||||
gst_chroma_hold_init (GstChromaHold * self, GstChromaHoldClass * klass)
|
gst_chroma_hold_init (GstChromaHold * self)
|
||||||
{
|
{
|
||||||
self->target_r = DEFAULT_TARGET_R;
|
self->target_r = DEFAULT_TARGET_R;
|
||||||
self->target_g = DEFAULT_TARGET_G;
|
self->target_g = DEFAULT_TARGET_G;
|
||||||
|
@ -255,43 +246,20 @@ gst_chroma_hold_get_property (GObject * object, guint prop_id, GValue * value,
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
gst_chroma_hold_get_unit_size (GstBaseTransform * btrans,
|
gst_chroma_hold_set_info (GstVideoFilter * vfilter, GstCaps * incaps,
|
||||||
GstCaps * caps, guint * size)
|
GstVideoInfo * in_info, GstCaps * outcaps, GstVideoInfo * out_info)
|
||||||
{
|
{
|
||||||
GstVideoFormat format;
|
GstChromaHold *self = GST_CHROMA_HOLD (vfilter);
|
||||||
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);
|
|
||||||
|
|
||||||
GST_CHROMA_HOLD_LOCK (self);
|
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,
|
GST_DEBUG_OBJECT (self,
|
||||||
"Setting caps %" GST_PTR_FORMAT " -> %" GST_PTR_FORMAT, incaps, outcaps);
|
"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)) {
|
if (!gst_chroma_hold_set_process_function (self)) {
|
||||||
GST_WARNING_OBJECT (self, "No processing function for this caps");
|
GST_WARNING_OBJECT (self, "No processing function for this caps");
|
||||||
GST_CHROMA_HOLD_UNLOCK (self);
|
GST_CHROMA_HOLD_UNLOCK (self);
|
||||||
|
@ -350,7 +318,7 @@ hue_dist (gint h1, gint h2)
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
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 height, GstChromaHold * self)
|
||||||
{
|
{
|
||||||
gint i, j;
|
gint i, j;
|
||||||
|
@ -360,11 +328,15 @@ gst_chroma_hold_process_xrgb (guint8 * dest, gint width,
|
||||||
gint tolerance = self->tolerance;
|
gint tolerance = self->tolerance;
|
||||||
gint p[4];
|
gint p[4];
|
||||||
gint diff;
|
gint diff;
|
||||||
|
gint row_wrap;
|
||||||
|
guint8 *dest;
|
||||||
|
|
||||||
p[0] = gst_video_format_get_component_offset (self->format, 3, width, height);
|
dest = GST_VIDEO_FRAME_PLANE_DATA (frame, 0);
|
||||||
p[1] = gst_video_format_get_component_offset (self->format, 0, width, height);
|
p[0] = GST_VIDEO_FRAME_COMP_POFFSET (frame, 3);
|
||||||
p[2] = gst_video_format_get_component_offset (self->format, 1, width, height);
|
p[1] = GST_VIDEO_FRAME_COMP_POFFSET (frame, 0);
|
||||||
p[3] = gst_video_format_get_component_offset (self->format, 2, width, height);
|
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;
|
h1 = self->hue;
|
||||||
|
|
||||||
|
@ -386,6 +358,7 @@ gst_chroma_hold_process_xrgb (guint8 * dest, gint width,
|
||||||
|
|
||||||
dest += 4;
|
dest += 4;
|
||||||
}
|
}
|
||||||
|
dest += row_wrap;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -445,10 +418,10 @@ gst_chroma_hold_before_transform (GstBaseTransform * btrans, GstBuffer * buf)
|
||||||
}
|
}
|
||||||
|
|
||||||
static GstFlowReturn
|
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);
|
GstChromaHold *self = GST_CHROMA_HOLD (vfilter);
|
||||||
gint width, height;
|
|
||||||
|
|
||||||
GST_CHROMA_HOLD_LOCK (self);
|
GST_CHROMA_HOLD_LOCK (self);
|
||||||
|
|
||||||
|
@ -458,10 +431,7 @@ gst_chroma_hold_transform_ip (GstBaseTransform * btrans, GstBuffer * buf)
|
||||||
return GST_FLOW_NOT_NEGOTIATED;
|
return GST_FLOW_NOT_NEGOTIATED;
|
||||||
}
|
}
|
||||||
|
|
||||||
width = self->width;
|
self->process (frame, self->width, self->height, self);
|
||||||
height = self->height;
|
|
||||||
|
|
||||||
self->process (GST_BUFFER_DATA (buf), width, height, self);
|
|
||||||
|
|
||||||
GST_CHROMA_HOLD_UNLOCK (self);
|
GST_CHROMA_HOLD_UNLOCK (self);
|
||||||
|
|
||||||
|
|
|
@ -28,7 +28,6 @@
|
||||||
#include <gst/gst.h>
|
#include <gst/gst.h>
|
||||||
#include <gst/video/video.h>
|
#include <gst/video/video.h>
|
||||||
#include <gst/video/gstvideofilter.h>
|
#include <gst/video/gstvideofilter.h>
|
||||||
#include <gst/controller/gstcontroller.h>
|
|
||||||
|
|
||||||
G_BEGIN_DECLS
|
G_BEGIN_DECLS
|
||||||
#define GST_TYPE_CHROMA_HOLD \
|
#define GST_TYPE_CHROMA_HOLD \
|
||||||
|
@ -62,7 +61,7 @@ struct _GstChromaHold
|
||||||
guint tolerance;
|
guint tolerance;
|
||||||
|
|
||||||
/* processing function */
|
/* processing function */
|
||||||
void (*process) (guint8 * dest, gint width, gint height,
|
void (*process) (GstVideoFrame * frame, gint width, gint height,
|
||||||
GstChromaHold * chroma_hold);
|
GstChromaHold * chroma_hold);
|
||||||
|
|
||||||
/* pre-calculated values */
|
/* pre-calculated values */
|
||||||
|
|
|
@ -49,15 +49,11 @@ enum
|
||||||
PROP_PRESET
|
PROP_PRESET
|
||||||
};
|
};
|
||||||
|
|
||||||
GST_BOILERPLATE (GstColorEffects, gst_color_effects, GstVideoFilter,
|
#define gst_color_effects_parent_class parent_class
|
||||||
GST_TYPE_VIDEO_FILTER);
|
G_DEFINE_TYPE (GstColorEffects, gst_color_effects, GST_TYPE_VIDEO_FILTER);
|
||||||
|
|
||||||
#define CAPS_STR GST_VIDEO_CAPS_ARGB ";" GST_VIDEO_CAPS_BGRA ";"\
|
#define CAPS_STR GST_VIDEO_CAPS_MAKE ("{ " \
|
||||||
GST_VIDEO_CAPS_ABGR ";" GST_VIDEO_CAPS_RGBA ";"\
|
"ARGB, BGRA, ABGR, RGBA, xRGB, BGRx, xBGR, RGBx, RGB, BGR, AYUV }")
|
||||||
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") ";"
|
|
||||||
|
|
||||||
static GstStaticPadTemplate gst_color_effects_src_template =
|
static GstStaticPadTemplate gst_color_effects_src_template =
|
||||||
GST_STATIC_PAD_TEMPLATE ("src",
|
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)
|
m[o*4+2] * v3 + m[o*4+3]) >> 8)
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gst_color_effects_transform_rgb (GstColorEffects * filter, guint8 * data)
|
gst_color_effects_transform_rgb (GstColorEffects * filter,
|
||||||
|
GstVideoFrame * frame)
|
||||||
{
|
{
|
||||||
gint i, j;
|
gint i, j;
|
||||||
gint width, height;
|
gint width, height;
|
||||||
|
@ -311,23 +308,18 @@ gst_color_effects_transform_rgb (GstColorEffects * filter, guint8 * data)
|
||||||
guint32 r, g, b;
|
guint32 r, g, b;
|
||||||
guint32 luma;
|
guint32 luma;
|
||||||
gint offsets[3];
|
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,
|
width = GST_VIDEO_FRAME_WIDTH (frame);
|
||||||
filter->width, filter->height);
|
height = GST_VIDEO_FRAME_HEIGHT (frame);
|
||||||
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 =
|
row_stride = GST_VIDEO_FRAME_PLANE_STRIDE (frame, 0);
|
||||||
gst_video_format_get_component_width (filter->format, 0, filter->width);
|
pixel_stride = GST_VIDEO_FRAME_COMP_PSTRIDE (frame, 0);
|
||||||
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_wrap = row_stride - pixel_stride * width;
|
row_wrap = row_stride - pixel_stride * width;
|
||||||
|
|
||||||
/* transform */
|
/* transform */
|
||||||
|
@ -365,7 +357,8 @@ gst_color_effects_transform_rgb (GstColorEffects * filter, guint8 * data)
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gst_color_effects_transform_ayuv (GstColorEffects * filter, guint8 * data)
|
gst_color_effects_transform_ayuv (GstColorEffects * filter,
|
||||||
|
GstVideoFrame * frame)
|
||||||
{
|
{
|
||||||
gint i, j;
|
gint i, j;
|
||||||
gint width, height;
|
gint width, height;
|
||||||
|
@ -373,23 +366,18 @@ gst_color_effects_transform_ayuv (GstColorEffects * filter, guint8 * data)
|
||||||
gint r, g, b;
|
gint r, g, b;
|
||||||
gint y, u, v;
|
gint y, u, v;
|
||||||
gint offsets[3];
|
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,
|
width = GST_VIDEO_FRAME_WIDTH (frame);
|
||||||
filter->width, filter->height);
|
height = GST_VIDEO_FRAME_HEIGHT (frame);
|
||||||
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 =
|
row_stride = GST_VIDEO_FRAME_PLANE_STRIDE (frame, 0);
|
||||||
gst_video_format_get_component_width (filter->format, 0, filter->width);
|
pixel_stride = GST_VIDEO_FRAME_COMP_PSTRIDE (frame, 0);
|
||||||
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_wrap = row_stride - pixel_stride * width;
|
row_wrap = row_stride - pixel_stride * width;
|
||||||
|
|
||||||
for (i = 0; i < height; i++) {
|
for (i = 0; i < height; i++) {
|
||||||
|
@ -445,25 +433,22 @@ gst_color_effects_transform_ayuv (GstColorEffects * filter, guint8 * data)
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
gst_color_effects_set_caps (GstBaseTransform * btrans, GstCaps * incaps,
|
gst_color_effects_set_info (GstVideoFilter * vfilter, GstCaps * incaps,
|
||||||
GstCaps * outcaps)
|
GstVideoInfo * in_info, GstCaps * outcaps, GstVideoInfo * out_info)
|
||||||
{
|
{
|
||||||
GstColorEffects *filter = GST_COLOR_EFFECTS (btrans);
|
GstColorEffects *filter = GST_COLOR_EFFECTS (vfilter);
|
||||||
|
|
||||||
GST_DEBUG_OBJECT (filter,
|
GST_DEBUG_OBJECT (filter,
|
||||||
"in %" GST_PTR_FORMAT " out %" GST_PTR_FORMAT, incaps, outcaps);
|
"in %" GST_PTR_FORMAT " out %" GST_PTR_FORMAT, incaps, outcaps);
|
||||||
|
|
||||||
filter->process = NULL;
|
filter->process = NULL;
|
||||||
|
|
||||||
if (!gst_video_format_parse_caps (incaps, &filter->format,
|
filter->format = GST_VIDEO_INFO_FORMAT (in_info);
|
||||||
&filter->width, &filter->height))
|
filter->width = GST_VIDEO_INFO_WIDTH (in_info);
|
||||||
goto invalid_caps;
|
filter->height = GST_VIDEO_INFO_HEIGHT (in_info);
|
||||||
|
|
||||||
GST_OBJECT_LOCK (filter);
|
GST_OBJECT_LOCK (filter);
|
||||||
|
|
||||||
filter->size =
|
|
||||||
gst_video_format_get_size (filter->format, filter->width, filter->height);
|
|
||||||
|
|
||||||
switch (filter->format) {
|
switch (filter->format) {
|
||||||
case GST_VIDEO_FORMAT_AYUV:
|
case GST_VIDEO_FORMAT_AYUV:
|
||||||
filter->process = gst_color_effects_transform_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);
|
GST_OBJECT_UNLOCK (filter);
|
||||||
|
|
||||||
return filter->process != NULL;
|
return filter->process != NULL;
|
||||||
|
|
||||||
invalid_caps:
|
|
||||||
GST_ERROR_OBJECT (filter, "Invalid caps: %" GST_PTR_FORMAT, incaps);
|
|
||||||
return FALSE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static GstFlowReturn
|
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);
|
GstColorEffects *filter = GST_COLOR_EFFECTS (vfilter);
|
||||||
guint8 *data;
|
|
||||||
gint size;
|
|
||||||
|
|
||||||
if (!filter->process)
|
if (!filter->process)
|
||||||
goto not_negotiated;
|
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) */
|
/* do nothing if there is no table ("none" preset) */
|
||||||
if (filter->table == NULL)
|
if (filter->table == NULL)
|
||||||
return GST_FLOW_OK;
|
return GST_FLOW_OK;
|
||||||
|
|
||||||
GST_OBJECT_LOCK (filter);
|
GST_OBJECT_LOCK (filter);
|
||||||
filter->process (filter, data);
|
filter->process (filter, out);
|
||||||
GST_OBJECT_UNLOCK (filter);
|
GST_OBJECT_UNLOCK (filter);
|
||||||
|
|
||||||
return GST_FLOW_OK;
|
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:
|
not_negotiated:
|
||||||
GST_ERROR_OBJECT (filter, "Not negotiated yet");
|
GST_ERROR_OBJECT (filter, "Not negotiated yet");
|
||||||
return GST_FLOW_NOT_NEGOTIATED;
|
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
|
static void
|
||||||
gst_color_effects_set_property (GObject * object, guint prop_id,
|
gst_color_effects_set_property (GObject * object, guint prop_id,
|
||||||
const GValue * value, GParamSpec * pspec)
|
const GValue * value, GParamSpec * pspec)
|
||||||
|
@ -615,7 +567,8 @@ static void
|
||||||
gst_color_effects_class_init (GstColorEffectsClass * klass)
|
gst_color_effects_class_init (GstColorEffectsClass * klass)
|
||||||
{
|
{
|
||||||
GObjectClass *gobject_class = (GObjectClass *) 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,
|
GST_DEBUG_CATEGORY_INIT (coloreffects_debug, "coloreffects", 0,
|
||||||
"coloreffects");
|
"coloreffects");
|
||||||
|
@ -628,13 +581,23 @@ gst_color_effects_class_init (GstColorEffectsClass * klass)
|
||||||
GST_TYPE_COLOR_EFFECTS_PRESET, DEFAULT_PROP_PRESET,
|
GST_TYPE_COLOR_EFFECTS_PRESET, DEFAULT_PROP_PRESET,
|
||||||
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
|
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
|
||||||
|
|
||||||
trans_class->set_caps = GST_DEBUG_FUNCPTR (gst_color_effects_set_caps);
|
vfilter_class->set_info = GST_DEBUG_FUNCPTR (gst_color_effects_set_info);
|
||||||
trans_class->transform_ip =
|
vfilter_class->transform_frame_ip =
|
||||||
GST_DEBUG_FUNCPTR (gst_color_effects_transform_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
|
static void
|
||||||
gst_color_effects_init (GstColorEffects * filter, GstColorEffectsClass * klass)
|
gst_color_effects_init (GstColorEffects * filter)
|
||||||
{
|
{
|
||||||
filter->preset = GST_COLOR_EFFECTS_PRESET_NONE;
|
filter->preset = GST_COLOR_EFFECTS_PRESET_NONE;
|
||||||
filter->table = NULL;
|
filter->table = NULL;
|
||||||
|
|
|
@ -77,9 +77,8 @@ struct _GstColorEffects
|
||||||
GstVideoFormat format;
|
GstVideoFormat format;
|
||||||
gint width;
|
gint width;
|
||||||
gint height;
|
gint height;
|
||||||
gint size;
|
|
||||||
|
|
||||||
void (*process) (GstColorEffects * filter, guint8 * data);
|
void (*process) (GstColorEffects * filter, GstVideoFrame * frame);
|
||||||
};
|
};
|
||||||
|
|
||||||
struct _GstColorEffectsClass
|
struct _GstColorEffectsClass
|
||||||
|
|
Loading…
Reference in a new issue