mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-02-01 20:12:28 +00:00
libs: encoder: h264: Use gst_param_spec_array for view-ids
GValueArray is deprecated. Use GstValueArray instead. gst_param_spec_array can be deserialized from command line using: vaapih264enc view-ids="<(uint)40,(uint)100>" num-views=2 While the g_param_spec_value_array() can not, and always get error: "gst_value_deserialize_g_value_array: unimplemented" Also fixed an out-of-range bug.
This commit is contained in:
parent
6669a7fc57
commit
6404bd399d
1 changed files with 43 additions and 20 deletions
|
@ -21,9 +21,6 @@
|
|||
* Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
/* GValueArray has deprecated without providing an alternative in glib >= 2.32
|
||||
* See https://bugzilla.gnome.org/show_bug.cgi?id=667228
|
||||
*/
|
||||
#define GLIB_DISABLE_DEPRECATION_WARNINGS
|
||||
|
||||
#include "sysdeps.h"
|
||||
|
@ -3440,6 +3437,46 @@ gst_vaapi_encoder_h264_finalize (GstVaapiEncoder * base_encoder)
|
|||
}
|
||||
}
|
||||
|
||||
static void
|
||||
set_view_ids (GstVaapiEncoderH264 * const encoder, const GValue * value)
|
||||
{
|
||||
guint i, j;
|
||||
gboolean use_default = TRUE;
|
||||
guint len = gst_value_array_get_size (value);
|
||||
|
||||
/* Try the user set view IDs */
|
||||
if (len > 0) {
|
||||
if (len != encoder->num_views) {
|
||||
GST_WARNING ("The view number is %d, but %d view IDs are provided. Just "
|
||||
"fallback to use default view IDs.", encoder->num_views, len);
|
||||
goto set_default_ids;
|
||||
}
|
||||
|
||||
for (i = 0; i < len; i++) {
|
||||
const GValue *val = gst_value_array_get_value (value, i);
|
||||
encoder->view_ids[i] = g_value_get_uint (val);
|
||||
}
|
||||
|
||||
/* check whether duplicated ID */
|
||||
for (i = 0; i < len; i++) {
|
||||
for (j = i + 1; j < len; j++) {
|
||||
if (encoder->view_ids[i] == encoder->view_ids[j]) {
|
||||
GST_WARNING ("The view %d and view %d have same view ID %d. Just "
|
||||
"fallback to use default view IDs.", i, j, encoder->view_ids[i]);
|
||||
goto set_default_ids;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
use_default = FALSE;
|
||||
}
|
||||
|
||||
set_default_ids:
|
||||
if (use_default)
|
||||
for (i = 0; i < encoder->num_views; i++)
|
||||
encoder->view_ids[i] = i;
|
||||
}
|
||||
|
||||
static GstVaapiEncoderStatus
|
||||
gst_vaapi_encoder_h264_set_property (GstVaapiEncoder * base_encoder,
|
||||
gint prop_id, const GValue * value)
|
||||
|
@ -3477,23 +3514,9 @@ gst_vaapi_encoder_h264_set_property (GstVaapiEncoder * base_encoder,
|
|||
case GST_VAAPI_ENCODER_H264_PROP_NUM_VIEWS:
|
||||
encoder->num_views = g_value_get_uint (value);
|
||||
break;
|
||||
case GST_VAAPI_ENCODER_H264_PROP_VIEW_IDS:{
|
||||
guint i;
|
||||
GValueArray *view_ids = g_value_get_boxed (value);
|
||||
|
||||
if (view_ids == NULL) {
|
||||
for (i = 0; i < MAX_NUM_VIEWS; i++)
|
||||
encoder->view_ids[i] = i;
|
||||
} else {
|
||||
g_assert (view_ids->n_values <= encoder->num_views);
|
||||
|
||||
for (i = 0; i < encoder->num_views; i++) {
|
||||
GValue *val = g_value_array_get_nth (view_ids, i);
|
||||
encoder->view_ids[i] = g_value_get_uint (val);
|
||||
}
|
||||
}
|
||||
case GST_VAAPI_ENCODER_H264_PROP_VIEW_IDS:
|
||||
set_view_ids (encoder, value);
|
||||
break;
|
||||
}
|
||||
case GST_VAAPI_ENCODER_H264_PROP_AUD:
|
||||
encoder->use_aud = g_value_get_boolean (value);
|
||||
break;
|
||||
|
@ -3752,7 +3775,7 @@ gst_vaapi_encoder_h264_get_default_properties (void)
|
|||
*/
|
||||
GST_VAAPI_ENCODER_PROPERTIES_APPEND (props,
|
||||
GST_VAAPI_ENCODER_H264_PROP_VIEW_IDS,
|
||||
g_param_spec_value_array ("view-ids",
|
||||
gst_param_spec_array ("view-ids",
|
||||
"View IDs", "Set of View Ids used for MVC encoding",
|
||||
g_param_spec_uint ("view-id-value", "View id value",
|
||||
"view id values used for mvc encoding", 0, MAX_VIEW_ID, 0,
|
||||
|
|
Loading…
Reference in a new issue