mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-06-06 07:28:53 +00:00
Ported alpha, remove alphacolor as functionality is in ffmpegcolorspace.
Original commit message from CVS: * configure.ac: * gst/alpha/Makefile.am: * gst/alpha/gstalpha.c: (gst_alpha_class_init), (gst_alpha_init), (gst_alpha_sink_setcaps), (gst_alpha_chain): Ported alpha, remove alphacolor as functionality is in ffmpegcolorspace.
This commit is contained in:
parent
d564e75b34
commit
97f9bab6e8
5 changed files with 36 additions and 567 deletions
|
@ -1,3 +1,12 @@
|
||||||
|
2005-05-17 Wim Taymans <wim@fluendo.com>
|
||||||
|
|
||||||
|
* configure.ac:
|
||||||
|
* gst/alpha/Makefile.am:
|
||||||
|
* gst/alpha/gstalpha.c: (gst_alpha_class_init), (gst_alpha_init),
|
||||||
|
(gst_alpha_sink_setcaps), (gst_alpha_chain):
|
||||||
|
Ported alpha, remove alphacolor as functionality is in
|
||||||
|
ffmpegcolorspace.
|
||||||
|
|
||||||
2005-05-17 Wim Taymans <wim@fluendo.com>
|
2005-05-17 Wim Taymans <wim@fluendo.com>
|
||||||
|
|
||||||
* ext/libcaca/gstcacasink.c: (gst_cacasink_setcaps),
|
* ext/libcaca/gstcacasink.c: (gst_cacasink_setcaps),
|
||||||
|
|
|
@ -1,14 +1,9 @@
|
||||||
|
|
||||||
plugin_LTLIBRARIES = libgstalpha.la libgstalphacolor.la
|
plugin_LTLIBRARIES = libgstalpha.la
|
||||||
|
|
||||||
libgstalpha_la_SOURCES = gstalpha.c
|
libgstalpha_la_SOURCES = gstalpha.c
|
||||||
libgstalpha_la_CFLAGS = $(GST_CFLAGS)
|
libgstalpha_la_CFLAGS = $(GST_CFLAGS) $(GST_PLUGINS_LIBS_CFLAGS)
|
||||||
libgstalpha_la_LIBADD =
|
libgstalpha_la_LIBADD =
|
||||||
libgstalpha_la_LDFLAGS = $(GST_PLUGIN_LDFLAGS)
|
libgstalpha_la_LDFLAGS = $(GST_PLUGIN_LDFLAGS)
|
||||||
|
|
||||||
libgstalphacolor_la_SOURCES = gstalphacolor.c
|
|
||||||
libgstalphacolor_la_CFLAGS = $(GST_CFLAGS)
|
|
||||||
libgstalphacolor_la_LIBADD =
|
|
||||||
libgstalphacolor_la_LDFLAGS = $(GST_PLUGIN_LDFLAGS)
|
|
||||||
|
|
||||||
noinst_HEADERS =
|
noinst_HEADERS =
|
||||||
|
|
|
@ -1,145 +0,0 @@
|
||||||
<?xml version="1.0" encoding="Windows-1252"?>
|
|
||||||
<VisualStudioProject
|
|
||||||
ProjectType="Visual C++"
|
|
||||||
Version="7.10"
|
|
||||||
Name="alphacolor"
|
|
||||||
ProjectGUID="{979C216F-0ACF-4956-AE00-055A42D678A2}"
|
|
||||||
Keyword="Win32Proj">
|
|
||||||
<Platforms>
|
|
||||||
<Platform
|
|
||||||
Name="Win32"/>
|
|
||||||
</Platforms>
|
|
||||||
<Configurations>
|
|
||||||
<Configuration
|
|
||||||
Name="Debug|Win32"
|
|
||||||
OutputDirectory="../../win32/Debug"
|
|
||||||
IntermediateDirectory="../../win32/Debug"
|
|
||||||
ConfigurationType="2"
|
|
||||||
CharacterSet="2">
|
|
||||||
<Tool
|
|
||||||
Name="VCCLCompilerTool"
|
|
||||||
Optimization="0"
|
|
||||||
AdditionalIncludeDirectories="../../../gstreamer/win32;../../../gstreamer;../../../gstreamer/libs;../../../glib;../../../glib/glib;../../../glib/gmodule;"../../gst-libs";../../../popt/include;../../../libxml2/include/libxml2"
|
|
||||||
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;alphacolor_EXPORTS;HAVE_CONFIG_H;_USE_MATH_DEFINES"
|
|
||||||
MinimalRebuild="TRUE"
|
|
||||||
BasicRuntimeChecks="3"
|
|
||||||
RuntimeLibrary="3"
|
|
||||||
UsePrecompiledHeader="0"
|
|
||||||
WarningLevel="3"
|
|
||||||
Detect64BitPortabilityProblems="TRUE"
|
|
||||||
DebugInformationFormat="4"/>
|
|
||||||
<Tool
|
|
||||||
Name="VCCustomBuildTool"/>
|
|
||||||
<Tool
|
|
||||||
Name="VCLinkerTool"
|
|
||||||
AdditionalDependencies="glib-2.0.lib gmodule-2.0.lib gthread-2.0.lib gobject-2.0.lib libgstreamer.lib gstbytestream.lib iconv.lib intl.lib"
|
|
||||||
OutputFile="$(OutDir)/gstalphacolor.dll"
|
|
||||||
LinkIncremental="2"
|
|
||||||
AdditionalLibraryDirectories="../../../gstreamer/win32/Debug;../../../glib/glib;../../../glib/gmodule;../../../glib/gthread;../../../glib/gobject;../../../gettext/lib;../../../libiconv/lib"
|
|
||||||
ModuleDefinitionFile=""
|
|
||||||
GenerateDebugInformation="TRUE"
|
|
||||||
ProgramDatabaseFile="$(OutDir)/alphacolor.pdb"
|
|
||||||
SubSystem="2"
|
|
||||||
OptimizeReferences="2"
|
|
||||||
ImportLibrary="$(OutDir)/gstalphacolor.lib"
|
|
||||||
TargetMachine="1"/>
|
|
||||||
<Tool
|
|
||||||
Name="VCMIDLTool"/>
|
|
||||||
<Tool
|
|
||||||
Name="VCPostBuildEventTool"
|
|
||||||
CommandLine="copy /Y $(TargetPath) c:\gstreamer\plugins"/>
|
|
||||||
<Tool
|
|
||||||
Name="VCPreBuildEventTool"/>
|
|
||||||
<Tool
|
|
||||||
Name="VCPreLinkEventTool"/>
|
|
||||||
<Tool
|
|
||||||
Name="VCResourceCompilerTool"/>
|
|
||||||
<Tool
|
|
||||||
Name="VCWebServiceProxyGeneratorTool"/>
|
|
||||||
<Tool
|
|
||||||
Name="VCXMLDataGeneratorTool"/>
|
|
||||||
<Tool
|
|
||||||
Name="VCWebDeploymentTool"/>
|
|
||||||
<Tool
|
|
||||||
Name="VCManagedWrapperGeneratorTool"/>
|
|
||||||
<Tool
|
|
||||||
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
|
|
||||||
</Configuration>
|
|
||||||
<Configuration
|
|
||||||
Name="Release|Win32"
|
|
||||||
OutputDirectory="../../win32/Release"
|
|
||||||
IntermediateDirectory="../../win32/Release"
|
|
||||||
ConfigurationType="2"
|
|
||||||
CharacterSet="2">
|
|
||||||
<Tool
|
|
||||||
Name="VCCLCompilerTool"
|
|
||||||
AdditionalIncludeDirectories="../../../gstreamer/win32;../../../gstreamer;../../../gstreamer/libs;../../../glib;../../../glib/glib;../../../glib/gmodule;"../../gst-libs";../../../popt/include;../../../libxml2/include/libxml2"
|
|
||||||
PreprocessorDefinitions="WIN32;NDEBUG;GST_DISABLE_GST_DEBUG;_WINDOWS;_USRDLL;alphacolor_EXPORTS;HAVE_CONFIG_H;_USE_MATH_DEFINES"
|
|
||||||
RuntimeLibrary="2"
|
|
||||||
UsePrecompiledHeader="0"
|
|
||||||
WarningLevel="3"
|
|
||||||
Detect64BitPortabilityProblems="TRUE"
|
|
||||||
DebugInformationFormat="3"/>
|
|
||||||
<Tool
|
|
||||||
Name="VCCustomBuildTool"/>
|
|
||||||
<Tool
|
|
||||||
Name="VCLinkerTool"
|
|
||||||
AdditionalDependencies="glib-2.0.lib gmodule-2.0.lib gthread-2.0.lib gobject-2.0.lib libgstreamer.lib gstbytestream.lib iconv.lib intl.lib"
|
|
||||||
OutputFile="$(OutDir)/gstalphacolor.dll"
|
|
||||||
LinkIncremental="1"
|
|
||||||
AdditionalLibraryDirectories="../../../gstreamer/win32/Release;../../../glib/glib;../../../glib/gmodule;../../../glib/gthread;../../../glib/gobject;../../../gettext/lib;../../../libiconv/lib"
|
|
||||||
ModuleDefinitionFile=""
|
|
||||||
GenerateDebugInformation="TRUE"
|
|
||||||
SubSystem="2"
|
|
||||||
OptimizeReferences="2"
|
|
||||||
EnableCOMDATFolding="2"
|
|
||||||
ImportLibrary="$(OutDir)/gstalphacolor.lib"
|
|
||||||
TargetMachine="1"/>
|
|
||||||
<Tool
|
|
||||||
Name="VCMIDLTool"/>
|
|
||||||
<Tool
|
|
||||||
Name="VCPostBuildEventTool"
|
|
||||||
CommandLine="copy /Y $(TargetPath) c:\gstreamer\plugins"/>
|
|
||||||
<Tool
|
|
||||||
Name="VCPreBuildEventTool"/>
|
|
||||||
<Tool
|
|
||||||
Name="VCPreLinkEventTool"/>
|
|
||||||
<Tool
|
|
||||||
Name="VCResourceCompilerTool"/>
|
|
||||||
<Tool
|
|
||||||
Name="VCWebServiceProxyGeneratorTool"/>
|
|
||||||
<Tool
|
|
||||||
Name="VCXMLDataGeneratorTool"/>
|
|
||||||
<Tool
|
|
||||||
Name="VCWebDeploymentTool"/>
|
|
||||||
<Tool
|
|
||||||
Name="VCManagedWrapperGeneratorTool"/>
|
|
||||||
<Tool
|
|
||||||
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
|
|
||||||
</Configuration>
|
|
||||||
</Configurations>
|
|
||||||
<References>
|
|
||||||
</References>
|
|
||||||
<Files>
|
|
||||||
<Filter
|
|
||||||
Name="Source Files"
|
|
||||||
Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx"
|
|
||||||
UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}">
|
|
||||||
<File
|
|
||||||
RelativePath=".\gstalphacolor.c">
|
|
||||||
</File>
|
|
||||||
</Filter>
|
|
||||||
<Filter
|
|
||||||
Name="Header Files"
|
|
||||||
Filter="h;hpp;hxx;hm;inl;inc;xsd"
|
|
||||||
UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}">
|
|
||||||
</Filter>
|
|
||||||
<Filter
|
|
||||||
Name="Resource Files"
|
|
||||||
Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx"
|
|
||||||
UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}">
|
|
||||||
</Filter>
|
|
||||||
</Files>
|
|
||||||
<Globals>
|
|
||||||
</Globals>
|
|
||||||
</VisualStudioProject>
|
|
|
@ -156,9 +156,8 @@ static void gst_alpha_set_property (GObject * object, guint prop_id,
|
||||||
static void gst_alpha_get_property (GObject * object, guint prop_id,
|
static void gst_alpha_get_property (GObject * object, guint prop_id,
|
||||||
GValue * value, GParamSpec * pspec);
|
GValue * value, GParamSpec * pspec);
|
||||||
|
|
||||||
static GstPadLinkReturn
|
static gboolean gst_alpha_sink_setcaps (GstPad * pad, GstCaps * caps);
|
||||||
gst_alpha_sink_link (GstPad * pad, const GstCaps * caps);
|
static GstFlowReturn gst_alpha_chain (GstPad * pad, GstBuffer * buffer);
|
||||||
static void gst_alpha_chain (GstPad * pad, GstData * _data);
|
|
||||||
|
|
||||||
static GstElementStateReturn gst_alpha_change_state (GstElement * element);
|
static GstElementStateReturn gst_alpha_change_state (GstElement * element);
|
||||||
|
|
||||||
|
@ -233,6 +232,9 @@ gst_alpha_class_init (GstAlphaClass * klass)
|
||||||
|
|
||||||
parent_class = g_type_class_ref (GST_TYPE_ELEMENT);
|
parent_class = g_type_class_ref (GST_TYPE_ELEMENT);
|
||||||
|
|
||||||
|
gobject_class->set_property = gst_alpha_set_property;
|
||||||
|
gobject_class->get_property = gst_alpha_get_property;
|
||||||
|
|
||||||
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_METHOD,
|
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_METHOD,
|
||||||
g_param_spec_enum ("method", "Method",
|
g_param_spec_enum ("method", "Method",
|
||||||
"How the alpha channels should be created", GST_TYPE_ALPHA_METHOD,
|
"How the alpha channels should be created", GST_TYPE_ALPHA_METHOD,
|
||||||
|
@ -256,9 +258,6 @@ gst_alpha_class_init (GstAlphaClass * klass)
|
||||||
g_param_spec_float ("noise_level", "Noise Level", "Size of noise radius",
|
g_param_spec_float ("noise_level", "Noise Level", "Size of noise radius",
|
||||||
0.0, 64.0, DEFAULT_NOISE_LEVEL, (GParamFlags) G_PARAM_READWRITE));
|
0.0, 64.0, DEFAULT_NOISE_LEVEL, (GParamFlags) G_PARAM_READWRITE));
|
||||||
|
|
||||||
gobject_class->set_property = gst_alpha_set_property;
|
|
||||||
gobject_class->get_property = gst_alpha_get_property;
|
|
||||||
|
|
||||||
gstelement_class->change_state = gst_alpha_change_state;
|
gstelement_class->change_state = gst_alpha_change_state;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -271,7 +270,7 @@ gst_alpha_init (GstAlpha * alpha)
|
||||||
(&gst_alpha_sink_template), "sink");
|
(&gst_alpha_sink_template), "sink");
|
||||||
gst_element_add_pad (GST_ELEMENT (alpha), alpha->sinkpad);
|
gst_element_add_pad (GST_ELEMENT (alpha), alpha->sinkpad);
|
||||||
gst_pad_set_chain_function (alpha->sinkpad, gst_alpha_chain);
|
gst_pad_set_chain_function (alpha->sinkpad, gst_alpha_chain);
|
||||||
gst_pad_set_link_function (alpha->sinkpad, gst_alpha_sink_link);
|
gst_pad_set_setcaps_function (alpha->sinkpad, gst_alpha_sink_setcaps);
|
||||||
|
|
||||||
alpha->srcpad =
|
alpha->srcpad =
|
||||||
gst_pad_new_from_template (gst_static_pad_template_get
|
gst_pad_new_from_template (gst_static_pad_template_get
|
||||||
|
@ -285,8 +284,6 @@ gst_alpha_init (GstAlpha * alpha)
|
||||||
alpha->target_b = DEFAULT_TARGET_B;
|
alpha->target_b = DEFAULT_TARGET_B;
|
||||||
alpha->angle = DEFAULT_ANGLE;
|
alpha->angle = DEFAULT_ANGLE;
|
||||||
alpha->noise_level = DEFAULT_NOISE_LEVEL;
|
alpha->noise_level = DEFAULT_NOISE_LEVEL;
|
||||||
|
|
||||||
GST_FLAG_SET (alpha, GST_ELEMENT_EVENT_AWARE);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* do we need this function? */
|
/* do we need this function? */
|
||||||
|
@ -387,15 +384,15 @@ gst_alpha_get_property (GObject * object, guint prop_id, GValue * value,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static GstPadLinkReturn
|
static gboolean
|
||||||
gst_alpha_sink_link (GstPad * pad, const GstCaps * caps)
|
gst_alpha_sink_setcaps (GstPad * pad, GstCaps * caps)
|
||||||
{
|
{
|
||||||
GstAlpha *alpha;
|
GstAlpha *alpha;
|
||||||
GstStructure *structure;
|
GstStructure *structure;
|
||||||
gboolean ret;
|
gboolean ret;
|
||||||
guint32 fourcc;
|
guint32 fourcc;
|
||||||
|
|
||||||
alpha = GST_ALPHA (gst_pad_get_parent (pad));
|
alpha = GST_ALPHA (GST_PAD_PARENT (pad));
|
||||||
structure = gst_caps_get_structure (caps, 0);
|
structure = gst_caps_get_structure (caps, 0);
|
||||||
|
|
||||||
if (gst_structure_get_fourcc (structure, "format", &fourcc)) {
|
if (gst_structure_get_fourcc (structure, "format", &fourcc)) {
|
||||||
|
@ -407,16 +404,16 @@ gst_alpha_sink_link (GstPad * pad, const GstCaps * caps)
|
||||||
alpha->ayuv = TRUE;
|
alpha->ayuv = TRUE;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
return GST_PAD_LINK_REFUSED;
|
return FALSE;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
return GST_PAD_LINK_REFUSED;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = gst_structure_get_int (structure, "width", &alpha->in_width);
|
ret = gst_structure_get_int (structure, "width", &alpha->in_width);
|
||||||
ret &= gst_structure_get_int (structure, "height", &alpha->in_height);
|
ret &= gst_structure_get_int (structure, "height", &alpha->in_height);
|
||||||
|
|
||||||
return GST_PAD_LINK_OK;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -791,34 +788,23 @@ gst_alpha_init_params (GstAlpha * alpha)
|
||||||
alpha->kg = MIN (kgl, 127);
|
alpha->kg = MIN (kgl, 127);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static GstFlowReturn
|
||||||
gst_alpha_chain (GstPad * pad, GstData * _data)
|
gst_alpha_chain (GstPad * pad, GstBuffer * buffer)
|
||||||
{
|
{
|
||||||
GstBuffer *buffer;
|
|
||||||
GstAlpha *alpha;
|
GstAlpha *alpha;
|
||||||
GstBuffer *outbuf;
|
GstBuffer *outbuf;
|
||||||
gint new_width, new_height;
|
gint new_width, new_height;
|
||||||
|
GstFlowReturn ret;
|
||||||
|
|
||||||
alpha = GST_ALPHA (gst_pad_get_parent (pad));
|
alpha = GST_ALPHA (GST_PAD_PARENT (pad));
|
||||||
|
|
||||||
if (GST_IS_EVENT (_data)) {
|
GST_STREAM_LOCK (pad);
|
||||||
GstEvent *event = GST_EVENT (_data);
|
|
||||||
|
|
||||||
switch (GST_EVENT_TYPE (event)) {
|
|
||||||
default:
|
|
||||||
gst_pad_event_default (pad, event);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
buffer = GST_BUFFER (_data);
|
|
||||||
|
|
||||||
new_width = alpha->in_width;
|
new_width = alpha->in_width;
|
||||||
new_height = alpha->in_height;
|
new_height = alpha->in_height;
|
||||||
|
|
||||||
if (new_width != alpha->out_width ||
|
if (new_width != alpha->out_width ||
|
||||||
new_height != alpha->out_height || !GST_PAD_CAPS (alpha->srcpad)) {
|
new_height != alpha->out_height || !GST_RPAD_CAPS (alpha->srcpad)) {
|
||||||
GstCaps *newcaps;
|
GstCaps *newcaps;
|
||||||
|
|
||||||
newcaps = gst_caps_copy (gst_pad_get_negotiated_caps (alpha->sinkpad));
|
newcaps = gst_caps_copy (gst_pad_get_negotiated_caps (alpha->sinkpad));
|
||||||
|
@ -826,10 +812,7 @@ gst_alpha_chain (GstPad * pad, GstData * _data)
|
||||||
"format", GST_TYPE_FOURCC, GST_STR_FOURCC ("AYUV"),
|
"format", GST_TYPE_FOURCC, GST_STR_FOURCC ("AYUV"),
|
||||||
"width", G_TYPE_INT, new_width, "height", G_TYPE_INT, new_height, NULL);
|
"width", G_TYPE_INT, new_width, "height", G_TYPE_INT, new_height, NULL);
|
||||||
|
|
||||||
if (!gst_pad_try_set_caps (alpha->srcpad, newcaps)) {
|
gst_pad_set_caps (alpha->srcpad, newcaps);
|
||||||
GST_ELEMENT_ERROR (alpha, CORE, NEGOTIATION, (NULL), (NULL));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
alpha->out_width = new_width;
|
alpha->out_width = new_width;
|
||||||
alpha->out_height = new_height;
|
alpha->out_height = new_height;
|
||||||
|
@ -838,6 +821,7 @@ gst_alpha_chain (GstPad * pad, GstData * _data)
|
||||||
outbuf =
|
outbuf =
|
||||||
gst_buffer_new_and_alloc (ROUND_UP_2 (new_width) *
|
gst_buffer_new_and_alloc (ROUND_UP_2 (new_width) *
|
||||||
ROUND_UP_2 (new_height) * 4);
|
ROUND_UP_2 (new_height) * 4);
|
||||||
|
gst_buffer_set_caps (outbuf, GST_RPAD_CAPS (alpha->srcpad));
|
||||||
GST_BUFFER_TIMESTAMP (outbuf) = GST_BUFFER_TIMESTAMP (buffer);
|
GST_BUFFER_TIMESTAMP (outbuf) = GST_BUFFER_TIMESTAMP (buffer);
|
||||||
GST_BUFFER_DURATION (outbuf) = GST_BUFFER_DURATION (buffer);
|
GST_BUFFER_DURATION (outbuf) = GST_BUFFER_DURATION (buffer);
|
||||||
|
|
||||||
|
@ -868,7 +852,11 @@ gst_alpha_chain (GstPad * pad, GstData * _data)
|
||||||
|
|
||||||
gst_buffer_unref (buffer);
|
gst_buffer_unref (buffer);
|
||||||
|
|
||||||
gst_pad_push (alpha->srcpad, GST_DATA (outbuf));
|
ret = gst_pad_push (alpha->srcpad, outbuf);
|
||||||
|
|
||||||
|
GST_STREAM_UNLOCK (pad);
|
||||||
|
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static GstElementStateReturn
|
static GstElementStateReturn
|
||||||
|
|
|
@ -1,378 +0,0 @@
|
||||||
/* GStreamer
|
|
||||||
* Copyright (C) <1999> Erik Walthinsen <omega@cse.ogi.edu>
|
|
||||||
*
|
|
||||||
* This library is free software; you can redistribute it and/or
|
|
||||||
* modify it under the terms of the GNU Library General Public
|
|
||||||
* License as published by the Free Software Foundation; either
|
|
||||||
* version 2 of the License, or (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This library is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
||||||
* Library General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU Library General Public
|
|
||||||
* License along with this library; if not, write to the
|
|
||||||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
||||||
* Boston, MA 02111-1307, USA.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifdef HAVE_CONFIG_H
|
|
||||||
#include "config.h"
|
|
||||||
#endif
|
|
||||||
#include <gst/gst.h>
|
|
||||||
#include <gst/video/video.h>
|
|
||||||
|
|
||||||
#include <string.h>
|
|
||||||
|
|
||||||
#define GST_TYPE_ALPHA_COLOR \
|
|
||||||
(gst_alpha_color_get_type())
|
|
||||||
#define GST_ALPHA_COLOR(obj) \
|
|
||||||
(G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_ALPHA_COLOR,GstAlphaColor))
|
|
||||||
#define GST_ALPHA_COLOR_CLASS(klass) \
|
|
||||||
(G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_ALPHA_COLOR,GstAlphaColorClass))
|
|
||||||
#define GST_IS_ALPHA_COLOR(obj) \
|
|
||||||
(G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_ALPHA_COLOR))
|
|
||||||
#define GST_IS_ALPHA_COLOR_CLASS(obj) \
|
|
||||||
(G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_ALPHA_COLOR))
|
|
||||||
|
|
||||||
typedef struct _GstAlphaColor GstAlphaColor;
|
|
||||||
typedef struct _GstAlphaColorClass GstAlphaColorClass;
|
|
||||||
|
|
||||||
struct _GstAlphaColor
|
|
||||||
{
|
|
||||||
GstElement element;
|
|
||||||
|
|
||||||
/* pads */
|
|
||||||
GstPad *sinkpad;
|
|
||||||
GstPad *srcpad;
|
|
||||||
|
|
||||||
/* caps */
|
|
||||||
gint in_width, in_height;
|
|
||||||
gboolean in_rgba;
|
|
||||||
gint out_width, out_height;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct _GstAlphaColorClass
|
|
||||||
{
|
|
||||||
GstElementClass parent_class;
|
|
||||||
};
|
|
||||||
|
|
||||||
/* elementfactory information */
|
|
||||||
static GstElementDetails gst_alpha_color_details =
|
|
||||||
GST_ELEMENT_DETAILS ("alpha color filter",
|
|
||||||
"Filter/Effect/Video",
|
|
||||||
"converts rgb to yuv with alpha",
|
|
||||||
"Wim Taymans <wim@fluendo.com>");
|
|
||||||
|
|
||||||
|
|
||||||
/* AlphaColor signals and args */
|
|
||||||
enum
|
|
||||||
{
|
|
||||||
/* FILL ME */
|
|
||||||
LAST_SIGNAL
|
|
||||||
};
|
|
||||||
|
|
||||||
enum
|
|
||||||
{
|
|
||||||
ARG_0,
|
|
||||||
/* FILL ME */
|
|
||||||
};
|
|
||||||
|
|
||||||
static GstStaticPadTemplate gst_alpha_color_sink_template =
|
|
||||||
GST_STATIC_PAD_TEMPLATE ("sink",
|
|
||||||
GST_PAD_SINK,
|
|
||||||
GST_PAD_ALWAYS,
|
|
||||||
GST_STATIC_CAPS (GST_VIDEO_CAPS_RGBA ";" GST_VIDEO_CAPS_BGRA)
|
|
||||||
);
|
|
||||||
|
|
||||||
static GstStaticPadTemplate gst_alpha_color_src_template =
|
|
||||||
GST_STATIC_PAD_TEMPLATE ("src",
|
|
||||||
GST_PAD_SRC,
|
|
||||||
GST_PAD_ALWAYS,
|
|
||||||
GST_STATIC_CAPS (GST_VIDEO_CAPS_YUV ("AYUV"))
|
|
||||||
);
|
|
||||||
|
|
||||||
|
|
||||||
static void gst_alpha_color_base_init (gpointer g_class);
|
|
||||||
static void gst_alpha_color_class_init (GstAlphaColorClass * klass);
|
|
||||||
static void gst_alpha_color_init (GstAlphaColor * alpha);
|
|
||||||
|
|
||||||
static void gst_alpha_color_set_property (GObject * object, guint prop_id,
|
|
||||||
const GValue * value, GParamSpec * pspec);
|
|
||||||
static void gst_alpha_color_get_property (GObject * object, guint prop_id,
|
|
||||||
GValue * value, GParamSpec * pspec);
|
|
||||||
|
|
||||||
static GstPadLinkReturn
|
|
||||||
gst_alpha_color_sink_link (GstPad * pad, const GstCaps * caps);
|
|
||||||
static void gst_alpha_color_chain (GstPad * pad, GstData * _data);
|
|
||||||
|
|
||||||
static GstElementStateReturn gst_alpha_color_change_state (GstElement *
|
|
||||||
element);
|
|
||||||
|
|
||||||
|
|
||||||
static GstElementClass *parent_class = NULL;
|
|
||||||
|
|
||||||
/* static guint gst_alpha_color_signals[LAST_SIGNAL] = { 0 }; */
|
|
||||||
|
|
||||||
GType
|
|
||||||
gst_alpha_color_get_type (void)
|
|
||||||
{
|
|
||||||
static GType alpha_type = 0;
|
|
||||||
|
|
||||||
if (!alpha_type) {
|
|
||||||
static const GTypeInfo alpha_info = {
|
|
||||||
sizeof (GstAlphaColorClass),
|
|
||||||
gst_alpha_color_base_init,
|
|
||||||
NULL,
|
|
||||||
(GClassInitFunc) gst_alpha_color_class_init,
|
|
||||||
NULL,
|
|
||||||
NULL,
|
|
||||||
sizeof (GstAlphaColor),
|
|
||||||
0,
|
|
||||||
(GInstanceInitFunc) gst_alpha_color_init,
|
|
||||||
};
|
|
||||||
|
|
||||||
alpha_type =
|
|
||||||
g_type_register_static (GST_TYPE_ELEMENT, "GstAlphaColor", &alpha_info,
|
|
||||||
0);
|
|
||||||
}
|
|
||||||
return alpha_type;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
gst_alpha_color_base_init (gpointer g_class)
|
|
||||||
{
|
|
||||||
GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
|
|
||||||
|
|
||||||
gst_element_class_set_details (element_class, &gst_alpha_color_details);
|
|
||||||
|
|
||||||
gst_element_class_add_pad_template (element_class,
|
|
||||||
gst_static_pad_template_get (&gst_alpha_color_sink_template));
|
|
||||||
gst_element_class_add_pad_template (element_class,
|
|
||||||
gst_static_pad_template_get (&gst_alpha_color_src_template));
|
|
||||||
}
|
|
||||||
static void
|
|
||||||
gst_alpha_color_class_init (GstAlphaColorClass * klass)
|
|
||||||
{
|
|
||||||
GObjectClass *gobject_class;
|
|
||||||
GstElementClass *gstelement_class;
|
|
||||||
|
|
||||||
gobject_class = (GObjectClass *) klass;
|
|
||||||
gstelement_class = (GstElementClass *) klass;
|
|
||||||
|
|
||||||
parent_class = g_type_class_ref (GST_TYPE_ELEMENT);
|
|
||||||
|
|
||||||
gobject_class->set_property = gst_alpha_color_set_property;
|
|
||||||
gobject_class->get_property = gst_alpha_color_get_property;
|
|
||||||
|
|
||||||
gstelement_class->change_state = gst_alpha_color_change_state;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
gst_alpha_color_init (GstAlphaColor * alpha)
|
|
||||||
{
|
|
||||||
/* create the sink and src pads */
|
|
||||||
alpha->sinkpad =
|
|
||||||
gst_pad_new_from_template (gst_static_pad_template_get
|
|
||||||
(&gst_alpha_color_sink_template), "sink");
|
|
||||||
gst_element_add_pad (GST_ELEMENT (alpha), alpha->sinkpad);
|
|
||||||
gst_pad_set_chain_function (alpha->sinkpad, gst_alpha_color_chain);
|
|
||||||
gst_pad_set_link_function (alpha->sinkpad, gst_alpha_color_sink_link);
|
|
||||||
|
|
||||||
alpha->srcpad =
|
|
||||||
gst_pad_new_from_template (gst_static_pad_template_get
|
|
||||||
(&gst_alpha_color_src_template), "src");
|
|
||||||
gst_element_add_pad (GST_ELEMENT (alpha), alpha->srcpad);
|
|
||||||
|
|
||||||
GST_FLAG_SET (alpha, GST_ELEMENT_EVENT_AWARE);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* do we need this function? */
|
|
||||||
static void
|
|
||||||
gst_alpha_color_set_property (GObject * object, guint prop_id,
|
|
||||||
const GValue * value, GParamSpec * pspec)
|
|
||||||
{
|
|
||||||
GstAlphaColor *alpha;
|
|
||||||
|
|
||||||
/* it's not null if we got it, but it might not be ours */
|
|
||||||
g_return_if_fail (GST_IS_ALPHA_COLOR (object));
|
|
||||||
|
|
||||||
alpha = GST_ALPHA_COLOR (object);
|
|
||||||
|
|
||||||
switch (prop_id) {
|
|
||||||
default:
|
|
||||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
static void
|
|
||||||
gst_alpha_color_get_property (GObject * object, guint prop_id, GValue * value,
|
|
||||||
GParamSpec * pspec)
|
|
||||||
{
|
|
||||||
GstAlphaColor *alpha;
|
|
||||||
|
|
||||||
/* it's not null if we got it, but it might not be ours */
|
|
||||||
g_return_if_fail (GST_IS_ALPHA_COLOR (object));
|
|
||||||
|
|
||||||
alpha = GST_ALPHA_COLOR (object);
|
|
||||||
|
|
||||||
switch (prop_id) {
|
|
||||||
default:
|
|
||||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static GstPadLinkReturn
|
|
||||||
gst_alpha_color_sink_link (GstPad * pad, const GstCaps * caps)
|
|
||||||
{
|
|
||||||
GstAlphaColor *alpha;
|
|
||||||
GstStructure *structure;
|
|
||||||
gboolean ret;
|
|
||||||
gdouble fps;
|
|
||||||
gint red_mask;
|
|
||||||
|
|
||||||
alpha = GST_ALPHA_COLOR (gst_pad_get_parent (pad));
|
|
||||||
structure = gst_caps_get_structure (caps, 0);
|
|
||||||
|
|
||||||
ret = gst_structure_get_int (structure, "width", &alpha->in_width);
|
|
||||||
ret &= gst_structure_get_int (structure, "height", &alpha->in_height);
|
|
||||||
ret &= gst_structure_get_double (structure, "framerate", &fps);
|
|
||||||
ret &= gst_structure_get_int (structure, "red_mask", &red_mask);
|
|
||||||
|
|
||||||
if (!ret)
|
|
||||||
return GST_PAD_LINK_REFUSED;
|
|
||||||
|
|
||||||
alpha->in_rgba = TRUE;
|
|
||||||
#if (G_BYTE_ORDER == G_BIG_ENDIAN)
|
|
||||||
if (red_mask != 0x000000ff)
|
|
||||||
#else
|
|
||||||
if (red_mask != 0x00ff0000)
|
|
||||||
#endif
|
|
||||||
alpha->in_rgba = FALSE;
|
|
||||||
|
|
||||||
caps = gst_caps_new_simple ("video/x-raw-yuv",
|
|
||||||
"format", GST_TYPE_FOURCC, GST_STR_FOURCC ("AYUV"),
|
|
||||||
"framerate", G_TYPE_DOUBLE, fps,
|
|
||||||
"width", G_TYPE_INT, alpha->in_width,
|
|
||||||
"height", G_TYPE_INT, alpha->in_height, NULL);
|
|
||||||
|
|
||||||
return gst_pad_try_set_caps (alpha->srcpad, caps);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
transform_rgb (guint8 * data, gint size)
|
|
||||||
{
|
|
||||||
guint8 y, u, v;
|
|
||||||
|
|
||||||
while (size > 0) {
|
|
||||||
y = data[0] * 0.299 + data[1] * 0.587 + data[2] * 0.114 + 0;
|
|
||||||
u = data[0] * -0.169 + data[1] * -0.332 + data[2] * 0.500 + 128;
|
|
||||||
v = data[0] * 0.500 + data[1] * -0.419 + data[2] * -0.0813 + 128;
|
|
||||||
|
|
||||||
data[0] = data[3];
|
|
||||||
data[1] = y;
|
|
||||||
data[2] = u;
|
|
||||||
data[3] = v;
|
|
||||||
|
|
||||||
data += 4;
|
|
||||||
size -= 4;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
transform_bgr (guint8 * data, gint size)
|
|
||||||
{
|
|
||||||
guint8 y, u, v;
|
|
||||||
|
|
||||||
while (size > 0) {
|
|
||||||
y = data[2] * 0.299 + data[1] * 0.587 + data[0] * 0.114 + 0;
|
|
||||||
u = data[2] * -0.169 + data[1] * -0.332 + data[0] * 0.500 + 128;
|
|
||||||
v = data[2] * 0.500 + data[1] * -0.419 + data[0] * -0.0813 + 128;
|
|
||||||
|
|
||||||
data[0] = data[3];
|
|
||||||
data[1] = y;
|
|
||||||
data[2] = u;
|
|
||||||
data[3] = v;
|
|
||||||
|
|
||||||
data += 4;
|
|
||||||
size -= 4;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
gst_alpha_color_chain (GstPad * pad, GstData * _data)
|
|
||||||
{
|
|
||||||
GstBuffer *buffer;
|
|
||||||
GstAlphaColor *alpha;
|
|
||||||
GstBuffer *outbuf;
|
|
||||||
gint width, height;
|
|
||||||
|
|
||||||
alpha = GST_ALPHA_COLOR (gst_pad_get_parent (pad));
|
|
||||||
|
|
||||||
if (GST_IS_EVENT (_data)) {
|
|
||||||
GstEvent *event = GST_EVENT (_data);
|
|
||||||
|
|
||||||
switch (GST_EVENT_TYPE (event)) {
|
|
||||||
default:
|
|
||||||
gst_pad_event_default (pad, event);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
buffer = GST_BUFFER (_data);
|
|
||||||
|
|
||||||
width = alpha->in_width;
|
|
||||||
height = alpha->in_height;
|
|
||||||
|
|
||||||
outbuf = gst_buffer_copy_on_write (buffer);
|
|
||||||
|
|
||||||
if (alpha->in_rgba)
|
|
||||||
transform_rgb (GST_BUFFER_DATA (outbuf), GST_BUFFER_SIZE (outbuf));
|
|
||||||
else
|
|
||||||
transform_bgr (GST_BUFFER_DATA (outbuf), GST_BUFFER_SIZE (outbuf));
|
|
||||||
|
|
||||||
gst_pad_push (alpha->srcpad, GST_DATA (outbuf));
|
|
||||||
}
|
|
||||||
|
|
||||||
static GstElementStateReturn
|
|
||||||
gst_alpha_color_change_state (GstElement * element)
|
|
||||||
{
|
|
||||||
GstAlphaColor *alpha;
|
|
||||||
|
|
||||||
alpha = GST_ALPHA_COLOR (element);
|
|
||||||
|
|
||||||
switch (GST_STATE_TRANSITION (element)) {
|
|
||||||
case GST_STATE_NULL_TO_READY:
|
|
||||||
break;
|
|
||||||
case GST_STATE_READY_TO_PAUSED:
|
|
||||||
break;
|
|
||||||
case GST_STATE_PAUSED_TO_PLAYING:
|
|
||||||
break;
|
|
||||||
case GST_STATE_PLAYING_TO_PAUSED:
|
|
||||||
break;
|
|
||||||
case GST_STATE_PAUSED_TO_READY:
|
|
||||||
break;
|
|
||||||
case GST_STATE_READY_TO_NULL:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
parent_class->change_state (element);
|
|
||||||
|
|
||||||
return GST_STATE_SUCCESS;
|
|
||||||
}
|
|
||||||
|
|
||||||
static gboolean
|
|
||||||
plugin_init (GstPlugin * plugin)
|
|
||||||
{
|
|
||||||
return gst_element_register (plugin, "alphacolor", GST_RANK_NONE,
|
|
||||||
GST_TYPE_ALPHA_COLOR);
|
|
||||||
}
|
|
||||||
|
|
||||||
GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
|
|
||||||
GST_VERSION_MINOR,
|
|
||||||
"alphacolor",
|
|
||||||
"colorspace conversion preserving the alpha channels",
|
|
||||||
plugin_init, VERSION, GST_LICENSE, GST_PACKAGE, GST_ORIGIN)
|
|
Loading…
Reference in a new issue