[vlc-commits] Move subpicture_region_Copy to the core

Jean-Baptiste Kempf git at videolan.org
Tue Jul 28 16:01:56 CEST 2015


vlc | branch: master | Jean-Baptiste Kempf <jb at videolan.org> | Mon Apr  6 18:49:15 2015 +0200| [19fe6a4cf3704652c4c075bcfef0be85c2773821] | committer: Jean-Baptiste Kempf

Move subpicture_region_Copy to the core

Signed-off-by: Jean-Baptiste Kempf <jb at videolan.org>

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=19fe6a4cf3704652c4c075bcfef0be85c2773821
---

 include/vlc_subpicture.h |    8 ++++++++
 modules/access/bluray.c  |   32 +-------------------------------
 src/libvlccore.sym       |    1 +
 src/misc/subpicture.c    |   29 +++++++++++++++++++++++++++++
 4 files changed, 39 insertions(+), 31 deletions(-)

diff --git a/include/vlc_subpicture.h b/include/vlc_subpicture.h
index 0329e03..3f130c9 100644
--- a/include/vlc_subpicture.h
+++ b/include/vlc_subpicture.h
@@ -106,6 +106,14 @@ VLC_API void subpicture_region_Delete( subpicture_region_t *p_region );
 VLC_API void subpicture_region_ChainDelete( subpicture_region_t *p_head );
 
 /**
+ * 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 );
+
+/**
  *
  */
 typedef struct subpicture_updater_sys_t subpicture_updater_sys_t;
diff --git a/modules/access/bluray.c b/modules/access/bluray.c
index 873031b..d218f91 100644
--- a/modules/access/bluray.c
+++ b/modules/access/bluray.c
@@ -676,36 +676,6 @@ static int subpictureUpdaterValidate(subpicture_t *p_subpic,
     return res;
 }
 
-/* This should probably be moved to subpictures.c afterward */
-static subpicture_region_t* subpicture_region_Clone(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->psz_text = p_region_src->psz_text ? strdup(p_region_src->psz_text) : NULL;
-    p_region_dst->psz_html = p_region_src->psz_html ? strdup(p_region_src->psz_html) : NULL;
-    if (p_region_src->p_style != NULL) {
-        p_region_dst->p_style = malloc(sizeof(*p_region_dst->p_style));
-        p_region_dst->p_style = text_style_Copy(p_region_dst->p_style,
-                                                p_region_src->p_style);
-    }
-
-    //Palette is already copied by subpicture_region_New, we just have to duplicate p_pixels
-    for (int i = 0; i < p_region_src->p_picture->i_planes; i++)
-        memcpy(p_region_dst->p_picture->p[i].p_pixels,
-               p_region_src->p_picture->p[i].p_pixels,
-               p_region_src->p_picture->p[i].i_lines * p_region_src->p_picture->p[i].i_pitch);
-    return p_region_dst;
-}
-
 static void subpictureUpdaterUpdate(subpicture_t *p_subpic,
                                     const video_format_t *p_fmt_src,
                                     const video_format_t *p_fmt_dst,
@@ -731,7 +701,7 @@ static void subpictureUpdaterUpdate(subpicture_t *p_subpic,
 
     subpicture_region_t **p_dst = &p_subpic->p_region;
     while (p_src != NULL) {
-        *p_dst = subpicture_region_Clone(p_src);
+        *p_dst = subpicture_region_Copy(p_src);
         if (*p_dst == NULL)
             break;
         p_dst = &(*p_dst)->p_next;
diff --git a/src/libvlccore.sym b/src/libvlccore.sym
index e740822..d8525b6 100644
--- a/src/libvlccore.sym
+++ b/src/libvlccore.sym
@@ -415,6 +415,7 @@ subpicture_New
 subpicture_NewFromPicture
 subpicture_Update
 subpicture_region_ChainDelete
+subpicture_region_Copy
 subpicture_region_Delete
 subpicture_region_New
 vlc_tls_ClientCreate
diff --git a/src/misc/subpicture.c b/src/misc/subpicture.c
index 3ae7722..e1237cb 100644
--- a/src/misc/subpicture.c
+++ b/src/misc/subpicture.c
@@ -290,3 +290,32 @@ 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->psz_text = p_region_src->psz_text ? strdup(p_region_src->psz_text) : NULL;
+    p_region_dst->psz_html = p_region_src->psz_html ? strdup(p_region_src->psz_html) : NULL;
+    if (p_region_src->p_style != NULL) {
+        p_region_dst->p_style = malloc(sizeof(*p_region_dst->p_style));
+        p_region_dst->p_style = text_style_Copy(p_region_dst->p_style,
+                                                p_region_src->p_style);
+    }
+
+    //Palette is already copied by subpicture_region_New, we just have to duplicate p_pixels
+    for (int i = 0; i < p_region_src->p_picture->i_planes; i++)
+        memcpy(p_region_dst->p_picture->p[i].p_pixels,
+               p_region_src->p_picture->p[i].p_pixels,
+               p_region_src->p_picture->p[i].i_lines * p_region_src->p_picture->p[i].i_pitch);
+    return p_region_dst;
+}



More information about the vlc-commits mailing list