[vlc-commits] [Git][videolan/vlc][master] 9 commits: vout_subpictures: merge spu_channel_Clear() and spu_channel_Clean()

Steve Lhomme (@robUx4) gitlab at videolan.org
Fri Nov 17 12:43:58 UTC 2023



Steve Lhomme pushed to branch master at VideoLAN / VLC


Commits:
a2ca60f5 by Steve Lhomme at 2023-11-17T12:24:48+00:00
vout_subpictures: merge spu_channel_Clear() and spu_channel_Clean()

It does the same as spu_channel_Clean():

- spu_PrerenderCancel() on each subpicture
- subpicture_Delete() on each subpicture
- empty the channel->entries vector

- - - - -
ea91ffcc by Steve Lhomme at 2023-11-17T12:24:48+00:00
vout_subpictures: use local variables to simplify code

- - - - -
6e731cbe by Steve Lhomme at 2023-11-17T12:24:48+00:00
vout_subpictures: use vlc_vector_foreach_ref() to channel entries

We don't use it below in spu_SelectSubpictures() because the element is
deleted with the index.

- - - - -
f84bb0ee by Steve Lhomme at 2023-11-17T12:24:48+00:00
vout_subpictures: use a function to fix region colorimetry

- - - - -
dd095f8d by Steve Lhomme at 2023-11-17T12:24:48+00:00
vout_subpictures: do the region fix early

- - - - -
f5f23599 by Steve Lhomme at 2023-11-17T12:24:48+00:00
vout_subpictures: pass the text region to render as const

- - - - -
962a8062 by Steve Lhomme at 2023-11-17T12:24:48+00:00
vout_subpictures: fix the SPU color space for rendered text regions

The same way it's fixed for other regions.

- - - - -
27413956 by Steve Lhomme at 2023-11-17T12:24:48+00:00
vout_subpicture: mark the final rendering of text region unlikely

They should be rendered by the pre-renderer (spu_PrerenderText).

- - - - -
432195b8 by Steve Lhomme at 2023-11-17T12:24:48+00:00
vout_subpictures: remove unneeded forward declaration

It's only used after the definition.

- - - - -


1 changed file:

- src/video_output/vout_subpictures.c


Changes:

=====================================
src/video_output/vout_subpictures.c
=====================================
@@ -133,7 +133,6 @@ struct spu_private_t {
     vout_thread_t       *vout;
 };
 
