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

Steve Lhomme robux4 at videolabs.io
Fri Feb 10 15:12:19 CET 2017


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

--
replaces https://patches.videolan.org/patch/15499/
- rename to plane_Setup()
- add some documentation
---
 include/vlc_picture.h | 14 ++++++++++++++
 src/libvlccore.sym    |  1 +
 src/misc/picture.c    | 14 +++++++++++---
 3 files changed, 26 insertions(+), 3 deletions(-)

diff --git a/include/vlc_picture.h b/include/vlc_picture.h
index b8d4a5a..865fdeb 100644
--- a/include/vlc_picture.h
+++ b/include/vlc_picture.h
@@ -222,6 +222,20 @@ VLC_API int picture_Export( vlc_object_t *p_obj, block_t **pp_image, video_forma
  */
 VLC_API int picture_Setup( picture_t *, const video_format_t * );
 
+/**
+ * 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);
+
+
 
 /*****************************************************************************
  * Shortcuts to access image components
diff --git a/src/libvlccore.sym b/src/libvlccore.sym
index 150409e..f5aa1fc 100644
--- a/src/libvlccore.sym
+++ b/src/libvlccore.sym
@@ -327,6 +327,7 @@ picture_pool_Wait
 picture_Reset
 picture_Setup
 plane_CopyPixels
+plane_Setup
 playlist_Add
 playlist_AddExt
 playlist_AddInput
diff --git a/src/misc/picture.c b/src/misc/picture.c
index 0a2dc8f..7421c2e 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 );
+}
+
+int plane_Setup( vlc_fourcc_t i_chroma, const video_format_t *restrict fmt,
+                         plane_t *planes, int *plane_count )
+{
     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,8 @@ 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;
+
+    *plane_count = p_dsc->plane_count;
 
     return VLC_SUCCESS;
 }
-- 
2.10.2



More information about the vlc-devel mailing list