[vlc-commits] [Git][videolan/vlc][master] 2 commits: bluray: use a reference of internal pictures instead of picture copy

Jean-Baptiste Kempf (@jbk) gitlab at videolan.org
Thu Nov 16 08:25:29 UTC 2023



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


Commits:
0ee8e70d by Steve Lhomme at 2023-11-16T06:43:49+00:00
bluray: use a reference of internal pictures instead of picture copy

The picture inside our internal regions is refcounted, so it will stay alive
even if the internal region is deleted.

This will make things a bit faster and use less memory.

- - - - -
e7065003 by Steve Lhomme at 2023-11-16T06:43:49+00:00
subpicture: remove subpicture_region_Copy()

It's not used anymore.

As the doc suggests it was provided for convenience and was originally not
handling text-based regions at all. Is it supposed to take care of the
subpicture_region_t::p_private data copying it doesn't know about ?

It is rare to need this feature on regions. In bluray it was likely done
because the same region couldn't be in 2 different containers at the same time.

- - - - -


4 changed files:

- include/vlc_subpicture.h
- modules/access/bluray.c
- src/libvlccore.sym
- src/misc/subpicture.c


Changes:

=====================================
include/vlc_subpicture.h
=====================================
@@ -166,14 +166,6 @@ VLC_API void subpicture_region_Delete( subpicture_region_t *p_region );
  */
 VLC_API void vlc_spu_regions_Clear( vlc_spu_regions * );
 
-/**
- * This function will copy a subpicture region to a new allocated one
- * and transfer all the properties
- *
- * Provided for convenience.
- */
-VLC_API subpicture_region_t *subpicture_region_Copy( subpicture_region_t *p_region );
-
 /**
  * Tells if the region is a text-based region.
  */


=====================================
modules/access/bluray.c
=====================================
@@ -1674,17 +1674,26 @@ static void subpictureUpdaterUpdate(subpicture_t *p_subpic,
      * When this function is called, all p_subpic regions are gone.
      * We need to duplicate our regions (stored internally) to this subpic.
      */
-    subpicture_region_t *p_src;
+    const subpicture_region_t *p_src;
     if (vlc_spu_regions_is_empty(&p_overlay->regions)) {
         updater_unlock_overlay(p_upd_sys);
         return;
     }
 
     subpicture_region_t *p_dst;
-    vlc_spu_regions_foreach(p_src, &p_overlay->regions) {
-        p_dst = subpicture_region_Copy(p_src);
+    vlc_spu_regions_foreach_const(p_src, &p_overlay->regions) {
+        p_dst = subpicture_region_ForPicture(&p_src->fmt, p_src->p_picture);
         if (p_dst == NULL)
             break;
+
+        p_dst->i_x      = p_src->i_x;
+        p_dst->i_y      = p_src->i_y;
+        // fields not modified on the source
+        p_dst->i_align  = p_src->i_align;
+        p_dst->i_alpha  = p_src->i_alpha;
+        p_dst->zoom_h   = p_src->zoom_h;
+        p_dst->zoom_v   = p_src->zoom_v;
+
         vlc_spu_regions_push(&p_subpic->regions, p_dst);
     }
     p_overlay->status = Displayed;


=====================================
src/libvlccore.sym
=====================================
@@ -412,7 +412,6 @@ subpicture_Update
 vlc_spu_regions_Clear
 vlc_render_subpicture_New
 vlc_render_subpicture_Delete
-subpicture_region_Copy
 subpicture_region_Delete
 subpicture_region_New
 subpicture_region_NewText


=====================================
src/misc/subpicture.c
=====================================
@@ -366,28 +366,3 @@ unsigned picture_BlendSubpicture(picture_t *dst,
     }
     return done;
 }
-
-subpicture_region_t* subpicture_region_Copy( subpicture_region_t *p_region_src )
-{
-    if (!p_region_src)
-        return NULL;
-    subpicture_region_t *p_region_dst = subpicture_region_New(&p_region_src->fmt);
-    if (unlikely(!p_region_dst))
-        return NULL;
-
-    p_region_dst->i_x      = p_region_src->i_x;
-    p_region_dst->i_y      = p_region_src->i_y;
-    p_region_dst->i_align  = p_region_src->i_align;
-    p_region_dst->i_alpha  = p_region_src->i_alpha;
-
-    p_region_dst->text_flags      = p_region_src->text_flags;
-    p_region_dst->i_max_width     = p_region_src->i_max_width;
-    p_region_dst->i_max_height    = p_region_src->i_max_height;
-    p_region_dst->p_text = text_segment_Copy( p_region_src->p_text );
-
-    p_region_dst->zoom_h   = p_region_src->zoom_h;
-    p_region_dst->zoom_v   = p_region_src->zoom_v;
-
-    picture_CopyPixels(p_region_dst->p_picture, p_region_src->p_picture);
-    return p_region_dst;
-}



View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/62a2fcc8d6d07d371f8611c480b5ea5330fd7729...e70650037ef8c8becfca73f7182512122efa6255

-- 
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/62a2fcc8d6d07d371f8611c480b5ea5330fd7729...e70650037ef8c8becfca73f7182512122efa6255
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