Commit 19fe6a4c authored by Jean-Baptiste Kempf's avatar Jean-Baptiste Kempf

Move subpicture_region_Copy to the core

Signed-off-by: default avatarJean-Baptiste Kempf <jb@videolan.org>
parent 7f649acf
......@@ -105,6 +105,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 );
/**
*
*/
......
......@@ -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;
......
......@@ -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
......
......@@ -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;
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment