[vlc-devel] [PATCH v3 01/24] picture: add helpers for picture chaining
Thomas Guillem
thomas at gllm.fr
Mon Sep 21 10:37:40 CEST 2020
On Mon, Sep 21, 2020, at 08:29, Steve Lhomme wrote:
> Picture chains are used either to keep a list of picture (in FIFO order) or to
> attach a picture to another and return them all at once (filters).
> ---
> include/vlc_picture.h | 94 +++++++++++++++++++++++++++++++++++++++++++
> 1 file changed, 94 insertions(+)
>
> diff --git a/include/vlc_picture.h b/include/vlc_picture.h
> index 7bb9ee5083c..ded7f0df81d 100644
> --- a/include/vlc_picture.h
> +++ b/include/vlc_picture.h
> @@ -167,6 +167,100 @@ static inline vlc_video_context*
> picture_GetVideoContext(picture_t *pic)
> return pic->context ? pic->context->vctx : NULL;
> }
>
> +/**
> + * picture chaining helpers
> + */
> +
> +/**
> + * Pop the chain from a picture chain.
> + *
> + * The next picture in the chain becomes the front of the picture
> chain.
> + *
> + * \return the front of the picture chain, with other pictures still
> chained
> + */
> +static inline picture_t * vlc_picture_chain_PopChain(picture_t **chain)
Do we really need this PopChain ?
You are returning the whole chain and yet you keep it in chain. This feels dangerous.
> +{
> + picture_t *front = *chain;
> + if (front)
> + *chain = front->p_next;
> + return front;
> +}
> +
> +/**
> + * Pop the front of a picture chain.
> + *
> + * The next picture in the chain becomes the front of the picture
> chain.
> + *
> + * \return the front of the picture chain (the picture itself)
> + */
> +static inline picture_t * vlc_picture_chain_PopFront(picture_t **chain)
> +{
> + picture_t *front = *chain;
> + if (front)
> + {
> + *chain = front->p_next;
> + // unlink the front picture from the rest of the chain
> + front->p_next = NULL;
> + }
> + return front;
> +}
> +
> +/**
> + * Append a picture chain to a picture chain.
> + */
> +static inline void vlc_picture_chain_AppendChain(picture_t *chain,
> picture_t *tail)
> +{
> + chain->p_next = tail;
> +}
> +
> +/**
> + * Append a picture to a picture chain.
> + *
> + * \param chain the picture chain pointer
> + * \param pic the picture to append to the chain
> + *
> + * \return the new tail of the picture chain
> + */
> +VLC_USED
> +static inline picture_t * vlc_picture_chain_Append(picture_t *chain,
> picture_t *pic)
> +{
> + chain->p_next = pic;
> + pic->p_next = NULL; // we're appending a picture, not a chain
> + return pic;
> +}
> +
> +/**
> + * Add a picture at the front of a picture chain.
> + *
> + * The added picture becomes the front of the picture chain.
> + */
> +static inline void vlc_picture_chain_Prepend(picture_t **chain,
> picture_t *pic)
> +{
> + pic->p_next = *chain;
> + *chain = pic;
> +}
> +
> +/**
> + * Check whether a picture has other pictures linked
> + */
> +static inline bool picture_HasChainedPics(const picture_t *pic)
> +{
> + return pic->p_next != NULL;
> +}
> +
> +/**
> + * Reset a picture chain.
> + *
> + * \return the picture chain that was contained in the picture
> + */
> +static inline picture_t * picture_GetAndResetChain(picture_t *pic)
> +{
> + picture_t *chain = pic->p_next;
> + pic->p_next = NULL;
> + return chain;
> +}
> +
> +
> /**
> * This function will create a new picture.
> * The picture created will implement a default release management
> compatible
> --
> 2.26.2
>
> _______________________________________________
> vlc-devel mailing list
> To unsubscribe or modify your subscription options:
> https://mailman.videolan.org/listinfo/vlc-devel
More information about the vlc-devel
mailing list