mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-14 05:12:09 +00:00
webpenc: add animation properties
- animation background color - number of animation loops Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/5994>
This commit is contained in:
parent
05bd35f625
commit
eb416d5077
3 changed files with 100 additions and 0 deletions
|
@ -243627,6 +243627,46 @@
|
|||
}
|
||||
},
|
||||
"properties": {
|
||||
"animated": {
|
||||
"blurb": "Encode an animated webp, instead of several pictures",
|
||||
"conditionally-available": false,
|
||||
"construct": false,
|
||||
"construct-only": false,
|
||||
"controllable": false,
|
||||
"default": "false",
|
||||
"mutable": "null",
|
||||
"readable": true,
|
||||
"type": "gboolean",
|
||||
"writable": true
|
||||
},
|
||||
"animation-background-color": {
|
||||
"blurb": "The animation background color in ARGB order (1 byte per component).",
|
||||
"conditionally-available": false,
|
||||
"construct": false,
|
||||
"construct-only": false,
|
||||
"controllable": false,
|
||||
"default": "0",
|
||||
"max": "-1",
|
||||
"min": "0",
|
||||
"mutable": "null",
|
||||
"readable": true,
|
||||
"type": "guint",
|
||||
"writable": true
|
||||
},
|
||||
"animation-loops": {
|
||||
"blurb": "The number of animation loops for the animated mode. If set to 0, the animation will loop forever.",
|
||||
"conditionally-available": false,
|
||||
"construct": false,
|
||||
"construct-only": false,
|
||||
"controllable": false,
|
||||
"default": "0",
|
||||
"max": "-1",
|
||||
"min": "0",
|
||||
"mutable": "null",
|
||||
"readable": true,
|
||||
"type": "guint",
|
||||
"writable": true
|
||||
},
|
||||
"lossless": {
|
||||
"blurb": "Enable lossless encoding",
|
||||
"conditionally-available": false,
|
||||
|
|
|
@ -38,6 +38,8 @@ enum
|
|||
PROP_SPEED,
|
||||
PROP_PRESET,
|
||||
PROP_ANIMATED,
|
||||
PROP_ANIMATION_LOOPS,
|
||||
PROP_ANIMATION_BACKGROUND_COLOR
|
||||
};
|
||||
|
||||
#define DEFAULT_LOSSLESS FALSE
|
||||
|
@ -45,6 +47,8 @@ enum
|
|||
#define DEFAULT_SPEED 4
|
||||
#define DEFAULT_PRESET WEBP_PRESET_PHOTO
|
||||
#define DEFAULT_ANIMATED FALSE
|
||||
#define DEFAULT_ANIMATION_LOOPS 0
|
||||
#define DEFAULT_ANIMATION_BACKGROUND_COLOR 0
|
||||
|
||||
static void gst_webp_enc_set_property (GObject * object, guint prop_id,
|
||||
const GValue * value, GParamSpec * pspec);
|
||||
|
@ -159,11 +163,48 @@ gst_webp_enc_class_init (GstWebpEncClass * klass)
|
|||
"Preset name for visual tuning",
|
||||
GST_WEBP_ENC_PRESET_TYPE, DEFAULT_PRESET,
|
||||
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
|
||||
|
||||
/**
|
||||
* GstWebpEnc:animated:
|
||||
*
|
||||
* Encode an animated webp, instead of several pictures.
|
||||
*
|
||||
* Since: 1.24
|
||||
*/
|
||||
g_object_class_install_property (gobject_class, PROP_ANIMATED,
|
||||
g_param_spec_boolean ("animated", "Animated",
|
||||
"Encode an animated webp, instead of several pictures",
|
||||
DEFAULT_ANIMATED, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
|
||||
|
||||
/**
|
||||
* GstWebpEnc:animation-loops:
|
||||
*
|
||||
* The number of animation loops for the animated mode.
|
||||
* If set to 0, the animation will loop forever.
|
||||
*
|
||||
* Since: 1.24
|
||||
*/
|
||||
g_object_class_install_property (gobject_class, PROP_ANIMATION_LOOPS,
|
||||
g_param_spec_uint ("animation-loops", "Animation Loops",
|
||||
"The number of animation loops for the animated mode. "
|
||||
"If set to 0, the animation will loop forever.", 0, G_MAXUINT,
|
||||
DEFAULT_ANIMATION_LOOPS, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
|
||||
|
||||
/**
|
||||
* GstWebpEnc:animation-background-color:
|
||||
*
|
||||
* The animation background color in ARGB order (1 byte per component).
|
||||
*
|
||||
* Since: 1.24
|
||||
*/
|
||||
g_object_class_install_property (gobject_class,
|
||||
PROP_ANIMATION_BACKGROUND_COLOR,
|
||||
g_param_spec_uint ("animation-background-color",
|
||||
"Animation Background Color",
|
||||
"The animation background color in ARGB order (1 byte per component).",
|
||||
0, G_MAXUINT32, DEFAULT_ANIMATION_BACKGROUND_COLOR,
|
||||
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
|
||||
|
||||
GST_DEBUG_CATEGORY_INIT (webpenc_debug, "webpenc", 0,
|
||||
"WEBP encoding element");
|
||||
|
||||
|
@ -180,6 +221,8 @@ gst_webp_enc_init (GstWebpEnc * webpenc)
|
|||
webpenc->speed = DEFAULT_SPEED;
|
||||
webpenc->preset = DEFAULT_PRESET;
|
||||
webpenc->animated = DEFAULT_ANIMATED;
|
||||
webpenc->animation_loops = DEFAULT_ANIMATION_LOOPS;
|
||||
webpenc->animation_background_color = DEFAULT_ANIMATION_BACKGROUND_COLOR;
|
||||
|
||||
webpenc->use_argb = FALSE;
|
||||
webpenc->rgb_format = GST_VIDEO_FORMAT_UNKNOWN;
|
||||
|
@ -240,6 +283,9 @@ gst_webp_enc_set_format (GstVideoEncoder * encoder, GstVideoCodecState * state)
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
enc_options.anim_params.bgcolor = enc->animation_background_color;
|
||||
enc_options.anim_params.loop_count = enc->animation_loops;
|
||||
|
||||
enc->anim_enc = WebPAnimEncoderNew (width, height, &enc_options);
|
||||
if (!enc->anim_enc) {
|
||||
GST_ERROR_OBJECT (enc, "Failed to create the animation encoder");
|
||||
|
@ -396,6 +442,12 @@ gst_webp_enc_set_property (GObject * object, guint prop_id,
|
|||
case PROP_ANIMATED:
|
||||
webpenc->animated = g_value_get_boolean (value);
|
||||
break;
|
||||
case PROP_ANIMATION_LOOPS:
|
||||
webpenc->animation_loops = g_value_get_uint (value);
|
||||
break;
|
||||
case PROP_ANIMATION_BACKGROUND_COLOR:
|
||||
webpenc->animation_background_color = g_value_get_uint (value);
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
break;
|
||||
|
@ -424,6 +476,12 @@ gst_webp_enc_get_property (GObject * object, guint prop_id, GValue * value,
|
|||
case PROP_ANIMATED:
|
||||
g_value_set_boolean (value, webpenc->animated);
|
||||
break;
|
||||
case PROP_ANIMATION_LOOPS:
|
||||
g_value_set_uint (value, webpenc->animation_loops);
|
||||
break;
|
||||
case PROP_ANIMATION_BACKGROUND_COLOR:
|
||||
g_value_set_uint (value, webpenc->animation_background_color);
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
break;
|
||||
|
|
|
@ -56,6 +56,8 @@ struct _GstWebpEnc
|
|||
guint speed;
|
||||
gint preset;
|
||||
gboolean animated;
|
||||
guint animation_loops;
|
||||
guint32 animation_background_color;
|
||||
|
||||
gboolean use_argb;
|
||||
GstVideoFormat rgb_format;
|
||||
|
|
Loading…
Reference in a new issue