+/**
+ * This function compares two 64 bits integers.
+ * It can be used by qsort.
+ */
+static int IntegerCmp( int64_t i0, int64_t i1 )
+{
+ return i0 < i1 ? -1 : i0 > i1 ? 1 : 0;
+}
+/**
+ * This function compares 2 subpictures using the following properties
+ * (ordered by priority)
+ * 1. absolute positionning
+ * 2. start time
+ * 3. creation order
+ *
+ * It can be used by qsort.
+ *
+ * XXX spu_RenderSubpictures depends heavily on this order.
+ */
+static int SubpictureCmp( const void *s0, const void *s1 )
+{
+ subpicture_t *p_subpic0 = *(subpicture_t**)s0;
+ subpicture_t *p_subpic1 = *(subpicture_t**)s1;
+ int r;
+
+ r = IntegerCmp( !p_subpic0->b_absolute, !p_subpic1->b_absolute );
+ if( !r )
+ r = IntegerCmp( p_subpic0->i_start, p_subpic1->i_start );
+ if( !r )
+ r = IntegerCmp( p_subpic0->i_order, p_subpic1->i_order );
+ return r;
+}