[vlc-devel] [PATCH 4/7] picture: split the plane definition from the picture creation

Steve Lhomme robux4 at videolabs.io
Thu May 11 09:36:06 CEST 2017


From: Steve Lhomme <robUx4 at videolabs.io>

This way we can tell plane dimensions from a video format anywhere.

And we can find the dimensions to use when using a GPU texture in the CPU,
especially the internal height VLC uses for ASM optimized code.
---
 include/vlc_picture.h | 14 ++++++++++++++
 src/libvlccore.sym    |  1 +
 src/misc/picture.c    | 17 ++++++++++++++---
 3 files changed, 29 insertions(+), 3 deletions(-)

diff --git a/include/vlc_picture.h b/include/vlc_picture.h
index 718e3946a4..fcea7a97a3 100644
--- a/include/vlc_picture.h
+++ b/include/vlc_picture.h
@@ -235,6 +235,20 @@ VLC_API int picture_Setup( picture_t *, const video_format_t * );
  */
 VLC_API int picture_UpdatePlanes(picture_t *p_pic, uint8_t *p_buf, unsigned i_pitch, bool b_swap);
 
+/**
+ * This function setup the plane dimensions needed to store the specified chroma with
+ * the dimensions from the given format.
+ *
+ * It will return VLC_EGENERIC if the core does not understand the requested
+ * chroma.
+ *
+ * p_planes and plane_count will be filled when succesful.
+ *
+ * p_planes should hold at least PICTURE_PLANE_MAX plane_t items.
+ */
+VLC_API int plane_Setup(vlc_fourcc_t chroma, const video_format_t *fmt, plane_t *p_planes,
+                        int *plane_count, unsigned *internal_height);
+
 /*****************************************************************************
  * Shortcuts to access image components
  *****************************************************************************/
diff --git a/src/libvlccore.sym b/src/libvlccore.sym
index da98551cb1..d29129f99a 100644
--- a/src/libvlccore.sym
+++ b/src/libvlccore.sym
@@ -329,6 +329,7 @@ picture_Reset
 picture_Setup
 picture_UpdatePlanes
 plane_CopyPixels
+plane_Setup
 playlist_Add
 playlist_AddExt
 playlist_AddInput
diff --git a/src/misc/picture.c b/src/misc/picture.c
index ceb9fad2d5..f7ed3f2e39 100644
--- a/src/misc/picture.c
+++ b/src/misc/picture.c
@@ -154,8 +154,15 @@ int picture_Setup( picture_t *p_picture, const video_format_t *restrict fmt )
                         fmt->i_visible_width, fmt->i_visible_height,
                         fmt->i_sar_num, fmt->i_sar_den );
 
+    return plane_Setup( p_picture->format.i_chroma, fmt, p_picture->p,
+                                &p_picture->i_planes, NULL );
+}
+
+int plane_Setup( vlc_fourcc_t i_chroma, const video_format_t *restrict fmt,
+                 plane_t *planes, int *plane_count, unsigned *internal_height )
+{
     const vlc_chroma_description_t *p_dsc =
-        vlc_fourcc_GetChromaDescription( p_picture->format.i_chroma );
+        vlc_fourcc_GetChromaDescription( i_chroma );
     if( !p_dsc )
         return VLC_EGENERIC;
 
@@ -182,7 +189,7 @@ int picture_Setup( picture_t *p_picture, const video_format_t *restrict fmt )
     const int i_height_extra   = 2 * i_ratio_h; /* This one is a hack for some ASM functions */
     for( unsigned i = 0; i < p_dsc->plane_count; i++ )
     {
-        plane_t *p = &p_picture->p[i];
+        plane_t *p = &planes[i];
 
         p->i_lines         = (i_height_aligned + i_height_extra ) * p_dsc->p[i].h.num / p_dsc->p[i].h.den;
         p->i_visible_lines = fmt->i_visible_height * p_dsc->p[i].h.num / p_dsc->p[i].h.den;
@@ -192,7 +199,11 @@ int picture_Setup( picture_t *p_picture, const video_format_t *restrict fmt )
 
         assert( (p->i_pitch % 16) == 0 );
     }
-    p_picture->i_planes  = p_dsc->plane_count;
+
+    if (plane_count)
+        *plane_count = p_dsc->plane_count;
+    if (internal_height)
+        *internal_height = i_height_aligned + i_height_extra;
 
     return VLC_SUCCESS;
 }
-- 
2.12.1



More information about the vlc-devel mailing list