gamma: Some random cleanup
This commit is contained in:
parent
ecb0c3a932
commit
2a3f99ca5f
@ -57,13 +57,7 @@
|
|||||||
GST_DEBUG_CATEGORY_STATIC (gamma_debug);
|
GST_DEBUG_CATEGORY_STATIC (gamma_debug);
|
||||||
#define GST_CAT_DEFAULT gamma_debug
|
#define GST_CAT_DEFAULT gamma_debug
|
||||||
|
|
||||||
/* GstGamma signals and args */
|
/* GstGamma properties */
|
||||||
enum
|
|
||||||
{
|
|
||||||
/* FILL ME */
|
|
||||||
LAST_SIGNAL
|
|
||||||
};
|
|
||||||
|
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
PROP_0,
|
PROP_0,
|
||||||
@ -102,7 +96,6 @@ static void gst_gamma_calculate_tables (GstGamma * gamma);
|
|||||||
|
|
||||||
GST_BOILERPLATE (GstGamma, gst_gamma, GstVideoFilter, GST_TYPE_VIDEO_FILTER);
|
GST_BOILERPLATE (GstGamma, gst_gamma, GstVideoFilter, GST_TYPE_VIDEO_FILTER);
|
||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gst_gamma_base_init (gpointer g_class)
|
gst_gamma_base_init (gpointer g_class)
|
||||||
{
|
{
|
||||||
@ -121,18 +114,16 @@ gst_gamma_base_init (gpointer g_class)
|
|||||||
static void
|
static void
|
||||||
gst_gamma_class_init (GstGammaClass * g_class)
|
gst_gamma_class_init (GstGammaClass * g_class)
|
||||||
{
|
{
|
||||||
GObjectClass *gobject_class;
|
GObjectClass *gobject_class = (GObjectClass *) g_class;
|
||||||
GstBaseTransformClass *trans_class;
|
GstBaseTransformClass *trans_class = (GstBaseTransformClass *) g_class;
|
||||||
|
|
||||||
gobject_class = G_OBJECT_CLASS (g_class);
|
|
||||||
trans_class = GST_BASE_TRANSFORM_CLASS (g_class);
|
|
||||||
|
|
||||||
gobject_class->set_property = gst_gamma_set_property;
|
gobject_class->set_property = gst_gamma_set_property;
|
||||||
gobject_class->get_property = gst_gamma_get_property;
|
gobject_class->get_property = gst_gamma_get_property;
|
||||||
|
|
||||||
g_object_class_install_property (gobject_class, PROP_GAMMA,
|
g_object_class_install_property (gobject_class, PROP_GAMMA,
|
||||||
g_param_spec_double ("gamma", "Gamma", "gamma",
|
g_param_spec_double ("gamma", "Gamma", "gamma",
|
||||||
0.01, 10, DEFAULT_PROP_GAMMA, G_PARAM_READWRITE));
|
0.01, 10, DEFAULT_PROP_GAMMA,
|
||||||
|
G_PARAM_STATIC_STRINGS | G_PARAM_READWRITE));
|
||||||
|
|
||||||
trans_class->set_caps = GST_DEBUG_FUNCPTR (gst_gamma_set_caps);
|
trans_class->set_caps = GST_DEBUG_FUNCPTR (gst_gamma_set_caps);
|
||||||
trans_class->transform_ip = GST_DEBUG_FUNCPTR (gst_gamma_transform_ip);
|
trans_class->transform_ip = GST_DEBUG_FUNCPTR (gst_gamma_transform_ip);
|
||||||
@ -141,8 +132,6 @@ gst_gamma_class_init (GstGammaClass * g_class)
|
|||||||
static void
|
static void
|
||||||
gst_gamma_init (GstGamma * gamma, GstGammaClass * g_class)
|
gst_gamma_init (GstGamma * gamma, GstGammaClass * g_class)
|
||||||
{
|
{
|
||||||
GST_DEBUG_OBJECT (gamma, "gst_gamma_init");
|
|
||||||
|
|
||||||
/* properties */
|
/* properties */
|
||||||
gamma->gamma = DEFAULT_PROP_GAMMA;
|
gamma->gamma = DEFAULT_PROP_GAMMA;
|
||||||
gst_gamma_calculate_tables (gamma);
|
gst_gamma_calculate_tables (gamma);
|
||||||
@ -152,17 +141,18 @@ static void
|
|||||||
gst_gamma_set_property (GObject * object, guint prop_id, const GValue * value,
|
gst_gamma_set_property (GObject * object, guint prop_id, const GValue * value,
|
||||||
GParamSpec * pspec)
|
GParamSpec * pspec)
|
||||||
{
|
{
|
||||||
GstGamma *gamma;
|
GstGamma *gamma = GST_GAMMA (object);
|
||||||
|
|
||||||
g_return_if_fail (GST_IS_GAMMA (object));
|
|
||||||
gamma = GST_GAMMA (object);
|
|
||||||
|
|
||||||
GST_DEBUG ("gst_gamma_set_property");
|
|
||||||
switch (prop_id) {
|
switch (prop_id) {
|
||||||
case PROP_GAMMA:
|
case PROP_GAMMA:{
|
||||||
gamma->gamma = g_value_get_double (value);
|
gdouble val = g_value_get_double (value);
|
||||||
|
|
||||||
|
GST_DEBUG_OBJECT (gamma, "Changing gamma from %lf to %lf", gamma->gamma,
|
||||||
|
val);
|
||||||
|
gamma->gamma = val;
|
||||||
gst_gamma_calculate_tables (gamma);
|
gst_gamma_calculate_tables (gamma);
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
default:
|
default:
|
||||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||||
break;
|
break;
|
||||||
@ -173,10 +163,7 @@ static void
|
|||||||
gst_gamma_get_property (GObject * object, guint prop_id, GValue * value,
|
gst_gamma_get_property (GObject * object, guint prop_id, GValue * value,
|
||||||
GParamSpec * pspec)
|
GParamSpec * pspec)
|
||||||
{
|
{
|
||||||
GstGamma *gamma;
|
GstGamma *gamma = GST_GAMMA (object);
|
||||||
|
|
||||||
g_return_if_fail (GST_IS_GAMMA (object));
|
|
||||||
gamma = GST_GAMMA (object);
|
|
||||||
|
|
||||||
switch (prop_id) {
|
switch (prop_id) {
|
||||||
case PROP_GAMMA:
|
case PROP_GAMMA:
|
||||||
@ -191,9 +178,9 @@ gst_gamma_get_property (GObject * object, guint prop_id, GValue * value,
|
|||||||
static void
|
static void
|
||||||
gst_gamma_calculate_tables (GstGamma * gamma)
|
gst_gamma_calculate_tables (GstGamma * gamma)
|
||||||
{
|
{
|
||||||
int n;
|
gint n;
|
||||||
double val;
|
gdouble val;
|
||||||
double exp;
|
gdouble exp;
|
||||||
|
|
||||||
if (gamma->gamma == 1.0) {
|
if (gamma->gamma == 1.0) {
|
||||||
GST_BASE_TRANSFORM (gamma)->passthrough = TRUE;
|
GST_BASE_TRANSFORM (gamma)->passthrough = TRUE;
|
||||||
@ -206,16 +193,16 @@ gst_gamma_calculate_tables (GstGamma * gamma)
|
|||||||
val = n / 255.0;
|
val = n / 255.0;
|
||||||
val = pow (val, exp);
|
val = pow (val, exp);
|
||||||
val = 255.0 * val;
|
val = 255.0 * val;
|
||||||
gamma->gamma_table[n] = (unsigned char) floor (val + 0.5);
|
gamma->gamma_table[n] = (guint8) floor (val + 0.5);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef HAVE_LIBOIL
|
#ifndef HAVE_LIBOIL
|
||||||
static void
|
static void
|
||||||
oil_tablelookup_u8 (guint8 * dest, int dstr, guint8 * src, int sstr,
|
oil_tablelookup_u8 (guint8 * dest, gint dstr, const guint8 * src, gint sstr,
|
||||||
guint8 * table, int tstr, int n)
|
const guint8 * table, gint tstr, gint n)
|
||||||
{
|
{
|
||||||
int i;
|
gint i;
|
||||||
|
|
||||||
for (i = 0; i < n; i++) {
|
for (i = 0; i < n; i++) {
|
||||||
*dest = table[*src * tstr];
|
*dest = table[*src * tstr];
|
||||||
@ -239,23 +226,22 @@ static gboolean
|
|||||||
gst_gamma_set_caps (GstBaseTransform * base, GstCaps * incaps,
|
gst_gamma_set_caps (GstBaseTransform * base, GstCaps * incaps,
|
||||||
GstCaps * outcaps)
|
GstCaps * outcaps)
|
||||||
{
|
{
|
||||||
GstGamma *this;
|
GstGamma *gamma = GST_GAMMA (base);
|
||||||
GstStructure *structure;
|
GstStructure *structure;
|
||||||
gboolean res;
|
gboolean res;
|
||||||
|
|
||||||
this = GST_GAMMA (base);
|
GST_DEBUG_OBJECT (gamma,
|
||||||
|
"setting caps: in %" GST_PTR_FORMAT " out %" GST_PTR_FORMAT, incaps,
|
||||||
GST_DEBUG_OBJECT (this,
|
outcaps);
|
||||||
"set_caps: in %" GST_PTR_FORMAT " out %" GST_PTR_FORMAT, incaps, outcaps);
|
|
||||||
|
|
||||||
structure = gst_caps_get_structure (incaps, 0);
|
structure = gst_caps_get_structure (incaps, 0);
|
||||||
|
|
||||||
res = gst_structure_get_int (structure, "width", &this->width);
|
res = gst_structure_get_int (structure, "width", &gamma->width);
|
||||||
res &= gst_structure_get_int (structure, "height", &this->height);
|
res &= gst_structure_get_int (structure, "height", &gamma->height);
|
||||||
if (!res)
|
if (!res)
|
||||||
goto done;
|
goto done;
|
||||||
|
|
||||||
this->size = GST_VIDEO_I420_SIZE (this->width, this->height);
|
gamma->size = GST_VIDEO_I420_SIZE (gamma->width, gamma->height);
|
||||||
|
|
||||||
done:
|
done:
|
||||||
return res;
|
return res;
|
||||||
@ -270,12 +256,10 @@ gst_gamma_planar411_ip (GstGamma * gamma, guint8 * data, gint size)
|
|||||||
static GstFlowReturn
|
static GstFlowReturn
|
||||||
gst_gamma_transform_ip (GstBaseTransform * base, GstBuffer * outbuf)
|
gst_gamma_transform_ip (GstBaseTransform * base, GstBuffer * outbuf)
|
||||||
{
|
{
|
||||||
GstGamma *gamma;
|
GstGamma *gamma = GST_GAMMA (base);
|
||||||
guint8 *data;
|
guint8 *data;
|
||||||
guint size;
|
guint size;
|
||||||
|
|
||||||
gamma = GST_GAMMA (base);
|
|
||||||
|
|
||||||
if (base->passthrough)
|
if (base->passthrough)
|
||||||
goto done;
|
goto done;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user