[vlc-devel] [PATCH 15/48] picture: pointer for decoder-specified hardware context
Rémi Denis-Courmont
remi at remlab.net
Tue Jul 2 19:51:41 CEST 2013
---
include/vlc_picture.h | 1 +
src/misc/picture.c | 20 ++++++++++++++++++--
2 files changed, 19 insertions(+), 2 deletions(-)
diff --git a/include/vlc_picture.h b/include/vlc_picture.h
index c99f54d..126229f 100644
--- a/include/vlc_picture.h
+++ b/include/vlc_picture.h
@@ -91,6 +91,7 @@ struct picture_t
bool b_progressive; /**< is it a progressive frame ? */
bool b_top_field_first; /**< which field is first */
unsigned int i_nb_fields; /**< # of displayed fields */
+ void * context; /**< video format-specific data */
/**@}*/
/** Private data - the video output plugin might want to put stuff here to
diff --git a/src/misc/picture.c b/src/misc/picture.c
index b8cf656..b69a38c 100644
--- a/src/misc/picture.c
+++ b/src/misc/picture.c
@@ -85,6 +85,18 @@ static int AllocatePicture( picture_t *p_pic )
/*****************************************************************************
*
*****************************************************************************/
+
+static void PictureDestroyContext( picture_t *p_picture )
+{
+ void (**context)( void * ) = p_picture->context;
+ if( context != NULL )
+ {
+ void (*context_destroy)( void * ) = *context;
+ context_destroy( context );
+ p_picture->context = NULL;
+ }
+}
+
static void PictureDestroy( picture_t *p_picture )
{
assert( p_picture &&
@@ -106,6 +118,7 @@ void picture_Reset( picture_t *p_picture )
p_picture->b_progressive = false;
p_picture->i_nb_fields = 2;
p_picture->b_top_field_first = false;
+ PictureDestroyContext( p_picture );
}
/*****************************************************************************
@@ -266,8 +279,11 @@ picture_t *picture_Hold( picture_t *p_picture )
void picture_Release( picture_t *p_picture )
{
- if( vlc_atomic_dec( &p_picture->gc.refcount ) == 0 &&
- p_picture->gc.pf_destroy )
+ if( vlc_atomic_dec( &p_picture->gc.refcount ) > 0 )
+ return;
+
+ PictureDestroyContext( p_picture );
+ if( p_picture->gc.pf_destroy != NULL )
p_picture->gc.pf_destroy( p_picture );
}
--
1.8.3.2
More information about the vlc-devel
mailing list