mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-18 22:36:33 +00:00
videoconvert: add dither-bits option
Fix the dither option. Add a new option to set the quantizer
This commit is contained in:
parent
fc1d24ec45
commit
991a81bd5d
2 changed files with 23 additions and 3 deletions
|
@ -56,10 +56,14 @@ static GQuark _colorspace_quark;
|
||||||
#define gst_video_convert_parent_class parent_class
|
#define gst_video_convert_parent_class parent_class
|
||||||
G_DEFINE_TYPE (GstVideoConvert, gst_video_convert, GST_TYPE_VIDEO_FILTER);
|
G_DEFINE_TYPE (GstVideoConvert, gst_video_convert, GST_TYPE_VIDEO_FILTER);
|
||||||
|
|
||||||
|
#define DEFAULT_PROP_DITHER GST_VIDEO_DITHER_BAYER
|
||||||
|
#define DEFAULT_PROP_DITHER_QUANTIZATION 1
|
||||||
|
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
PROP_0,
|
PROP_0,
|
||||||
PROP_DITHER
|
PROP_DITHER,
|
||||||
|
PROP_DITHER_QUANTIZATION
|
||||||
};
|
};
|
||||||
|
|
||||||
#define CSP_VIDEO_CAPS GST_VIDEO_CAPS_MAKE (GST_VIDEO_FORMATS_ALL) ";" \
|
#define CSP_VIDEO_CAPS GST_VIDEO_CAPS_MAKE (GST_VIDEO_FORMATS_ALL) ";" \
|
||||||
|
@ -421,7 +425,10 @@ gst_video_convert_set_info (GstVideoFilter * filter,
|
||||||
|
|
||||||
space->convert = gst_video_converter_new (in_info, out_info,
|
space->convert = gst_video_converter_new (in_info, out_info,
|
||||||
gst_structure_new ("GstVideoConvertConfig",
|
gst_structure_new ("GstVideoConvertConfig",
|
||||||
"dither", GST_TYPE_VIDEO_DITHER_METHOD, space->dither, NULL));
|
GST_VIDEO_CONVERTER_OPT_DITHER_METHOD, GST_TYPE_VIDEO_DITHER_METHOD,
|
||||||
|
space->dither,
|
||||||
|
GST_VIDEO_CONVERTER_OPT_DITHER_QUANTIZATION, G_TYPE_UINT,
|
||||||
|
space->dither_quantization, NULL));
|
||||||
if (space->convert == NULL)
|
if (space->convert == NULL)
|
||||||
goto no_convert;
|
goto no_convert;
|
||||||
|
|
||||||
|
@ -496,13 +503,19 @@ gst_video_convert_class_init (GstVideoConvertClass * klass)
|
||||||
|
|
||||||
g_object_class_install_property (gobject_class, PROP_DITHER,
|
g_object_class_install_property (gobject_class, PROP_DITHER,
|
||||||
g_param_spec_enum ("dither", "Dither", "Apply dithering while converting",
|
g_param_spec_enum ("dither", "Dither", "Apply dithering while converting",
|
||||||
gst_video_dither_method_get_type (), 0,
|
gst_video_dither_method_get_type (), DEFAULT_PROP_DITHER,
|
||||||
|
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
|
||||||
|
g_object_class_install_property (gobject_class, PROP_DITHER_QUANTIZATION,
|
||||||
|
g_param_spec_uint ("dither-quantization", "Dither Quantize",
|
||||||
|
"Quantizer to use", 0, G_MAXUINT, DEFAULT_PROP_DITHER_QUANTIZATION,
|
||||||
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
|
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gst_video_convert_init (GstVideoConvert * space)
|
gst_video_convert_init (GstVideoConvert * space)
|
||||||
{
|
{
|
||||||
|
space->dither = DEFAULT_PROP_DITHER;
|
||||||
|
space->dither_quantization = DEFAULT_PROP_DITHER_QUANTIZATION;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -517,6 +530,9 @@ gst_video_convert_set_property (GObject * object, guint property_id,
|
||||||
case PROP_DITHER:
|
case PROP_DITHER:
|
||||||
csp->dither = g_value_get_enum (value);
|
csp->dither = g_value_get_enum (value);
|
||||||
break;
|
break;
|
||||||
|
case PROP_DITHER_QUANTIZATION:
|
||||||
|
csp->dither_quantization = g_value_get_uint (value);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
||||||
break;
|
break;
|
||||||
|
@ -535,6 +551,9 @@ gst_video_convert_get_property (GObject * object, guint property_id,
|
||||||
case PROP_DITHER:
|
case PROP_DITHER:
|
||||||
g_value_set_enum (value, csp->dither);
|
g_value_set_enum (value, csp->dither);
|
||||||
break;
|
break;
|
||||||
|
case PROP_DITHER_QUANTIZATION:
|
||||||
|
g_value_set_uint (value, csp->dither_quantization);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -48,6 +48,7 @@ struct _GstVideoConvert {
|
||||||
|
|
||||||
GstVideoConverter *convert;
|
GstVideoConverter *convert;
|
||||||
GstVideoDitherMethod dither;
|
GstVideoDitherMethod dither;
|
||||||
|
guint dither_quantization;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct _GstVideoConvertClass
|
struct _GstVideoConvertClass
|
||||||
|
|
Loading…
Reference in a new issue