[vlc-devel] [PATCH 03/34] video context: add a function to test if 2 context are similar
Steve Lhomme
robux4 at ycbcr.xyz
Tue Nov 12 16:06:46 CET 2019
On 2019-11-12 11:23, Rémi Denis-Courmont wrote:
> VDPAU buffers are tied to a VDPAU device instance. You cannot use them
> across different VLC video contexts. I doubt you can do that with NVDEC
> either.
>
> It might be possible with DRM or maybe not, but even then I doubt that
> the similarity callback can actually be implemented...
>
> So I don't really see the point over a straight pointer equality test.
A video context created from a decoder device is likely to be compatible
with another video context created from the same decoder device. This
works in NVDEC and in D3D11. Decoder devices can probably check for
equality with just a pointer.
Given we are in push a format change might restart the hardware decoder
which push a new video context created from scratch. If it's
similar/compatible with the previous one that was pushed there's no need
to restart everything downstream, even though they are not the same pointer.
> Le 12 novembre 2019 09:32:13 GMT+02:00, Steve Lhomme <robux4 at ycbcr.xyz>
> a écrit :
>
> On 2019-11-09 3:52, Rémi Denis-Courmont wrote:
>
> Le vendredi 8 novembre 2019, 16:40:07 EET Steve Lhomme a écrit :
>
> If they are not similar a converter from one to the other
> should be used.
>
> What is the definition of similar ? For non-serial objects, the
> idea seems
> rather fishy.
>
>
> "Video Context are similar when they can use surfaces from one another."
>
> This is used in places where the video_format_IsSimilar() is used. A
> hardware decoder may push the same video format (same opaque chroma) but
> using a different video context. In some cases (NVDEC/CUDA for example)
> the new video context can be used without reconfiguring anything. In
> some other cases they might not be (DXVA2 after a device reset has been
> received).
>
> A NULL callback is allowed, in which case only the type of
> the video context
> is checked.
> ------------------------------------------------------------------------
> include/vlc_picture.h | 11 +++++++++++
> modules/hw/vdpau/avcodec.c | 2 +-
> modules/video_chroma/d3d11_fmt.c | 2 +-
> modules/video_chroma/d3d9_fmt.c | 2 +-
> src/input/decoder_helpers.c | 16 ++++++++++++++++
> src/libvlccore.sym | 1 +
> 6 files changed, 31 insertions(+), 3 deletions(-)
>
> diff --git a/include/vlc_picture.h b/include/vlc_picture.h
> index a5931ef67af..c9bf28a9ed8 100644
> --- a/include/vlc_picture.h
> +++ b/include/vlc_picture.h
> @@ -85,6 +85,11 @@ typedef struct vlc_video_context
> vlc_video_context;
> struct vlc_video_context_operations
> {
> void (*destroy)(void *priv);
> + /**
> + * Check if two video context of the same type are similar.
> + * The callback can be NULL.
> + */
> + bool (*similar)(const vlc_video_context*, const
> vlc_video_context*);
> };
>
> /** Decoder device type */
> @@ -110,6 +115,12 @@ VLC_API void
> vlc_video_context_Release(vlc_video_context *); VLC_API enum
> vlc_video_context_type vlc_video_context_GetType(const
> vlc_video_context
> *); VLC_API void
> *vlc_video_context_GetPrivate(vlc_video_context *, enum
> vlc_video_context_type); VLC_API vlc_video_context
> *vlc_video_context_Hold(vlc_video_context *); +/**
> + * Test if two video context are similar/compatible.
> + *
> + * Video Context are similar when they can use surfaces
> from one another.
> + */
> +VLC_API bool vlc_video_context_IsSimilar(const
> vlc_video_context *, const
> vlc_video_context *);
>
> /**
> * Get the decoder device used by the device context.
> diff --git a/modules/hw/vdpau/avcodec.c
> b/modules/hw/vdpau/avcodec.c
> index 74aa135f70c..6f9a75fd803 100644
> --- a/modules/hw/vdpau/avcodec.c
> +++ b/modules/hw/vdpau/avcodec.c
> @@ -153,7 +153,7 @@ static void
> DestroyVDPAUVideoContext(void *private)
> }
>
> const struct vlc_video_context_operations vdpau_vctx_ops = {
> - DestroyVDPAUVideoContext,
> + DestroyVDPAUVideoContext, NULL // TODO
> };
>
> static int Open(vlc_va_t *va, AVCodecContext *avctx, const
> AVPixFmtDescriptor *desc, diff --git
> a/modules/video_chroma/d3d11_fmt.c
> b/modules/video_chroma/d3d11_fmt.c index
> 77156f509bb..edb39244a33 100644
> --- a/modules/video_chroma/d3d11_fmt.c
> +++ b/modules/video_chroma/d3d11_fmt.c
> @@ -771,7 +771,7 @@ static void
> ReleaseD3D11ContextPrivate(void *private)
> }
>
> const struct vlc_video_context_operations d3d11_vctx_ops = {
> - ReleaseD3D11ContextPrivate,
> + ReleaseD3D11ContextPrivate, NULL // TODO
> };
>
> void d3d11_pic_context_destroy(picture_context_t *ctx)
> diff --git a/modules/video_chroma/d3d9_fmt.c
> b/modules/video_chroma/d3d9_fmt.c index
> 508bfc838f8..3a53484908e 100644
> --- a/modules/video_chroma/d3d9_fmt.c
> +++ b/modules/video_chroma/d3d9_fmt.c
> @@ -293,7 +293,7 @@ static void
> ReleaseD3D9ContextPrivate(void *private)
> }
>
> const struct vlc_video_context_operations d3d9_vctx_ops = {
> - ReleaseD3D9ContextPrivate,
> + ReleaseD3D9ContextPrivate, NULL // TODO
> };
>
> void d3d9_pic_context_destroy(picture_context_t *ctx)
> diff --git a/src/input/decoder_helpers.c
> b/src/input/decoder_helpers.c
> index 3ff71f49c23..e4b8f2797b6 100644
> --- a/src/input/decoder_helpers.c
> +++ b/src/input/decoder_helpers.c
> @@ -294,3 +294,19 @@ vlc_decoder_device*
> vlc_video_context_HoldDevice(vlc_video_context *vctx) return
> NULL;
> return vlc_decoder_device_Hold( vctx->device );
> }
> +
> +bool vlc_video_context_IsSimilar(const vlc_video_context
> *a, const
> vlc_video_context *b) +{
> + if (!a && !b)
> + return true;
> + if (!a || !b)
> + return false;
>
> if (a == NULL || b == NULL)
> return a == b;
>
> + if (a->private_type != b->private_type)
> + return false;
> + if (a->ops == NULL)
> + {
> + assert(b->ops == NULL);
> + return b->ops == NULL;
> + }
> + return a->ops->similar == NULL || a->ops->similar(a, b);
> +}
> diff --git a/src/libvlccore.sym b/src/libvlccore.sym
> index 7dce1c2c25b..3ea59614722 100644
> --- a/src/libvlccore.sym
> +++ b/src/libvlccore.sym
> @@ -952,3 +952,4 @@ vlc_video_context_GetType
> vlc_video_context_GetPrivate
> vlc_video_context_Hold
> vlc_video_context_HoldDevice
> +vlc_video_context_IsSimilar
>
>
> --
> Rémi Denis-Courmont
> ------------------------------------------------------------------------
> 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
>
>
> --
> Envoyé de mon appareil Android avec Courriel K-9 Mail. Veuillez excuser
> ma brièveté.
>
> _______________________________________________
> 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