-static void spu_PrerenderSync(spu_private_t *, const subpicture_t *);
 static void spu_PrerenderCancel(spu_private_t *, const subpicture_t *);
 
 static void spu_channel_Init(struct spu_channel *channel, size_t id,
@@ -161,24 +160,16 @@ 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_DeleteAt(struct spu_channel *channel, size_t index)
-{
-    assert(index < channel->entries.size);
-    assert(channel->entries.data[index].subpic);
-
-    subpicture_Delete(channel->entries.data[index].subpic);
-    vlc_vector_remove(&channel->entries, index);
-}
-
 static void spu_channel_Clean(spu_private_t *sys, struct spu_channel *channel)
 {
-    for (size_t i = 0; i < channel->entries.size; i++)
+    spu_render_entry_t *entry;
+    vlc_vector_foreach_ref(entry, &channel->entries)
     {
-        assert(channel->entries.data[i].subpic);
-        spu_PrerenderCancel(sys, channel->entries.data[i].subpic);
-        subpicture_Delete(channel->entries.data[i].subpic);
+        assert(entry->subpic);
+        spu_PrerenderCancel(sys, entry->subpic);
+        subpicture_Delete(entry->subpic);
     }
-    vlc_vector_destroy(&channel->entries);
+    vlc_vector_clear(&channel->entries);
 }
 
 static struct spu_channel *spu_GetChannel(spu_t *spu, size_t channel_id)
@@ -313,8 +304,21 @@ static filter_t *SpuRenderCreateAndLoadScale(vlc_object_t *object,
     return scale;
 }
 
+static void region_FixFmt(subpicture_region_t *region)
+{
+    // assume rendered text is in sRGB if nothing is set
+    if (region->fmt.transfer == TRANSFER_FUNC_UNDEF)
+        region->fmt.transfer = TRANSFER_FUNC_SRGB;
+    if (region->fmt.primaries == COLOR_PRIMARIES_UNDEF)
+        region->fmt.primaries = COLOR_PRIMARIES_SRGB;
+    if (region->fmt.space == COLOR_SPACE_UNDEF)
+        region->fmt.space = COLOR_SPACE_SRGB;
+    if (region->fmt.color_range == COLOR_RANGE_UNDEF)
+        region->fmt.color_range = COLOR_RANGE_FULL;
+}
+
 static subpicture_region_t *SpuRenderText(spu_t *spu,
-                          subpicture_region_t *region,
+                          const subpicture_region_t *region,
                           unsigned i_original_width,
                           unsigned i_original_height,
                           const vlc_fourcc_t *chroma_list)
@@ -332,16 +336,6 @@ static subpicture_region_t *SpuRenderText(spu_t *spu,
         return NULL;
     }
 
-    // assume rendered text is in sRGB if nothing is set
-    if (region->fmt.transfer == TRANSFER_FUNC_UNDEF)
-        region->fmt.transfer = TRANSFER_FUNC_SRGB;
-    if (region->fmt.primaries == COLOR_PRIMARIES_UNDEF)
-        region->fmt.primaries = COLOR_PRIMARIES_SRGB;
-    if (region->fmt.space == COLOR_SPACE_UNDEF)
-        region->fmt.space = COLOR_SPACE_SRGB;
-    if (region->fmt.color_range == COLOR_RANGE_UNDEF)
-        region->fmt.color_range = COLOR_RANGE_FULL;
-
     /* FIXME aspect ratio ? */
     text->fmt_out.video.i_width =
     text->fmt_out.video.i_visible_width  = i_original_width;
@@ -603,9 +597,9 @@ static size_t spu_channel_UpdateDates(struct spu_channel *channel,
         goto end;
 
     vlc_clock_Lock(channel->clock);
-    for (size_t index = 0; index < channel->entries.size; index++)
+    spu_render_entry_t *entry;
+    vlc_vector_foreach_ref(entry, &channel->entries)
     {
-        spu_render_entry_t *entry = &channel->entries.data[index];
         assert(entry);
 
         vlc_tick_t ts;
@@ -691,8 +685,8 @@ spu_SelectSubpictures(spu_t *spu, vlc_tick_t system_now,
             continue;
 
         /* Select available pictures */
-        for (size_t index = 0; index < channel->entries.size; index++) {
-            spu_render_entry_t *render_entry = &channel->entries.data[index];
+        spu_render_entry_t *render_entry;
+        vlc_vector_foreach_ref(render_entry, &channel->entries) {
             subpicture_t *current = render_entry->subpic;
             const vlc_tick_t render_date = current->b_subtitle ? render_subtitle_date : system_now;
 
@@ -732,7 +726,7 @@ spu_SelectSubpictures(spu_t *spu, vlc_tick_t system_now,
 
         /* Select pictures to be displayed */
         for (size_t index = 0; index < channel->entries.size; ) {
-            spu_render_entry_t *render_entry = &channel->entries.data[index];
+            render_entry = &channel->entries.data[index];
             subpicture_t *current = render_entry->subpic;
             bool is_late = render_entry->is_late;
 
@@ -809,7 +803,7 @@ static subpicture_region_t *SpuRenderRegion(spu_t *spu,
     *dst_area = spu_area_create(0,0, 0,0, scale_size);
 
     /* Render text region */
-    if (subpicture_region_IsText( region ))
+    if (unlikely(subpicture_region_IsText( region )))
     {
         subpicture_region_t *rendered_text =
             SpuRenderText(spu, region,
@@ -822,10 +816,9 @@ static subpicture_region_t *SpuRenderRegion(spu_t *spu,
         vlc_list_replace(&region->node, &rendered_text->node);
         subpicture_region_Delete(region);
         region = rendered_text;
+        region_FixFmt(rendered_text);
     }
 
-    video_format_AdjustColorSpace(&region->fmt);
-
     /* Force palette if requested
      * FIXME b_force_palette and force_crop are applied to all subpictures using palette
      * instead of only the right one (being the dvd spu).
@@ -1212,6 +1205,9 @@ static vlc_render_subpicture *SpuRenderSubpictures(spu_t *spu,
         const unsigned i_original_width = subpic->i_original_picture_width;
         const unsigned i_original_height = subpic->i_original_picture_height;
 
+        vlc_spu_regions_foreach(region, &subpic->regions)
+            region_FixFmt(region);
+
         /* Render all regions
          * We always transform non absolute subtitle into absolute one on the
          * first rendering to allow good subtitle overlap support.
@@ -2042,11 +2038,11 @@ vlc_render_subpicture *spu_Render(spu_t *spu,
         spu_render_entry_t *entry = &subpicture_array[i];
         subpicture_t *subpic = entry->subpic;
 
-        spu_PrerenderSync(sys, entry->subpic);
+        spu_PrerenderSync(sys, subpic);
 
         /* Update time to clock */
-        entry->subpic->i_start = entry->start;
-        entry->subpic->i_stop = entry->stop;
+        subpic->i_start = entry->start;
+        subpic->i_stop = entry->stop;
 
         subpicture_Update(subpic,
                           fmt_src, fmt_dst,
@@ -2104,22 +2100,12 @@ ssize_t spu_RegisterChannel(spu_t *spu)
     return spu_RegisterChannelInternal(spu, NULL, NULL);
 }
 
-static void spu_channel_Clear(spu_private_t *sys,
-                              struct spu_channel *channel)
-{
-    for (size_t i = 0; i < channel->entries.size; i++)
-    {
-        spu_PrerenderCancel(sys, channel->entries.data[i].subpic);
-        spu_channel_DeleteAt(channel, i);
-    }
-}
-
 void spu_ClearChannel(spu_t *spu, size_t channel_id)
 {
     spu_private_t *sys = spu->p;
     vlc_mutex_lock(&sys->lock);
     struct spu_channel *channel = spu_GetChannel(spu, channel_id);
-    spu_channel_Clear(sys, channel);
+    spu_channel_Clean(sys, channel);
     if (channel->clock)
     {
         vlc_clock_Reset(channel->clock);



View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/9fc7deb8d1b070f2e615fc84b6c0db95a5540d68...432195b83e2038df3dbe826f5e294fe62fc41091

-- 
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/9fc7deb8d1b070f2e615fc84b6c0db95a5540d68...432195b83e2038df3dbe826f5e294fe62fc41091
You're receiving this email because of your account on code.videolan.org.


VideoLAN code repository instance


More information about the vlc-commits mailing list