Commit caa4d653 authored by Laurent Aimar's avatar Laurent Aimar

Improved a bit picture API.

parent c14063ab
......@@ -51,6 +51,11 @@ typedef struct plane_t
} plane_t;
/**
* A private definition to help overloading picture release
*/
typedef struct picture_release_sys_t picture_release_sys_t;
/**
* Video picture
*
......@@ -113,6 +118,7 @@ struct picture_t
/** This way the picture_Release can be overloaded */
void (*pf_release)( picture_t * );
picture_release_sys_t *p_release_sys;
/** Next picture in a FIFO a pictures */
struct picture_t *p_next;
......@@ -122,7 +128,7 @@ struct picture_t
* This function will create a new picture.
* The picture created will implement a default release management compatible
* with picture_Hold and picture_Release. This default management will release
* picture_sys_t *p_sys field if non NULL.
* p_sys, p_q, p_data_orig fields if non NULL.
*/
VLC_EXPORT( picture_t *, picture_New, ( vlc_fourcc_t i_chroma, int i_width, int i_height, int i_aspect ) );
......@@ -155,6 +161,17 @@ static inline void picture_Release( picture_t *p_picture )
p_picture->pf_release( p_picture );
}
/**
* This function will return true if you are not the only owner of the
* picture.
*
* It is only valid if it is created using picture_New.
*/
static inline bool picture_IsReferenced( picture_t *p_picture )
{
return p_picture->i_refcount > 1;
}
/**
* Cleanup quantization matrix data and set to 0
*/
......
......@@ -38,6 +38,7 @@
#include <vlc_filter.h>
#include <vlc_image.h>
#include <vlc_block.h>
#include <vlc_picture_pool.h>
#include "vout_pictures.h"
#include "vout_internal.h"
......@@ -664,6 +665,7 @@ int picture_Setup( picture_t *p_picture, vlc_fourcc_t i_chroma, int i_width, int
}
p_picture->pf_release = NULL;
p_picture->p_release_sys = NULL;
p_picture->pf_lock = NULL;
p_picture->pf_unlock = NULL;
p_picture->i_refcount = 0;
......@@ -925,6 +927,7 @@ picture_t *picture_New( vlc_fourcc_t i_chroma, int i_width, int i_height, int i_
void picture_Delete( picture_t *p_picture )
{
assert( p_picture && p_picture->i_refcount == 0 );
assert( p_picture->p_release_sys == NULL );
free( p_picture->p_q );
free( p_picture->p_data_orig );
......@@ -1047,4 +1050,3 @@ int picture_Export( vlc_object_t *p_obj,
/*****************************************************************************
*
*****************************************************************************/
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment