gst-plugins-bad: use g_sort_array() instead of deprecated g_qsort_with_data()

Fixes compiler warnings with the latest GLib versions.

See https://gitlab.gnome.org/GNOME/glib/-/merge_requests/4127

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/7384>
This commit is contained in:
Tim-Philipp Müller 2024-08-20 02:01:34 +01:00 committed by GStreamer Marge Bot
parent ec6763b122
commit 59d56bcb3f
7 changed files with 46 additions and 16 deletions

View file

@ -62,6 +62,8 @@
#include "gsth264decoder.h" #include "gsth264decoder.h"
#include "gsth264picture-private.h" #include "gsth264picture-private.h"
#include "gst/glib-compat-private.h"
GST_DEBUG_CATEGORY (gst_h264_decoder_debug); GST_DEBUG_CATEGORY (gst_h264_decoder_debug);
#define GST_CAT_DEFAULT gst_h264_decoder_debug #define GST_CAT_DEFAULT gst_h264_decoder_debug
@ -2664,7 +2666,7 @@ construct_ref_pic_lists_p (GstH264Decoder * self,
pos = priv->ref_pic_list_p0->len; pos = priv->ref_pic_list_p0->len;
gst_h264_dpb_get_pictures_long_term_ref (priv->dpb, gst_h264_dpb_get_pictures_long_term_ref (priv->dpb,
FALSE, priv->ref_pic_list_p0); FALSE, priv->ref_pic_list_p0);
g_qsort_with_data (&g_array_index (priv->ref_pic_list_p0, gpointer, pos), g_sort_array (&g_array_index (priv->ref_pic_list_p0, gpointer, pos),
priv->ref_pic_list_p0->len - pos, sizeof (gpointer), priv->ref_pic_list_p0->len - pos, sizeof (gpointer),
(GCompareDataFunc) long_term_pic_num_asc_compare, NULL); (GCompareDataFunc) long_term_pic_num_asc_compare, NULL);
@ -2913,14 +2915,14 @@ construct_ref_pic_lists_b (GstH264Decoder * self,
GST_DEBUG_OBJECT (self, "split point %i", pos); GST_DEBUG_OBJECT (self, "split point %i", pos);
/* and sort [1] descending, thus finishing sequence [1] [2]. */ /* and sort [1] descending, thus finishing sequence [1] [2]. */
g_qsort_with_data (priv->ref_pic_list_b0->data, pos, sizeof (gpointer), g_sort_array (priv->ref_pic_list_b0->data, pos, sizeof (gpointer),
(GCompareDataFunc) poc_desc_compare, NULL); (GCompareDataFunc) poc_desc_compare, NULL);
/* Now add [3] and sort by ascending long_term_pic_num. */ /* Now add [3] and sort by ascending long_term_pic_num. */
pos = priv->ref_pic_list_b0->len; pos = priv->ref_pic_list_b0->len;
gst_h264_dpb_get_pictures_long_term_ref (priv->dpb, gst_h264_dpb_get_pictures_long_term_ref (priv->dpb,
FALSE, priv->ref_pic_list_b0); FALSE, priv->ref_pic_list_b0);
g_qsort_with_data (&g_array_index (priv->ref_pic_list_b0, gpointer, pos), g_sort_array (&g_array_index (priv->ref_pic_list_b0, gpointer, pos),
priv->ref_pic_list_b0->len - pos, sizeof (gpointer), priv->ref_pic_list_b0->len - pos, sizeof (gpointer),
(GCompareDataFunc) long_term_pic_num_asc_compare, NULL); (GCompareDataFunc) long_term_pic_num_asc_compare, NULL);
@ -2941,14 +2943,14 @@ construct_ref_pic_lists_b (GstH264Decoder * self,
(GCompareFunc) poc_desc_compare); (GCompareFunc) poc_desc_compare);
/* and sort [1] ascending. */ /* and sort [1] ascending. */
g_qsort_with_data (priv->ref_pic_list_b1->data, pos, sizeof (gpointer), g_sort_array (priv->ref_pic_list_b1->data, pos, sizeof (gpointer),
(GCompareDataFunc) poc_asc_compare, NULL); (GCompareDataFunc) poc_asc_compare, NULL);
/* Now add [3] and sort by ascending long_term_pic_num */ /* Now add [3] and sort by ascending long_term_pic_num */
pos = priv->ref_pic_list_b1->len; pos = priv->ref_pic_list_b1->len;
gst_h264_dpb_get_pictures_long_term_ref (priv->dpb, gst_h264_dpb_get_pictures_long_term_ref (priv->dpb,
FALSE, priv->ref_pic_list_b1); FALSE, priv->ref_pic_list_b1);
g_qsort_with_data (&g_array_index (priv->ref_pic_list_b1, gpointer, pos), g_sort_array (&g_array_index (priv->ref_pic_list_b1, gpointer, pos),
priv->ref_pic_list_b1->len - pos, sizeof (gpointer), priv->ref_pic_list_b1->len - pos, sizeof (gpointer),
(GCompareDataFunc) long_term_pic_num_asc_compare, NULL); (GCompareDataFunc) long_term_pic_num_asc_compare, NULL);
@ -3010,7 +3012,7 @@ construct_ref_field_pic_lists_b (GstH264Decoder * self,
GST_DEBUG_OBJECT (self, "split point %i", pos); GST_DEBUG_OBJECT (self, "split point %i", pos);
/* and sort [1] descending, thus finishing sequence [1] [2]. */ /* and sort [1] descending, thus finishing sequence [1] [2]. */
g_qsort_with_data (priv->ref_frame_list_0_short_term->data, pos, g_sort_array (priv->ref_frame_list_0_short_term->data, pos,
sizeof (gpointer), (GCompareDataFunc) poc_desc_compare, NULL); sizeof (gpointer), (GCompareDataFunc) poc_desc_compare, NULL);
/* refFrameList1ShortTerm (8.2.4.2.4) [[1] [2]], where: /* refFrameList1ShortTerm (8.2.4.2.4) [[1] [2]], where:
@ -3031,7 +3033,7 @@ construct_ref_field_pic_lists_b (GstH264Decoder * self,
(GCompareFunc) poc_desc_compare); (GCompareFunc) poc_desc_compare);
/* and sort [1] ascending. */ /* and sort [1] ascending. */
g_qsort_with_data (priv->ref_frame_list_1_short_term->data, pos, g_sort_array (priv->ref_frame_list_1_short_term->data, pos,
sizeof (gpointer), (GCompareDataFunc) poc_asc_compare, NULL); sizeof (gpointer), (GCompareDataFunc) poc_asc_compare, NULL);
/* 8.2.4.2.2 refFrameList0LongTerm,: /* 8.2.4.2.2 refFrameList0LongTerm,:

View file

@ -27,6 +27,26 @@
G_BEGIN_DECLS G_BEGIN_DECLS
#if !GLIB_CHECK_VERSION(2, 81, 1)
#define g_sort_array(a,n,s,f,udata) gst_g_sort_array(a,n,s,f,udata)
// Don't need to maintain ABI compat here (n_elements), since we never pass
// the function as pointer but always call it directly ourselves.
static inline void
gst_g_sort_array (const void *array,
gssize n_elements,
size_t element_size,
GCompareDataFunc compare_func,
void *user_data)
{
if (n_elements >= 0 && n_elements <= G_MAXINT) {
g_qsort_with_data (array, n_elements, element_size, compare_func, user_data);
} else {
g_abort ();
}
}
#endif
G_END_DECLS G_END_DECLS
#endif #endif

View file

@ -58,6 +58,8 @@
#include "gstvadisplay_priv.h" #include "gstvadisplay_priv.h"
#include "gstvapluginutils.h" #include "gstvapluginutils.h"
#include "gst/glib-compat-private.h"
GST_DEBUG_CATEGORY_STATIC (gst_va_av1enc_debug); GST_DEBUG_CATEGORY_STATIC (gst_va_av1enc_debug);
#define GST_CAT_DEFAULT gst_va_av1enc_debug #define GST_CAT_DEFAULT gst_va_av1enc_debug
@ -1489,7 +1491,7 @@ _av1_assign_ref_index (GstVaAV1Enc * self, GstVideoCodecFrame * frame)
return FALSE; return FALSE;
} }
g_qsort_with_data (all_refs, ref_num, sizeof (GstVaAV1Ref), g_sort_array (all_refs, ref_num, sizeof (GstVaAV1Ref),
_av1_sort_by_frame_num, NULL); _av1_sort_by_frame_num, NULL);
/* Assign the forward references in order of: /* Assign the forward references in order of:

View file

@ -68,6 +68,8 @@
#include "vacompat.h" #include "vacompat.h"
#include "gstvapluginutils.h" #include "gstvapluginutils.h"
#include "gst/glib-compat-private.h"
GST_DEBUG_CATEGORY_STATIC (gst_va_h264enc_debug); GST_DEBUG_CATEGORY_STATIC (gst_va_h264enc_debug);
#define GST_CAT_DEFAULT gst_va_h264enc_debug #define GST_CAT_DEFAULT gst_va_h264enc_debug
@ -2647,10 +2649,10 @@ _insert_ref_pic_list_modification (GstH264SliceHdr * slice_hdr,
memcpy (list_by_pic_num, list, sizeof (GstVaH264EncFrame *) * total_list_num); memcpy (list_by_pic_num, list, sizeof (GstVaH264EncFrame *) * total_list_num);
if (is_asc) { if (is_asc) {
g_qsort_with_data (list_by_pic_num, total_list_num, sizeof (gpointer), g_sort_array (list_by_pic_num, total_list_num, sizeof (gpointer),
(GCompareDataFunc) _frame_num_asc_compare, NULL); (GCompareDataFunc) _frame_num_asc_compare, NULL);
} else { } else {
g_qsort_with_data (list_by_pic_num, total_list_num, sizeof (gpointer), g_sort_array (list_by_pic_num, total_list_num, sizeof (gpointer),
(GCompareDataFunc) _frame_num_des_compare, NULL); (GCompareDataFunc) _frame_num_des_compare, NULL);
} }
@ -3051,7 +3053,7 @@ _encode_one_frame (GstVaH264Enc * self, GstVideoCodecFrame * gst_frame)
} }
/* reorder to select the most nearest forward frames. */ /* reorder to select the most nearest forward frames. */
g_qsort_with_data (list0, total_list0_num, sizeof (gpointer), g_sort_array (list0, total_list0_num, sizeof (gpointer),
(GCompareDataFunc) _poc_des_compare, NULL); (GCompareDataFunc) _poc_des_compare, NULL);
list0_num = total_list0_num; list0_num = total_list0_num;
@ -3074,7 +3076,7 @@ _encode_one_frame (GstVaH264Enc * self, GstVideoCodecFrame * gst_frame)
} }
/* reorder to select the most nearest backward frames. */ /* reorder to select the most nearest backward frames. */
g_qsort_with_data (list1, total_list1_num, sizeof (gpointer), g_sort_array (list1, total_list1_num, sizeof (gpointer),
(GCompareDataFunc) _poc_asc_compare, NULL); (GCompareDataFunc) _poc_asc_compare, NULL);
list1_num = total_list1_num; list1_num = total_list1_num;

