[vlc-devel] [vlc-commits] picture: add picture_Clone()

Thomas Guillem thomas at gllm.fr
Mon Nov 6 09:11:07 CET 2017



On Mon, Nov 6, 2017, at 08:50, Steve Lhomme wrote:
> On Mon, Nov 6, 2017 at 8:43 AM, Thomas Guillem <thomas at gllm.fr> wrote:
> >
> > On Mon, Nov 6, 2017, at 08:34, Steve Lhomme wrote:
> >> Although I agree with this addition. Doesn't the freeze means we're no
> >> supposed to add new APIs' to libvlccore ?
> >
> > Yes, but we have to add this new API to fix this critical issue.
> >
> > I guess the rules is: no new API (especially in order to add features),
> > unless it's mandatory to fix a bug.
> 
> I need new APIs (proper surface context sharing or more refined
> picture pools) to fix #18936. But it's unlikely to happen since we
> said it should go in 4.0.

But a change like that will modify the behavior of every HW decoders /
vout for all platforms.

We know this problem since a long time:
 - It's working on Videotoolbox since filters/vout/decoders doesn't
 require a context from a vout
 - It's working on VDPAU since filters do nothing but just put some
 params in a struct that will be used by the video converter (VDPAU is
 not direct rendering from VLC point of view even if it's not doing any
 CPU copy)
 - It's working on VAAPI because we did a hack to use onlu one filter
 when there is more than one. Therefore, you end up with dummy filters
 that just configure the principal one.

I'm aware that the VAAPI way is a little hackish. We did that way
because we didn't want to touch the core API for 3.0.

Is it possible to find a work-around for Windows ?

> 
> >>
> >> On Sat, Nov 4, 2017 at 5:33 PM, Rémi Denis-Courmont <git at videolan.org>
> >> wrote:
> >> > vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Sat Nov  4 17:55:22 2017 +0200| [00425a2585b1a9821b1521e907f01d98d03ae897] | committer: Rémi Denis-Courmont
> >> >
> >> > picture: add picture_Clone()
> >> >
> >> >> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=00425a2585b1a9821b1521e907f01d98d03ae897
> >> > ---
> >> >
> >> >  include/vlc_picture.h   | 11 +++++++++++
> >> >  src/libvlccore.sym      |  1 +
> >> >  src/misc/picture.c      | 32 ++++++++++++++++++++++++++++++++
> >> >  src/misc/picture_pool.c |  6 ++++++
> >> >  4 files changed, 50 insertions(+)
> >> >
> >> > diff --git a/include/vlc_picture.h b/include/vlc_picture.h
> >> > index 3d71633fe4..74f156fbbd 100644
> >> > --- a/include/vlc_picture.h
> >> > +++ b/include/vlc_picture.h
> >> > @@ -189,6 +189,17 @@ VLC_API void plane_CopyPixels( plane_t *p_dst, const plane_t *p_src );
> >> >  VLC_API void picture_Copy( picture_t *p_dst, const picture_t *p_src );
> >> >
> >> >  /**
> >> > + * Perform a shallow picture copy
> >> > + *
> >> > + * This function makes a shallow copy of an existing picture. The same planes
> >> > + * and resources will be used, and the cloned picture reference count will be
> >> > + * incremented.
> >> > + *
> >> > + * \return A clone picture on success, NULL on error.
> >> > + */
> >> > +VLC_API picture_t *picture_Clone(picture_t *pic);
> >> > +
> >> > +/**
> >> >   * This function will export a picture to an encoded bitstream.
> >> >   *
> >> >   * pp_image will contain the encoded bitstream in psz_format format.
> >> > diff --git a/src/libvlccore.sym b/src/libvlccore.sym
> >> > index 21316ce2b8..539ddff8a8 100644
> >> > --- a/src/libvlccore.sym
> >> > +++ b/src/libvlccore.sym
> >> > @@ -295,6 +295,7 @@ net_vaPrintf
> >> >  net_Write
> >> >  NTPtime64
> >> >  picture_BlendSubpicture
> >> > +picture_Clone
> >> >  picture_CopyPixels
> >> >  picture_Hold
> >> >  picture_Release
> >> > diff --git a/src/misc/picture.c b/src/misc/picture.c
> >> > index 2762358049..c14e600d3f 100644
> >> > --- a/src/misc/picture.c
> >> > +++ b/src/misc/picture.c
> >> > @@ -374,6 +374,38 @@ void picture_Copy( picture_t *p_dst, const picture_t *p_src )
> >> >      picture_CopyProperties( p_dst, p_src );
> >> >  }
> >> >
> >> > +static void picture_DestroyClone(picture_t *clone)
> >> > +{
> >> > +    picture_t *picture = ((picture_priv_t *)clone)->gc.opaque;
> >> > +
> >> > +    free(clone);
> >> > +    picture_Release(picture);
> >> > +}
> >> > +
> >> > +picture_t *picture_Clone(picture_t *picture)
> >> > +{
> >> > +    /* TODO: merge common code with picture_pool_ClonePicture(). */
> >> > +    picture_resource_t res = {
> >> > +        .p_sys = picture->p_sys,
> >> > +        .pf_destroy = picture_DestroyClone,
> >> > +    };
> >> > +
> >> > +    for (int i = 0; i < picture->i_planes; i++) {
> >> > +        res.p[i].p_pixels = picture->p[i].p_pixels;
> >> > +        res.p[i].i_lines = picture->p[i].i_lines;
> >> > +        res.p[i].i_pitch = picture->p[i].i_pitch;
> >> > +    }
> >> > +
> >> > +    picture_t *clone = picture_NewFromResource(&picture->format, &res);
> >> > +    if (likely(clone != NULL)) {
> >> > +        ((picture_priv_t *)clone)->gc.opaque = picture;
> >> > +        picture_Hold(picture);
> >> > +
> >> > +        if (picture->context != NULL)
> >> > +            clone->context = picture->context->copy(picture->context);
> >> > +    }
> >> > +    return clone;
> >> > +}
> >> >
> >> >  /*****************************************************************************
> >> >   *
> >> > diff --git a/src/misc/picture_pool.c b/src/misc/picture_pool.c
> >> > index bb957c4af5..7b5a82bfba 100644
> >> > --- a/src/misc/picture_pool.c
> >> > +++ b/src/misc/picture_pool.c
> >> > @@ -299,6 +299,12 @@ void picture_pool_Cancel(picture_pool_t *pool, bool canceled)
> >> >  bool picture_pool_OwnsPic(picture_pool_t *pool, picture_t *pic)
> >> >  {
> >> >      picture_priv_t *priv = (picture_priv_t *)pic;
> >> > +
> >> > +    while (priv->gc.destroy != picture_pool_ReleasePicture) {
> >> > +        pic = priv->gc.opaque;
> >> > +        priv = (picture_priv_t *)pic;
> >> > +    }
> >> > +
> >> >      uintptr_t sys = (uintptr_t)priv->gc.opaque;
> >> >      picture_pool_t *picpool = (void *)(sys & ~(POOL_MAX - 1));
> >> >      return pool == picpool;
> >> >
> >> > _______________________________________________
> >> > vlc-commits mailing list
> >> > vlc-commits at videolan.org
> >> > https://mailman.videolan.org/listinfo/vlc-commits
> >> _______________________________________________
> >> vlc-devel mailing list
> >> To unsubscribe or modify your subscription options:
> >> https://mailman.videolan.org/listinfo/vlc-devel
> > _______________________________________________
> > vlc-devel mailing list
> > To unsubscribe or modify your subscription options:
> > https://mailman.videolan.org/listinfo/vlc-devel
> _______________________________________________
> 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