base: audio: video: Use more efficient caps/structure API in various places

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/7432>
This commit is contained in:
Sebastian Dröge 2024-09-03 13:19:17 +03:00
parent 21af7061eb
commit 275134c883
13 changed files with 147 additions and 131 deletions

View file

@ -1374,7 +1374,7 @@ gst_audio_converter_new (GstAudioConverterFlags flags, GstAudioInfo * in_info,
convert->out = *out_info;
/* default config */
convert->config = gst_structure_new_empty ("GstAudioConverter");
convert->config = gst_structure_new_static_str_empty ("GstAudioConverter");
if (config)
gst_audio_converter_update_config (convert, 0, 0, config);

View file

@ -668,12 +668,12 @@ gst_audio_make_raw_caps (const GstAudioFormat formats[], guint len,
else
layout_str = "non-interleaved";
s = gst_structure_new ("audio/x-raw",
s = gst_structure_new_static_str ("audio/x-raw",
"rate", GST_TYPE_INT_RANGE, 1, G_MAXINT,
"channels", GST_TYPE_INT_RANGE, 1, G_MAXINT,
"layout", G_TYPE_STRING, layout_str, NULL);
gst_structure_take_value (s, "format", &format);
gst_structure_take_value_static_str (s, "format", &format);
caps = gst_caps_new_full (s, NULL);

View file

@ -386,7 +386,7 @@ gst_audio_info_to_caps (const GstAudioInfo * info)
"but no channel positions present");
}
caps = gst_caps_new_simple ("audio/x-raw",
caps = gst_caps_new_simple_static_str ("audio/x-raw",
"format", G_TYPE_STRING, format,
"layout", G_TYPE_STRING, layout,
"rate", G_TYPE_INT, info->rate,
@ -408,8 +408,8 @@ gst_audio_info_to_caps (const GstAudioInfo * info)
&& info->position[0] == GST_AUDIO_CHANNEL_POSITION_MONO) {
/* Default mono special case */
} else {
gst_caps_set_simple (caps, "channel-mask", GST_TYPE_BITMASK, channel_mask,
NULL);
gst_caps_set_simple_static_str (caps, "channel-mask", GST_TYPE_BITMASK,
channel_mask, NULL);
}
}

View file

@ -773,7 +773,8 @@ gst_audio_aggregator_init (GstAudioAggregator * aagg)
aagg->current_caps = NULL;
aagg->priv->selected_samples_info =
gst_structure_new_empty ("GstAudioAggregatorSelectedSamplesInfo");
gst_structure_new_static_str_empty
("GstAudioAggregatorSelectedSamplesInfo");
g_queue_init (&aagg->priv->messages);
}
@ -979,7 +980,7 @@ gst_audio_aggregator_convert_sink_getcaps (GstPad * pad, GstAggregator * agg,
GST_INFO_OBJECT (pad, "first configured pad has sample rate %d",
first_configured_pad->info.rate);
sink_template_caps = gst_caps_make_writable (sink_template_caps);
gst_caps_set_simple (sink_template_caps, "rate", G_TYPE_INT,
gst_caps_set_simple_static_str (sink_template_caps, "rate", G_TYPE_INT,
first_configured_pad->info.rate, NULL);
gst_object_unref (first_configured_pad);
}
@ -1005,9 +1006,9 @@ gst_audio_aggregator_convert_sink_getcaps (GstPad * pad, GstAggregator * agg,
for (i = 0; i < n; i++) {
GstStructure *s = gst_caps_get_structure (tmp, i);
GstStructure *new_s =
gst_structure_new_empty (gst_structure_get_name (s));
gst_structure_set_value (new_s, "rate", gst_structure_get_value (s,
"rate"));
gst_structure_new_id_str_empty (gst_structure_get_name_id_str (s));
gst_structure_set_value_static_str (new_s, "rate",
gst_structure_get_value (s, "rate"));
sink_caps = gst_caps_merge_structure (sink_caps, new_s);
}
gst_caps_unref (tmp);
@ -1069,7 +1070,8 @@ gst_audio_aggregator_sink_setcaps (GstAudioAggregatorPad * aaggpad,
/* Returns NULL if there is no downstream peer */
if (downstream_caps) {
GstCaps *rate_caps =
gst_caps_new_simple ("audio/x-raw", "rate", G_TYPE_INT, info.rate,
gst_caps_new_simple_static_str ("audio/x-raw", "rate", G_TYPE_INT,
info.rate,
NULL);
gst_caps_set_features_simple (rate_caps,
@ -1171,7 +1173,8 @@ gst_audio_aggregator_fixate_src_caps (GstAggregator * agg, GstCaps * caps)
NULL)) {
mask = gst_audio_channel_get_fallback_mask (channels);
}
gst_structure_set (s, "channel-mask", GST_TYPE_BITMASK, mask, NULL);
gst_structure_set_static_str (s, "channel-mask", GST_TYPE_BITMASK, mask,
NULL);
}
gst_caps_unref (first_configured_caps);
@ -1189,7 +1192,8 @@ gst_audio_aggregator_fixate_src_caps (GstAggregator * agg, GstCaps * caps)
if (gst_structure_get_int (s, "channels", &channels) && channels > 2) {
if (!gst_structure_has_field_typed (s, "channel-mask", GST_TYPE_BITMASK))
gst_structure_set (s, "channel-mask", GST_TYPE_BITMASK, 0ULL, NULL);
gst_structure_set_static_str (s, "channel-mask", GST_TYPE_BITMASK, 0ULL,
NULL);
}
}
@ -1791,7 +1795,7 @@ gst_audio_aggregator_post_messages (GstAudioAggregator * aagg)
while ((msg = g_queue_pop_head (&aagg->priv->messages))) {
if (is_live) {
GstStructure *s = gst_message_writable_structure (msg);
gst_structure_set (s, "live", G_TYPE_BOOLEAN, TRUE, NULL);
gst_structure_set_static_str (s, "live", G_TYPE_BOOLEAN, TRUE, NULL);
}
gst_element_post_message (e, msg);
@ -2162,7 +2166,7 @@ gst_audio_aggregator_peek_next_sample (GstAggregator * agg,
aagg->priv->offset + aagg->priv->samples_per_buffer) {
GstCaps *caps = gst_pad_get_current_caps (GST_PAD (aggpad));
GstStructure *info =
gst_structure_new ("GstAudioAggregatorPadNextSampleInfo",
gst_structure_new_static_str ("GstAudioAggregatorPadNextSampleInfo",
"output-offset", G_TYPE_UINT64, pad->priv->output_offset,
"position", G_TYPE_UINT, pad->priv->position,
"size", G_TYPE_UINT, pad->priv->size,
@ -2456,7 +2460,7 @@ gst_audio_aggregator_aggregate (GstAggregator * agg, gboolean timeout)
gst_audio_aggregator_post_messages (aagg);
{
gst_structure_set (aagg->priv->selected_samples_info, "offset",
gst_structure_set_static_str (aagg->priv->selected_samples_info, "offset",
G_TYPE_UINT64, aagg->priv->offset, "frames", G_TYPE_UINT, blocksize,
NULL);
gst_aggregator_selected_samples (agg, agg_segment->position,

View file

@ -800,10 +800,11 @@ static void
if (pad->priv->converter_config) {
conv_config = gst_structure_copy (pad->priv->converter_config);
} else {
conv_config = gst_structure_new_empty ("GstVideoConverterConfig");
conv_config =
gst_structure_new_static_str_empty ("GstVideoConverterConfig");
}
gst_structure_set (conv_config, GST_VIDEO_CONVERTER_OPT_ASYNC_TASKS,
G_TYPE_BOOLEAN, TRUE, NULL);
gst_structure_set_static_str (conv_config,
GST_VIDEO_CONVERTER_OPT_ASYNC_TASKS, G_TYPE_BOOLEAN, TRUE, NULL);
pad->priv->convert =
gst_video_converter_new_with_pool (&vpad->info,
@ -1252,7 +1253,7 @@ gst_video_aggregator_default_update_caps (GstVideoAggregator * vagg,
GST_STR_NULL (chroma_site), GST_STR_NULL (color_name));
best_format_caps = gst_caps_copy (caps);
gst_caps_set_simple (best_format_caps, "format", G_TYPE_STRING,
gst_caps_set_simple_static_str (best_format_caps, "format", G_TYPE_STRING,
gst_video_format_to_string (best_format), NULL);
/*
* set_simple() will likely create some invalid combination, as it may as an
@ -1265,11 +1266,11 @@ gst_video_aggregator_default_update_caps (GstVideoAggregator * vagg,
gst_clear_caps (&ret);
if (chroma_site != NULL)
gst_caps_set_simple (best_format_caps, "chroma-site", G_TYPE_STRING,
chroma_site, NULL);
gst_caps_set_simple_static_str (best_format_caps, "chroma-site",
G_TYPE_STRING, chroma_site, NULL);
if (color_name != NULL)
gst_caps_set_simple (best_format_caps, "colorimetry", G_TYPE_STRING,
color_name, NULL);
gst_caps_set_simple_static_str (best_format_caps, "colorimetry",
G_TYPE_STRING, color_name, NULL);
g_free (color_name);
g_free (chroma_site);
@ -1562,7 +1563,7 @@ _get_non_alpha_caps (GstCaps * caps)
if (has_format) {
s = gst_structure_copy (s);
gst_structure_take_value (s, "format", &new_formats);
gst_structure_take_value_static_str (s, "format", &new_formats);
gst_caps_append_structure_full (result, s,
gst_caps_features_copy (gst_caps_get_features (caps, i)));
}
@ -1603,18 +1604,18 @@ gst_video_aggregator_pad_sink_getcaps (GstPad * pad, GstVideoAggregator * vagg,
n = gst_caps_get_size (srccaps);
for (i = 0; i < n; i++) {
s = gst_caps_get_structure (srccaps, i);
gst_structure_set (s, "framerate", GST_TYPE_FRACTION_RANGE, 0, 1, G_MAXINT,
1, NULL);
gst_structure_set_static_str (s, "framerate", GST_TYPE_FRACTION_RANGE, 0, 1,
G_MAXINT, 1, NULL);
if (GST_IS_VIDEO_AGGREGATOR_CONVERT_PAD (pad)) {
gst_structure_set (s, "width", GST_TYPE_INT_RANGE, 1, G_MAXINT,
gst_structure_set_static_str (s, "width", GST_TYPE_INT_RANGE, 1, G_MAXINT,
"height", GST_TYPE_INT_RANGE, 1, G_MAXINT, NULL);
gst_structure_remove_fields (s, "colorimetry", "chroma-site", "format",
"pixel-aspect-ratio", NULL);
}
if (has_interlace_mode)
gst_structure_set (s, "interlace-mode", G_TYPE_STRING,
gst_structure_set_static_str (s, "interlace-mode", G_TYPE_STRING,
gst_video_interlace_mode_to_string (interlace_mode), NULL);
}
@ -2907,11 +2908,11 @@ gst_video_aggregator_pad_sink_acceptcaps (GstPad * pad,
n = gst_caps_get_size (accepted_caps);
for (i = 0; i < n; i++) {
s = gst_caps_get_structure (accepted_caps, i);
gst_structure_set (s, "framerate", GST_TYPE_FRACTION_RANGE, 0, 1, G_MAXINT,
1, NULL);
gst_structure_set_static_str (s, "framerate", GST_TYPE_FRACTION_RANGE, 0, 1,
G_MAXINT, 1, NULL);
if (GST_IS_VIDEO_AGGREGATOR_CONVERT_PAD (pad)) {
gst_structure_set (s, "width", GST_TYPE_INT_RANGE, 1, G_MAXINT,
gst_structure_set_static_str (s, "width", GST_TYPE_INT_RANGE, 1, G_MAXINT,
"height", GST_TYPE_INT_RANGE, 1, G_MAXINT, NULL);
gst_structure_remove_fields (s, "colorimetry", "chroma-site", "format",
"pixel-aspect-ratio", NULL);

View file

@ -2441,7 +2441,7 @@ gst_video_converter_new_with_pool (const GstVideoInfo * in_info,
convert->out_maxwidth = GST_VIDEO_INFO_WIDTH (out_info);
convert->out_maxheight = GST_VIDEO_INFO_FIELD_HEIGHT (out_info);
convert->config = gst_structure_new_empty ("GstVideoConverter");
convert->config = gst_structure_new_static_str_empty ("GstVideoConverter");
if (config)
gst_video_converter_set_config (convert, config);
else

View file

@ -8686,12 +8686,12 @@ gst_video_make_raw_caps_with_features (const GstVideoFormat formats[],
gst_video_format_to_string (formats[0]));
}
s = gst_structure_new ("video/x-raw",
s = gst_structure_new_static_str ("video/x-raw",
"width", GST_TYPE_INT_RANGE, 1, G_MAXINT,
"height", GST_TYPE_INT_RANGE, 1, G_MAXINT,
"framerate", GST_TYPE_FRACTION_RANGE, 0, 1, G_MAXINT, 1, NULL);
gst_structure_take_value (s, "format", &format);
gst_structure_take_value_static_str (s, "format", &format);
caps = gst_caps_new_full (s, NULL);

View file

@ -678,7 +678,7 @@ gst_video_info_to_caps (const GstVideoInfo * info)
format = gst_video_format_to_string (info->finfo->format);
g_return_val_if_fail (format != NULL, NULL);
caps = gst_caps_new_simple ("video/x-raw",
caps = gst_caps_new_simple_static_str ("video/x-raw",
"format", G_TYPE_STRING, format,
"width", G_TYPE_INT, info->width,
"height", G_TYPE_INT, info->height, NULL);
@ -686,13 +686,13 @@ gst_video_info_to_caps (const GstVideoInfo * info)
par_n = info->par_n;
par_d = info->par_d;
gst_caps_set_simple (caps, "interlace-mode", G_TYPE_STRING,
gst_caps_set_simple_static_str (caps, "interlace-mode", G_TYPE_STRING,
gst_video_interlace_mode_to_string (info->interlace_mode), NULL);
if ((info->interlace_mode == GST_VIDEO_INTERLACE_MODE_INTERLEAVED ||
info->interlace_mode == GST_VIDEO_INTERLACE_MODE_ALTERNATE) &&
GST_VIDEO_INFO_FIELD_ORDER (info) != GST_VIDEO_FIELD_ORDER_UNKNOWN) {
gst_caps_set_simple (caps, "field-order", G_TYPE_STRING,
gst_caps_set_simple_static_str (caps, "field-order", G_TYPE_STRING,
gst_video_field_order_to_string (GST_VIDEO_INFO_FIELD_ORDER (info)),
NULL);
}
@ -738,13 +738,13 @@ gst_video_info_to_caps (const GstVideoInfo * info)
gst_video_multiview_mode_to_caps_string (GST_VIDEO_INFO_MULTIVIEW_MODE
(info));
if (caps_str != NULL) {
gst_caps_set_simple (caps, "multiview-mode", G_TYPE_STRING,
gst_caps_set_simple_static_str (caps, "multiview-mode", G_TYPE_STRING,
caps_str, "multiview-flags", GST_TYPE_VIDEO_MULTIVIEW_FLAGSET,
multiview_flags, GST_FLAG_SET_MASK_EXACT, NULL);
}
}
gst_caps_set_simple (caps, "pixel-aspect-ratio",
gst_caps_set_simple_static_str (caps, "pixel-aspect-ratio",
GST_TYPE_FRACTION, par_n, par_d, NULL);
if (info->chroma_site != GST_VIDEO_CHROMA_SITE_UNKNOWN) {
@ -754,7 +754,7 @@ gst_video_info_to_caps (const GstVideoInfo * info)
GST_WARNING ("Couldn't convert chroma-site 0x%x to string",
info->chroma_site);
} else {
gst_caps_set_simple (caps,
gst_caps_set_simple_static_str (caps,
"chroma-site", G_TYPE_STRING, chroma_site, NULL);
g_free (chroma_site);
}
@ -769,20 +769,22 @@ gst_video_info_to_caps (const GstVideoInfo * info)
colorimetry.matrix = GST_VIDEO_COLOR_MATRIX_RGB;
}
if ((color = gst_video_colorimetry_to_string (&colorimetry))) {
gst_caps_set_simple (caps, "colorimetry", G_TYPE_STRING, color, NULL);
gst_caps_set_simple_static_str (caps, "colorimetry", G_TYPE_STRING, color,
NULL);
g_free (color);
}
if (info->views > 1)
gst_caps_set_simple (caps, "views", G_TYPE_INT, info->views, NULL);
gst_caps_set_simple_static_str (caps, "views", G_TYPE_INT, info->views,
NULL);
if (info->flags & GST_VIDEO_FLAG_VARIABLE_FPS && info->fps_n != 0) {
/* variable fps with a max-framerate */
gst_caps_set_simple (caps, "framerate", GST_TYPE_FRACTION, 0, 1,
gst_caps_set_simple_static_str (caps, "framerate", GST_TYPE_FRACTION, 0, 1,
"max-framerate", GST_TYPE_FRACTION, info->fps_n, info->fps_d, NULL);
} else {
/* no variable fps or no max-framerate */
gst_caps_set_simple (caps, "framerate", GST_TYPE_FRACTION,
gst_caps_set_simple_static_str (caps, "framerate", GST_TYPE_FRACTION,
info->fps_n, info->fps_d, NULL);
}

View file

@ -1136,7 +1136,8 @@ add_other_channels_to_structure (GstCapsFeatures * features, GstStructure * s,
{
gint other_channels = GPOINTER_TO_INT (user_data);
gst_structure_set (s, "channels", G_TYPE_INT, other_channels, NULL);
gst_structure_set_static_str (s, "channels", G_TYPE_INT, other_channels,
NULL);
return TRUE;
}
@ -1334,7 +1335,7 @@ gst_audio_convert_fixate_format (GstBaseTransform * base, GstStructure * ins,
}
if (out_info)
gst_structure_set (outs, "format", G_TYPE_STRING,
gst_structure_set_static_str (outs, "format", G_TYPE_STRING,
GST_AUDIO_FORMAT_INFO_NAME (out_info), NULL);
}
@ -1376,8 +1377,8 @@ gst_audio_convert_fixate_channels (GstBaseTransform * base, GstStructure * ins,
GST_AUDIO_CHANNEL_POSITION_MASK (FRONT_LEFT) |
GST_AUDIO_CHANNEL_POSITION_MASK (FRONT_RIGHT);
has_out_mask = TRUE;
gst_structure_set (outs, "channel-mask", GST_TYPE_BITMASK, out_mask,
NULL);
gst_structure_set_static_str (outs, "channel-mask", GST_TYPE_BITMASK,
out_mask, NULL);
}
}
@ -1405,7 +1406,8 @@ gst_audio_convert_fixate_channels (GstBaseTransform * base, GstStructure * ins,
/* same number of channels and no output layout: just use input layout */
if (!has_out_mask) {
/* in_chans == 1 handled above already */
gst_structure_set (outs, "channel-mask", GST_TYPE_BITMASK, in_mask, NULL);
gst_structure_set_static_str (outs, "channel-mask", GST_TYPE_BITMASK,
in_mask, NULL);
return;
}
@ -1428,8 +1430,8 @@ gst_audio_convert_fixate_channels (GstBaseTransform * base, GstStructure * ins,
* the input layout */
intersection = in_mask & out_mask;
if (n_bits_set (intersection) >= in_chans) {
gst_structure_set (outs, "channel-mask", GST_TYPE_BITMASK, in_mask,
NULL);
gst_structure_set_static_str (outs, "channel-mask", GST_TYPE_BITMASK,
in_mask, NULL);
return;
}
@ -1437,8 +1439,8 @@ gst_audio_convert_fixate_channels (GstBaseTransform * base, GstStructure * ins,
* just pick the first possibility */
intersection = find_suitable_mask (out_mask, out_chans);
if (intersection) {
gst_structure_set (outs, "channel-mask", GST_TYPE_BITMASK, intersection,
NULL);
gst_structure_set_static_str (outs, "channel-mask", GST_TYPE_BITMASK,
intersection, NULL);
return;
}
}
@ -1456,8 +1458,8 @@ gst_audio_convert_fixate_channels (GstBaseTransform * base, GstStructure * ins,
* if the first one is something unexpected or non-channel-pos-array-y */
if (n_bits_set (out_mask) >= out_chans) {
intersection = find_suitable_mask (out_mask, out_chans);
gst_structure_set (outs, "channel-mask", GST_TYPE_BITMASK, intersection,
NULL);
gst_structure_set_static_str (outs, "channel-mask", GST_TYPE_BITMASK,
intersection, NULL);
return;
}
@ -1473,11 +1475,12 @@ gst_audio_convert_fixate_channels (GstBaseTransform * base, GstStructure * ins,
if (out_chans > 1
&& (out_mask = gst_audio_channel_get_fallback_mask (out_chans))) {
GST_DEBUG_OBJECT (base, "using default channel layout as fallback");
gst_structure_set (outs, "channel-mask", GST_TYPE_BITMASK, out_mask, NULL);
gst_structure_set_static_str (outs, "channel-mask", GST_TYPE_BITMASK,
out_mask, NULL);
} else if (out_chans > 1) {
GST_ERROR_OBJECT (base, "Have no default layout for %d channels",
out_chans);
gst_structure_set (outs, "channel-mask", GST_TYPE_BITMASK,
gst_structure_set_static_str (outs, "channel-mask", GST_TYPE_BITMASK,
G_GUINT64_CONSTANT (0), NULL);
}
}
@ -1556,7 +1559,7 @@ gst_audio_convert_ensure_converter (GstBaseTransform * base,
goto done;
}
config = gst_structure_new ("GstAudioConverterConfig",
config = gst_structure_new_static_str ("GstAudioConverterConfig",
GST_AUDIO_CONVERTER_OPT_DITHER_METHOD, GST_TYPE_AUDIO_DITHER_METHOD,
this->dither,
GST_AUDIO_CONVERTER_OPT_DITHER_THRESHOLD, G_TYPE_UINT,
@ -1565,8 +1568,8 @@ gst_audio_convert_ensure_converter (GstBaseTransform * base,
GST_TYPE_AUDIO_NOISE_SHAPING_METHOD, this->ns, NULL);
if (this->mix_matrix_is_set) {
gst_structure_set_value (config, GST_AUDIO_CONVERTER_OPT_MIX_MATRIX,
&this->mix_matrix);
gst_structure_set_value_static_str (config,
GST_AUDIO_CONVERTER_OPT_MIX_MATRIX, &this->mix_matrix);
this->convert = gst_audio_converter_new (0, in_info, out_info, config);
} else if (this->input_channels_reorder_mode !=

View file

@ -189,9 +189,10 @@ __set_channels (GstCaps * caps, gint channels)
for (i = 0; i < size; i++) {
s = gst_caps_get_structure (caps, i);
if (channels > 0)
gst_structure_set (s, "channels", G_TYPE_INT, channels, NULL);
gst_structure_set_static_str (s, "channels", G_TYPE_INT, channels, NULL);
else
gst_structure_set (s, "channels", GST_TYPE_INT_RANGE, 1, G_MAXINT, NULL);
gst_structure_set_static_str (s, "channels", GST_TYPE_INT_RANGE, 1,
G_MAXINT, NULL);
}
}
@ -524,8 +525,8 @@ gst_audio_interleave_update_src_caps (GstAggregator * agg, GstCaps * caps,
*ret = gst_caps_copy (self->sinkcaps);
s = gst_caps_get_structure (*ret, 0);
gst_structure_set (s, "channels", G_TYPE_INT, self->channels, "layout",
G_TYPE_STRING, "interleaved", "channel-mask", GST_TYPE_BITMASK,
gst_structure_set_static_str (s, "channels", G_TYPE_INT, self->channels,
"layout", G_TYPE_STRING, "interleaved", "channel-mask", GST_TYPE_BITMASK,
gst_audio_interleave_get_channel_mask (self), NULL);
GST_OBJECT_UNLOCK (self);

View file

@ -327,11 +327,13 @@ gst_audio_resample_transform_caps (GstBaseTransform * base,
val = gst_structure_get_value (s, "rate");
if (val == NULL || GST_VALUE_HOLDS_INT_RANGE (val)) {
/* overwrite existing range, or add field if it doesn't exist yet */
gst_structure_set (s, "rate", GST_TYPE_INT_RANGE, 1, G_MAXINT, NULL);
gst_structure_set_static_str (s, "rate", GST_TYPE_INT_RANGE, 1, G_MAXINT,
NULL);
} else {
/* append caps with full range to existing caps with non-range rate field */
gst_caps_append_structure (res, gst_structure_copy (s));
gst_structure_set (s, "rate", GST_TYPE_INT_RANGE, 1, G_MAXINT, NULL);
gst_structure_set_static_str (s, "rate", GST_TYPE_INT_RANGE, 1, G_MAXINT,
NULL);
}
gst_caps_append_structure (res, s);
}
@ -374,12 +376,12 @@ make_options (GstAudioResample * resample, GstAudioInfo * in,
{
GstStructure *options;
options = gst_structure_new_empty ("resampler-options");
options = gst_structure_new_static_str_empty ("resampler-options");
if (in != NULL && out != NULL)
gst_audio_resampler_options_set_quality (resample->method,
resample->quality, in->rate, out->rate, options);
gst_structure_set (options,
gst_structure_set_static_str (options,
GST_AUDIO_CONVERTER_OPT_RESAMPLER_METHOD, GST_TYPE_AUDIO_RESAMPLER_METHOD,
resample->method,
GST_AUDIO_RESAMPLER_OPT_FILTER_MODE, GST_TYPE_AUDIO_RESAMPLER_FILTER_MODE,

View file

@ -1467,8 +1467,8 @@ _negotiated_caps (GstAggregator * agg, GstCaps * caps)
GstTaskPool *pool = gst_video_aggregator_get_execution_task_pool (vagg);
if (pool && n_threads > 1) {
config = gst_structure_new_empty ("GstVideoConverterConfig");
gst_structure_set (config, GST_VIDEO_CONVERTER_OPT_THREADS,
config = gst_structure_new_static_str_empty ("GstVideoConverterConfig");
gst_structure_set_static_str (config, GST_VIDEO_CONVERTER_OPT_THREADS,
G_TYPE_UINT, n_threads, NULL);
}
@ -1848,7 +1848,7 @@ src_pad_mouse_event (GstElement * element, GstPad * pad, gpointer user_data)
x = (event_x - (gdouble) rect.x) * (w / (gdouble) rect.w);
y = (event_y - (gdouble) rect.y) * (h / (gdouble) rect.h);
gst_structure_set (st, "pointer_x", G_TYPE_DOUBLE, x,
gst_structure_set_static_str (st, "pointer_x", G_TYPE_DOUBLE, x,
"pointer_y", G_TYPE_DOUBLE, y, NULL);
gst_pad_push_event (pad, gst_event_new_navigation (st));
} else {

View file

@ -642,11 +642,11 @@ gst_video_convert_caps_remove_format_and_rangify_size_info (GstVideoConvertScale
|| gst_caps_features_is_equal (features,
features_format_interlaced_sysmem))) {
if (klass->scales) {
gst_structure_set (structure, "width", GST_TYPE_INT_RANGE, 1, G_MAXINT,
"height", GST_TYPE_INT_RANGE, 1, G_MAXINT, NULL);
gst_structure_set_static_str (structure, "width", GST_TYPE_INT_RANGE, 1,
G_MAXINT, "height", GST_TYPE_INT_RANGE, 1, G_MAXINT, NULL);
/* if pixel aspect ratio, make a range of it */
if (gst_structure_has_field (structure, "pixel-aspect-ratio")) {
gst_structure_set (structure, "pixel-aspect-ratio",
gst_structure_set_static_str (structure, "pixel-aspect-ratio",
GST_TYPE_FRACTION_RANGE, 1, G_MAXINT, G_MAXINT, 1, NULL);
}
}
@ -841,47 +841,47 @@ gst_video_convert_scale_set_info (GstVideoFilter * filter, GstCaps * in,
GST_CAT_DEBUG_OBJECT (CAT_PERFORMANCE, filter, "setup videoscaling");
gst_base_transform_set_passthrough (GST_BASE_TRANSFORM (filter), FALSE);
options = gst_structure_new_empty ("videoconvertscale");
options = gst_structure_new_static_str_empty ("videoconvertscale");
switch (priv->method) {
case GST_VIDEO_SCALE_NEAREST:
gst_structure_set (options,
gst_structure_set_static_str (options,
GST_VIDEO_CONVERTER_OPT_RESAMPLER_METHOD,
GST_TYPE_VIDEO_RESAMPLER_METHOD, GST_VIDEO_RESAMPLER_METHOD_NEAREST,
NULL);
break;
case GST_VIDEO_SCALE_BILINEAR:
gst_structure_set (options,
gst_structure_set_static_str (options,
GST_VIDEO_CONVERTER_OPT_RESAMPLER_METHOD,
GST_TYPE_VIDEO_RESAMPLER_METHOD, GST_VIDEO_RESAMPLER_METHOD_LINEAR,
GST_VIDEO_RESAMPLER_OPT_MAX_TAPS, G_TYPE_INT, 2, NULL);
break;
case GST_VIDEO_SCALE_4TAP:
gst_structure_set (options,
gst_structure_set_static_str (options,
GST_VIDEO_CONVERTER_OPT_RESAMPLER_METHOD,
GST_TYPE_VIDEO_RESAMPLER_METHOD, GST_VIDEO_RESAMPLER_METHOD_SINC,
GST_VIDEO_RESAMPLER_OPT_MAX_TAPS, G_TYPE_INT, 4, NULL);
break;
case GST_VIDEO_SCALE_LANCZOS:
gst_structure_set (options,
gst_structure_set_static_str (options,
GST_VIDEO_CONVERTER_OPT_RESAMPLER_METHOD,
GST_TYPE_VIDEO_RESAMPLER_METHOD, GST_VIDEO_RESAMPLER_METHOD_LANCZOS,
NULL);
break;
case GST_VIDEO_SCALE_BILINEAR2:
gst_structure_set (options,
gst_structure_set_static_str (options,
GST_VIDEO_CONVERTER_OPT_RESAMPLER_METHOD,
GST_TYPE_VIDEO_RESAMPLER_METHOD, GST_VIDEO_RESAMPLER_METHOD_LINEAR,
NULL);
break;
case GST_VIDEO_SCALE_SINC:
gst_structure_set (options,
gst_structure_set_static_str (options,
GST_VIDEO_CONVERTER_OPT_RESAMPLER_METHOD,
GST_TYPE_VIDEO_RESAMPLER_METHOD, GST_VIDEO_RESAMPLER_METHOD_SINC,
NULL);
break;
case GST_VIDEO_SCALE_HERMITE:
gst_structure_set (options,
gst_structure_set_static_str (options,
GST_VIDEO_CONVERTER_OPT_RESAMPLER_METHOD,
GST_TYPE_VIDEO_RESAMPLER_METHOD, GST_VIDEO_RESAMPLER_METHOD_CUBIC,
GST_VIDEO_RESAMPLER_OPT_CUBIC_B, G_TYPE_DOUBLE, (gdouble) 0.0,
@ -889,7 +889,7 @@ gst_video_convert_scale_set_info (GstVideoFilter * filter, GstCaps * in,
NULL);
break;
case GST_VIDEO_SCALE_SPLINE:
gst_structure_set (options,
gst_structure_set_static_str (options,
GST_VIDEO_CONVERTER_OPT_RESAMPLER_METHOD,
GST_TYPE_VIDEO_RESAMPLER_METHOD, GST_VIDEO_RESAMPLER_METHOD_CUBIC,
GST_VIDEO_RESAMPLER_OPT_CUBIC_B, G_TYPE_DOUBLE, (gdouble) 1.0,
@ -897,7 +897,7 @@ gst_video_convert_scale_set_info (GstVideoFilter * filter, GstCaps * in,
NULL);
break;
case GST_VIDEO_SCALE_CATROM:
gst_structure_set (options,
gst_structure_set_static_str (options,
GST_VIDEO_CONVERTER_OPT_RESAMPLER_METHOD,
GST_TYPE_VIDEO_RESAMPLER_METHOD, GST_VIDEO_RESAMPLER_METHOD_CUBIC,
GST_VIDEO_RESAMPLER_OPT_CUBIC_B, G_TYPE_DOUBLE, (gdouble) 0.0,
@ -905,7 +905,7 @@ gst_video_convert_scale_set_info (GstVideoFilter * filter, GstCaps * in,
NULL);
break;
case GST_VIDEO_SCALE_MITCHELL:
gst_structure_set (options,
gst_structure_set_static_str (options,
GST_VIDEO_CONVERTER_OPT_RESAMPLER_METHOD,
GST_TYPE_VIDEO_RESAMPLER_METHOD, GST_VIDEO_RESAMPLER_METHOD_CUBIC,
GST_VIDEO_RESAMPLER_OPT_CUBIC_B, G_TYPE_DOUBLE, (gdouble) 1.0 / 3.0,
@ -913,7 +913,7 @@ gst_video_convert_scale_set_info (GstVideoFilter * filter, GstCaps * in,
NULL);
break;
}
gst_structure_set (options,
gst_structure_set_static_str (options,
GST_VIDEO_RESAMPLER_OPT_ENVELOPE, G_TYPE_DOUBLE, priv->envelope,
GST_VIDEO_RESAMPLER_OPT_SHARPNESS, G_TYPE_DOUBLE, priv->sharpness,
GST_VIDEO_RESAMPLER_OPT_SHARPEN, G_TYPE_DOUBLE, priv->sharpen,
@ -1152,7 +1152,7 @@ gst_video_convert_scale_fixate_format (GstBaseTransform * base, GstCaps * caps,
}
}
if (out_info)
gst_structure_set (outs, "format", G_TYPE_STRING,
gst_structure_set_static_str (outs, "format", G_TYPE_STRING,
GST_VIDEO_FORMAT_INFO_NAME (out_info), NULL);
}
@ -1216,10 +1216,10 @@ transfer_colorimetry_from_input (GstBaseTransform * trans, GstCaps * in_caps,
tmp_caps = gst_caps_fixate (tmp_caps);
tmp_caps_s = gst_caps_get_structure (tmp_caps, 0);
if (!gst_structure_has_field (tmp_caps_s, "width"))
gst_structure_set_value (tmp_caps_s, "width",
gst_structure_set_value_static_str (tmp_caps_s, "width",
gst_structure_get_value (in_caps_s, "width"));
if (!gst_structure_has_field (tmp_caps_s, "height"))
gst_structure_set_value (tmp_caps_s, "height",
gst_structure_set_value_static_str (tmp_caps_s, "height",
gst_structure_get_value (in_caps_s, "height"));
if (!gst_video_info_from_caps (&out_info, tmp_caps)) {
@ -1238,7 +1238,8 @@ transfer_colorimetry_from_input (GstBaseTransform * trans, GstCaps * in_caps,
|| (GST_VIDEO_INFO_IS_GRAY (&out_info)
&& GST_VIDEO_INFO_IS_GRAY (&in_info))) {
/* Can transfer the colorimetry intact from the input if it has it */
gst_structure_set_value (out_caps_s, "colorimetry", in_colorimetry);
gst_structure_set_value_static_str (out_caps_s, "colorimetry",
in_colorimetry);
} else {
gchar *colorimetry_str;
@ -1252,7 +1253,7 @@ transfer_colorimetry_from_input (GstBaseTransform * trans, GstCaps * in_caps,
colorimetry_str =
gst_video_colorimetry_to_string (&out_info.colorimetry);
gst_caps_set_simple (out_caps, "colorimetry", G_TYPE_STRING,
gst_caps_set_simple_static_str (out_caps, "colorimetry", G_TYPE_STRING,
colorimetry_str, NULL);
g_free (colorimetry_str);
}
@ -1267,7 +1268,8 @@ transfer_colorimetry_from_input (GstBaseTransform * trans, GstCaps * in_caps,
gst_structure_get_value (in_caps_s, "chroma-site");
if (in_chroma_site != NULL
&& subsampling_unchanged (&in_info, &out_info))
gst_structure_set_value (out_caps_s, "chroma-site", in_chroma_site);
gst_structure_set_value_static_str (out_caps_s, "chroma-site",
in_chroma_site);
}
}
}
@ -1342,8 +1344,8 @@ gst_video_convert_scale_fixate_size (GstBaseTransform * base,
gst_value_set_fraction (&tpar, 1, 1);
to_par = &tpar;
gst_structure_set (outs, "pixel-aspect-ratio", GST_TYPE_FRACTION, 1, 1,
NULL);
gst_structure_set_static_str (outs, "pixel-aspect-ratio",
GST_TYPE_FRACTION, 1, 1, NULL);
}
if (!from_par) {
g_value_init (&fpar, GST_TYPE_FRACTION);
@ -1386,8 +1388,8 @@ gst_video_convert_scale_fixate_size (GstBaseTransform * base,
gst_structure_fixate_field_nearest_fraction (outs,
"pixel-aspect-ratio", n, d);
else if (n != d)
gst_structure_set (outs, "pixel-aspect-ratio", GST_TYPE_FRACTION,
n, d, NULL);
gst_structure_set_static_str (outs, "pixel-aspect-ratio",
GST_TYPE_FRACTION, n, d, NULL);
}
}
goto done;
@ -1454,7 +1456,7 @@ gst_video_convert_scale_fixate_size (GstBaseTransform * base,
}
if (!gst_structure_has_field (tmp, "pixel-aspect-ratio"))
gst_structure_set_value (tmp, "pixel-aspect-ratio", to_par);
gst_structure_set_value_static_str (tmp, "pixel-aspect-ratio", to_par);
gst_structure_fixate_field_nearest_fraction (tmp, "pixel-aspect-ratio",
to_par_n, to_par_d);
gst_structure_get_fraction (tmp, "pixel-aspect-ratio", &set_par_n,
@ -1465,7 +1467,7 @@ gst_video_convert_scale_fixate_size (GstBaseTransform * base,
if (set_par_n == to_par_n && set_par_d == to_par_d) {
if (gst_structure_has_field (outs, "pixel-aspect-ratio") ||
set_par_n != set_par_d)
gst_structure_set (outs, "width", G_TYPE_INT, set_w,
gst_structure_set_static_str (outs, "width", G_TYPE_INT, set_w,
"pixel-aspect-ratio", GST_TYPE_FRACTION, set_par_n, set_par_d,
NULL);
goto done;
@ -1485,8 +1487,8 @@ gst_video_convert_scale_fixate_size (GstBaseTransform * base,
gst_structure_fixate_field_nearest_int (outs, "width", w);
if (gst_structure_has_field (outs, "pixel-aspect-ratio") ||
set_par_n != set_par_d)
gst_structure_set (outs, "pixel-aspect-ratio", GST_TYPE_FRACTION,
set_par_n, set_par_d, NULL);
gst_structure_set_static_str (outs, "pixel-aspect-ratio",
GST_TYPE_FRACTION, set_par_n, set_par_d, NULL);
goto done;
} else if (w) {
@ -1535,7 +1537,7 @@ gst_video_convert_scale_fixate_size (GstBaseTransform * base,
goto done;
}
if (!gst_structure_has_field (tmp, "pixel-aspect-ratio"))
gst_structure_set_value (tmp, "pixel-aspect-ratio", to_par);
gst_structure_set_value_static_str (tmp, "pixel-aspect-ratio", to_par);
gst_structure_fixate_field_nearest_fraction (tmp, "pixel-aspect-ratio",
to_par_n, to_par_d);
gst_structure_get_fraction (tmp, "pixel-aspect-ratio", &set_par_n,
@ -1546,7 +1548,7 @@ gst_video_convert_scale_fixate_size (GstBaseTransform * base,
if (set_par_n == to_par_n && set_par_d == to_par_d) {
if (gst_structure_has_field (outs, "pixel-aspect-ratio") ||
set_par_n != set_par_d)
gst_structure_set (outs, "height", G_TYPE_INT, set_h,
gst_structure_set_static_str (outs, "height", G_TYPE_INT, set_h,
"pixel-aspect-ratio", GST_TYPE_FRACTION, set_par_n, set_par_d,
NULL);
goto done;
@ -1566,8 +1568,8 @@ gst_video_convert_scale_fixate_size (GstBaseTransform * base,
gst_structure_fixate_field_nearest_int (outs, "height", h);
if (gst_structure_has_field (outs, "pixel-aspect-ratio") ||
set_par_n != set_par_d)
gst_structure_set (outs, "pixel-aspect-ratio", GST_TYPE_FRACTION,
set_par_n, set_par_d, NULL);
gst_structure_set_static_str (outs, "pixel-aspect-ratio",
GST_TYPE_FRACTION, set_par_n, set_par_d, NULL);
goto done;
} else if (gst_value_is_fixed (to_par)) {
@ -1599,8 +1601,8 @@ gst_video_convert_scale_fixate_size (GstBaseTransform * base,
/* We kept the DAR and the height is nearest to the original height */
if (set_w == w) {
gst_structure_set (outs, "width", G_TYPE_INT, set_w, "height",
G_TYPE_INT, set_h, NULL);
gst_structure_set_static_str (outs, "width", G_TYPE_INT, set_w,
"height", G_TYPE_INT, set_h, NULL);
goto done;
}
@ -1621,8 +1623,8 @@ gst_video_convert_scale_fixate_size (GstBaseTransform * base,
/* We kept the DAR and the width is nearest to the original width */
if (set_h == h) {
gst_structure_set (outs, "width", G_TYPE_INT, set_w, "height",
G_TYPE_INT, set_h, NULL);
gst_structure_set_static_str (outs, "width", G_TYPE_INT, set_w,
"height", G_TYPE_INT, set_h, NULL);
goto done;
}
@ -1634,8 +1636,8 @@ gst_video_convert_scale_fixate_size (GstBaseTransform * base,
f_h = set_h;
f_w = set_w;
}
gst_structure_set (outs, "width", G_TYPE_INT, f_w, "height", G_TYPE_INT,
f_h, NULL);
gst_structure_set_static_str (outs, "width", G_TYPE_INT, f_w, "height",
G_TYPE_INT, f_h, NULL);
goto done;
} else {
GstStructure *tmp;
@ -1660,7 +1662,7 @@ gst_video_convert_scale_fixate_size (GstBaseTransform * base,
}
if (!gst_structure_has_field (tmp, "pixel-aspect-ratio"))
gst_structure_set_value (tmp, "pixel-aspect-ratio", to_par);
gst_structure_set_value_static_str (tmp, "pixel-aspect-ratio", to_par);
gst_structure_fixate_field_nearest_fraction (tmp, "pixel-aspect-ratio",
to_par_n, to_par_d);
gst_structure_get_fraction (tmp, "pixel-aspect-ratio", &set_par_n,
@ -1668,13 +1670,13 @@ gst_video_convert_scale_fixate_size (GstBaseTransform * base,
gst_structure_free (tmp);
if (set_par_n == to_par_n && set_par_d == to_par_d) {
gst_structure_set (outs, "width", G_TYPE_INT, set_w, "height",
G_TYPE_INT, set_h, NULL);
gst_structure_set_static_str (outs, "width", G_TYPE_INT, set_w,
"height", G_TYPE_INT, set_h, NULL);
if (gst_structure_has_field (outs, "pixel-aspect-ratio") ||
set_par_n != set_par_d)
gst_structure_set (outs, "pixel-aspect-ratio", GST_TYPE_FRACTION,
set_par_n, set_par_d, NULL);
gst_structure_set_static_str (outs, "pixel-aspect-ratio",
GST_TYPE_FRACTION, set_par_n, set_par_d, NULL);
goto done;
}
@ -1694,12 +1696,12 @@ gst_video_convert_scale_fixate_size (GstBaseTransform * base,
gst_structure_free (tmp);
if (tmp2 == w) {
gst_structure_set (outs, "width", G_TYPE_INT, tmp2, "height",
gst_structure_set_static_str (outs, "width", G_TYPE_INT, tmp2, "height",
G_TYPE_INT, set_h, NULL);
if (gst_structure_has_field (outs, "pixel-aspect-ratio") ||
set_par_n != set_par_d)
gst_structure_set (outs, "pixel-aspect-ratio", GST_TYPE_FRACTION,
set_par_n, set_par_d, NULL);
gst_structure_set_static_str (outs, "pixel-aspect-ratio",
GST_TYPE_FRACTION, set_par_n, set_par_d, NULL);
goto done;
}
@ -1711,23 +1713,23 @@ gst_video_convert_scale_fixate_size (GstBaseTransform * base,
gst_structure_free (tmp);
if (tmp2 == h) {
gst_structure_set (outs, "width", G_TYPE_INT, set_w, "height",
G_TYPE_INT, tmp2, NULL);
if (gst_structure_has_field (outs, "pixel-aspect-ratio") ||
set_par_n != set_par_d)
gst_structure_set (outs, "pixel-aspect-ratio", GST_TYPE_FRACTION,
set_par_n, set_par_d, NULL);
gst_structure_set_static_str (outs, "width", G_TYPE_INT, set_w,
"height", G_TYPE_INT, tmp2, NULL);
if (gst_structure_has_field (outs, "pixel-aspect-ratio")
|| set_par_n != set_par_d)
gst_structure_set_static_str (outs, "pixel-aspect-ratio",
GST_TYPE_FRACTION, set_par_n, set_par_d, NULL);
goto done;
}
/* If all fails we can't keep the DAR and take the nearest values
* for everything from the first try */
gst_structure_set (outs, "width", G_TYPE_INT, set_w, "height",
gst_structure_set_static_str (outs, "width", G_TYPE_INT, set_w, "height",
G_TYPE_INT, set_h, NULL);
if (gst_structure_has_field (outs, "pixel-aspect-ratio") ||
set_par_n != set_par_d)
gst_structure_set (outs, "pixel-aspect-ratio", GST_TYPE_FRACTION,
set_par_n, set_par_d, NULL);
gst_structure_set_static_str (outs, "pixel-aspect-ratio",
GST_TYPE_FRACTION, set_par_n, set_par_d, NULL);
}
}
@ -1775,8 +1777,9 @@ gst_video_convert_scale_fixate_caps (GstBaseTransform * base,
for (i = 0; i < G_N_ELEMENTS (format_fields); i++) {
if (gst_structure_has_field (format_struct, format_fields[i])) {
gst_structure_set (fixated_struct, format_fields[i], G_TYPE_STRING,
gst_structure_get_string (format_struct, format_fields[i]), NULL);
gst_structure_set_static_str (fixated_struct, format_fields[i],
G_TYPE_STRING, gst_structure_get_string (format_struct,
format_fields[i]), NULL);
} else {
gst_structure_remove_field (fixated_struct, format_fields[i]);
}