View file

@ -58,6 +58,8 @@
#include "gstvadisplay_priv.h" #include "gstvadisplay_priv.h"
#include "gstvapluginutils.h" #include "gstvapluginutils.h"
#include "gst/glib-compat-private.h"
GST_DEBUG_CATEGORY_STATIC (gst_va_h265enc_debug); GST_DEBUG_CATEGORY_STATIC (gst_va_h265enc_debug);
#define GST_CAT_DEFAULT gst_va_h265enc_debug #define GST_CAT_DEFAULT gst_va_h265enc_debug
@ -1918,7 +1920,7 @@ _h265_encode_one_frame (GstVaH265Enc * self, GstVideoCodecFrame * gst_frame)
} }
/* reorder to select the most nearest forward frames. */ /* reorder to select the most nearest forward frames. */
g_qsort_with_data (list_forward, list_forward_num, sizeof (gpointer), g_sort_array (list_forward, list_forward_num, sizeof (gpointer),
(GCompareDataFunc) _poc_des_compare, NULL); (GCompareDataFunc) _poc_des_compare, NULL);
num_negative_pics = list_forward_num; num_negative_pics = list_forward_num;
@ -1956,7 +1958,7 @@ _h265_encode_one_frame (GstVaH265Enc * self, GstVideoCodecFrame * gst_frame)
} }
/* reorder to select the most nearest backward frames. */ /* reorder to select the most nearest backward frames. */
g_qsort_with_data (list_backward, list_backward_num, sizeof (gpointer), g_sort_array (list_backward, list_backward_num, sizeof (gpointer),
(GCompareDataFunc) _poc_asc_compare, NULL); (GCompareDataFunc) _poc_asc_compare, NULL);
num_positive_pics = list_backward_num; num_positive_pics = list_backward_num;

