tsmux: Remove program_array_index
authorJan Alexander Steffens (heftig) <jan.steffens@ltnglobal.com>
Mon, 10 Jan 2022 12:03:11 +0000 (13:03 +0100)
committerGStreamer Marge Bot <gitlab-merge-bot@gstreamer-foundation.org>
Mon, 24 Jan 2022 15:37:46 +0000 (15:37 +0000)
It's only used for removal. Let's just scan the array.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/1510>

subprojects/gst-plugins-bad/gst/mpegtsmux/tsmux/tsmux.c
subprojects/gst-plugins-bad/gst/mpegtsmux/tsmux/tsmuxstream.c
subprojects/gst-plugins-bad/gst/mpegtsmux/tsmux/tsmuxstream.h

index 629717c..a3161c9 100644 (file)
@@ -612,8 +612,6 @@ tsmux_program_add_stream (TsMuxProgram * program, TsMuxStream * stream)
   g_return_if_fail (program != NULL);
   g_return_if_fail (stream != NULL);
 
-  stream->program_array_index = program->streams->len;
-
   g_ptr_array_add (program->streams, stream);
   program->pmt_changed = TRUE;
 }
@@ -746,21 +744,10 @@ static gboolean
 tsmux_program_remove_stream (TsMuxProgram * program, TsMuxStream * stream)
 {
   GPtrArray *streams = program->streams;
-  TsMuxStream *s;
-  gint i;
-
-  i = stream->program_array_index;
-  g_return_val_if_fail (i >= 0, FALSE);
-
-  s = g_ptr_array_index (streams, i);
-  g_return_val_if_fail (s == stream, FALSE);
 
-  g_ptr_array_remove_index (streams, i);
-
-  /* Correct indices of remaining streams, if any */
-  for (; i < streams->len; i++) {
-    s = g_ptr_array_index (streams, i);
-    s->program_array_index -= 1;
+  if (!g_ptr_array_remove (streams, stream)) {
+    g_warn_if_reached ();
+    return FALSE;
   }
 
   return streams->len == 0;
index 87ec8b7..151ad83 100644 (file)
@@ -117,7 +117,6 @@ tsmux_stream_new (guint16 pid, guint stream_type)
   stream->pes_payload_size = 0;
   stream->cur_pes_payload_size = 0;
   stream->pes_bytes_written = 0;
-  stream->program_array_index = -1;
 
   switch (stream_type) {
     case TSMUX_ST_VIDEO_MPEG1:
index 7a9bd94..6bdcde8 100644 (file)
@@ -150,8 +150,6 @@ struct TsMuxStream {
   guint8 id;
   /* extended stream id (13818-1 Amdt 2) */
   guint8 id_extended;
-  /* array index in program array */
-  gint program_array_index;
 
   gboolean is_video_stream;