[vlc-commits] picture: separate picture_NewFromFormat()
Rémi Denis-Courmont
git at videolan.org
Sun Feb 11 09:17:07 CET 2018
vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Sat Feb 10 11:55:16 2018 +0200| [da03a861eb8aeb8314a74571cb57825c83361298] | committer: Rémi Denis-Courmont
picture: separate picture_NewFromFormat()
No need to call picture_NewFromResource() there. Just call the common
code.
No functional changes.
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=da03a861eb8aeb8314a74571cb57825c83361298
---
src/misc/picture.c | 49 ++++++++++++++++++++++++++-----------------------
1 file changed, 26 insertions(+), 23 deletions(-)
diff --git a/src/misc/picture.c b/src/misc/picture.c
index 832a8495ae..62edbc8434 100644
--- a/src/misc/picture.c
+++ b/src/misc/picture.c
@@ -248,44 +248,47 @@ static picture_priv_t *picture_NewPrivate(const video_format_t *restrict p_fmt)
picture_t *picture_NewFromResource( const video_format_t *p_fmt, const picture_resource_t *p_resource )
{
+ assert(p_resource != NULL);
+
picture_priv_t *priv = picture_NewPrivate(p_fmt);
if (unlikely(priv == NULL))
return NULL;
picture_t *p_picture = &priv->picture;
- if( p_resource )
- {
- p_picture->p_sys = p_resource->p_sys;
-
- if( p_resource->pf_destroy != NULL )
- priv->gc.destroy = p_resource->pf_destroy;
- else
- priv->gc.destroy = picture_DestroyFromResource;
+ p_picture->p_sys = p_resource->p_sys;
- for( int i = 0; i < p_picture->i_planes; i++ )
- {
- p_picture->p[i].p_pixels = p_resource->p[i].p_pixels;
- p_picture->p[i].i_lines = p_resource->p[i].i_lines;
- p_picture->p[i].i_pitch = p_resource->p[i].i_pitch;
- }
- }
+ if( p_resource->pf_destroy != NULL )
+ priv->gc.destroy = p_resource->pf_destroy;
else
+ priv->gc.destroy = picture_DestroyFromResource;
+
+ for( int i = 0; i < p_picture->i_planes; i++ )
{
- if( AllocatePicture( p_picture ) )
- {
- free( p_picture );
- return NULL;
- }
- priv->gc.destroy = picture_Destroy;
+ p_picture->p[i].p_pixels = p_resource->p[i].p_pixels;
+ p_picture->p[i].i_lines = p_resource->p[i].i_lines;
+ p_picture->p[i].i_pitch = p_resource->p[i].i_pitch;
}
return p_picture;
}
-picture_t *picture_NewFromFormat( const video_format_t *p_fmt )
+picture_t *picture_NewFromFormat(const video_format_t *restrict fmt)
{
- return picture_NewFromResource( p_fmt, NULL );
+ picture_priv_t *priv = picture_NewPrivate(fmt);
+ if (unlikely(priv == NULL))
+ return NULL;
+
+ picture_t *pic = &priv->picture;
+
+ if( AllocatePicture( pic ) )
+ {
+ free( pic );
+ return NULL;
+ }
+ priv->gc.destroy = picture_Destroy;
+
+ return pic;
}
picture_t *picture_New( vlc_fourcc_t i_chroma, int i_width, int i_height, int i_sar_num, int i_sar_den )
More information about the vlc-commits
mailing list