View file

@ -59,6 +59,8 @@
#include "gstvadisplay_priv.h" #include "gstvadisplay_priv.h"
#include "gstvapluginutils.h" #include "gstvapluginutils.h"
#include "gst/glib-compat-private.h"
GST_DEBUG_CATEGORY_STATIC (gst_va_vp9enc_debug); GST_DEBUG_CATEGORY_STATIC (gst_va_vp9enc_debug);
#define GST_CAT_DEFAULT gst_va_vp9enc_debug #define GST_CAT_DEFAULT gst_va_vp9enc_debug
@ -1239,7 +1241,7 @@ _vp9_assign_ref_index (GstVaVp9Enc * self, GstVideoCodecFrame * frame)
return FALSE; return FALSE;
} }
g_qsort_with_data (all_refs, ref_num, sizeof (GstVaVp9Ref), g_sort_array (all_refs, ref_num, sizeof (GstVaVp9Ref),
_vp9_sort_by_frame_num, NULL); _vp9_sort_by_frame_num, NULL);
/* Assign the forward references in order of: /* Assign the forward references in order of:

View file

@ -80,7 +80,7 @@ gstva = library('gstva',
va_sources, va_sources,
c_args : gst_plugins_bad_args + extra_args, c_args : gst_plugins_bad_args + extra_args,
cpp_args : gst_plugins_bad_args + extra_args, cpp_args : gst_plugins_bad_args + extra_args,
include_directories : [configinc], include_directories : [configinc, libsinc],
dependencies : [gstcodecs_dep, gstva_dep, libgudev_dep, libm] + extra_dep, dependencies : [gstcodecs_dep, gstva_dep, libgudev_dep, libm] + extra_dep,
override_options : c_std_arg, override_options : c_std_arg,
install : true, install : true,