[vlc-devel] [PATCH 03/34] video context: add a function to test if 2 context are similar
Steve Lhomme
robux4 at ycbcr.xyz
Fri Nov 8 15:40:07 CET 2019
If they are not similar a converter from one to the other should be used.
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->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
--
2.17.1
More information about the vlc-devel
mailing list