[vlc-devel] [PATCH] picture: split the plane definition from the picture creation
Steve Lhomme
robux4 at videolabs.io
Mon Jan 30 10:49:54 CET 2017
This way we can tell plane dimensions from a video format anywhere.
---
include/vlc_picture.h | 4 ++++
src/libvlccore.sym | 1 +
src/misc/picture.c | 46 +++++++++++++++++++++++++++-------------------
3 files changed, 32 insertions(+), 19 deletions(-)
diff --git a/include/vlc_picture.h b/include/vlc_picture.h
index b8d4a5a..4fd88a7 100644
--- a/include/vlc_picture.h
+++ b/include/vlc_picture.h
@@ -222,6 +222,10 @@ 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 * );
+VLC_API int picture_SetupPlanes(vlc_fourcc_t, const video_format_t *, plane_t *,
+ int *plane_count);
+
+
/*****************************************************************************
* Shortcuts to access image components
diff --git a/src/libvlccore.sym b/src/libvlccore.sym
index 7b9657a..cedfd0b 100644
--- a/src/libvlccore.sym
+++ b/src/libvlccore.sym
@@ -327,6 +327,7 @@ picture_pool_Reserve
picture_pool_Wait
picture_Reset
picture_Setup
+picture_SetupPlanes
plane_CopyPixels
playlist_Add
playlist_AddExt
diff --git a/src/misc/picture.c b/src/misc/picture.c
index 0a2dc8f..90c6151 100644
--- a/src/misc/picture.c
+++ b/src/misc/picture.c
@@ -137,25 +137,11 @@ static int LCM( int a, int b )
return a * b / GCD( a, b );
}
-int picture_Setup( picture_t *p_picture, const video_format_t *restrict fmt )
+int picture_SetupPlanes( vlc_fourcc_t i_chroma, const video_format_t *restrict fmt,
+ plane_t *planes, int *plane_count )
{
- /* Store default values */
- p_picture->i_planes = 0;
- for( unsigned i = 0; i < VOUT_MAX_PLANES; i++ )
- {
- plane_t *p = &p_picture->p[i];
- p->p_pixels = NULL;
- p->i_pixel_pitch = 0;
- }
-
- p_picture->i_nb_fields = 2;
-
- video_format_Setup( &p_picture->format, fmt->i_chroma, fmt->i_width, fmt->i_height,
- fmt->i_visible_width, fmt->i_visible_height,
- fmt->i_sar_num, fmt->i_sar_den );
-
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 +168,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,11 +178,33 @@ 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;
}
+int picture_Setup( picture_t *p_picture, const video_format_t *restrict fmt )
+{
+ /* Store default values */
+ p_picture->i_planes = 0;
+ for( unsigned i = 0; i < VOUT_MAX_PLANES; i++ )
+ {
+ plane_t *p = &p_picture->p[i];
+ p->p_pixels = NULL;
+ p->i_pixel_pitch = 0;
+ }
+
+ p_picture->i_nb_fields = 2;
+
+ video_format_Setup( &p_picture->format, fmt->i_chroma, fmt->i_width, fmt->i_height,
+ fmt->i_visible_width, fmt->i_visible_height,
+ fmt->i_sar_num, fmt->i_sar_den );
+
+ return picture_SetupPlanes( p_picture->format.i_chroma, fmt, p_picture->p,
+ &p_picture->i_planes );
+}
+
/*****************************************************************************
*
*****************************************************************************/
--
2.10.2
More information about the vlc-devel
mailing list