Jean-Baptiste Kempf pushed to branch master at VideoLAN / VLC


Commits:
7e659707 by François Cartegnie at 2023-11-24T15:31:10+00:00
vout: subpicture: try to early remove non renderable spu

- - - - -


1 changed file:

- src/video_output/vout_subpictures.c


Changes:

=====================================
src/video_output/vout_subpictures.c
=====================================
@@ -161,25 +161,60 @@ static int spu_channel_Push(struct spu_channel *channel, 
subpicture_t *subpic,
     return vlc_vector_push(&channel->entries, entry) ? VLC_SUCCESS : 
VLC_EGENERIC;
 }
 
+static void spu_Channel_CleanEntry(spu_private_t *sys, spu_render_entry_t 
*entry)
+{
+    assert(entry->subpic);
+
+    picture_t *pic;
+    vlc_vector_foreach(pic, &entry->scaled_region_pics)
+    {
+        if (pic != NULL)
+            picture_Release(pic);
+    }
+    vlc_vector_clear(&entry->scaled_region_pics);
+
+    spu_PrerenderCancel(sys, entry->subpic);
+    subpicture_Delete(entry->subpic);
+}
+
 static void spu_channel_Clean(spu_private_t *sys, struct spu_channel *channel)
 {
     spu_render_entry_t *entry;
     vlc_vector_foreach_ref(entry, &channel->entries)
+        spu_Channel_CleanEntry(sys, entry);
+    vlc_vector_clear(&channel->entries);
+}
+
+static bool spu_HasAlreadyExpired(vlc_tick_t start, vlc_tick_t stop,
+                                  vlc_tick_t system_now)
+{
+    bool b_stop_is_valid = (stop >= start);
+    /* we can't include ephemere SPU without end date
+           as the joining gap would be dropped due to the
+           asynchronous update between the drop and the displayed SPU */
+    if(b_stop_is_valid && stop < system_now)
+        return true;
+    return false;
+}
+
+static void spu_channel_EarlyRemoveLate(spu_private_t *sys,
+                                        struct spu_channel *channel,
+                                        vlc_tick_t system_now)
+{
+    /* Trying to have a reasonable hint to remove early from queue
+     * SPU that have no chance to be rendered */
+    for (size_t i = 0; i < channel->entries.size;)
     {
-        assert(entry->subpic);
+        const spu_render_entry_t *entry = &channel->entries.data[i];
 
-        picture_t *pic;
-        vlc_vector_foreach(pic, &entry->scaled_region_pics)
+        if(spu_HasAlreadyExpired(entry->start, entry->stop, system_now))
         {
-            if (pic != NULL)
-                picture_Release(pic);
+            spu_Channel_CleanEntry(sys, &channel->entries.data[i]);
+            vlc_vector_remove(&channel->entries, i);
         }
-        vlc_vector_clear(&entry->scaled_region_pics);
-
-        spu_PrerenderCancel(sys, entry->subpic);
-        subpicture_Delete(entry->subpic);
+        else
+            i++;
     }
-    vlc_vector_clear(&channel->entries);
 }
 
 static struct spu_channel *spu_GetChannel(spu_t *spu, size_t channel_id)
@@ -1976,6 +2011,16 @@ void spu_PutSubpicture(spu_t *spu, subpicture_t *subpic)
             vlc_clock_ConvertToSystemLocked(channel->clock, system_now,
                                             orgstop, channel->rate);
         vlc_clock_Unlock(channel->clock);
+
+        spu_channel_EarlyRemoveLate(sys, channel, system_now);
+
+        /* Maybe the new one is also already expired */
+        if(spu_HasAlreadyExpired(subpic->i_start, subpic->i_stop, system_now))
+        {
+            vlc_mutex_unlock(&sys->lock);
+            subpicture_Delete(subpic);
+            return;
+        }
     }
 
     if (spu_channel_Push(channel, subpic, orgstart, orgstop))



View it on GitLab: 
https://code.videolan.org/videolan/vlc/-/commit/7e659707837e13be4d57aa57fec18f2b6e0e90f8

-- 
View it on GitLab: 
https://code.videolan.org/videolan/vlc/-/commit/7e659707837e13be4d57aa57fec18f2b6e0e90f8
You're receiving this email because of your account on code.videolan.org.


VideoLAN code repository instance
_______________________________________________
vlc-commits mailing list
vlc-commits@videolan.org
https://mailman.videolan.org/listinfo/vlc-commits

Reply via email to