[vlc-commits] picture: add the video context in the picture context
Steve Lhomme
git at videolan.org
Mon Dec 2 13:42:39 CET 2019
vlc | branch: master | Steve Lhomme <robux4 at ycbcr.xyz> | Wed Nov 13 08:45:49 2019 +0100| [27b6be39b64d102f81477b44ff907e5c2cdd3a13] | committer: Steve Lhomme
picture: add the video context in the picture context
The creator of the picture_context_t must set the video context if needed.
If set, the picture context must hold a reference to the video context.
When "copying" a picture (using the same surface in another picture context) a
new reference has to be acquired.
Add an inline function to get the video context from a picture.
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=27b6be39b64d102f81477b44ff907e5c2cdd3a13
---
include/vlc_picture.h | 6 ++++++
modules/codec/avcodec/d3d11va.c | 1 +
modules/codec/avcodec/dxva2.c | 1 +
modules/codec/avcodec/vaapi.c | 1 +
modules/codec/vt_utils.c | 1 +
modules/hw/d3d11/d3d11_deinterlace.c | 1 +
modules/hw/d3d11/d3d11_surface.c | 1 +
modules/hw/d3d9/dxa9.c | 1 +
modules/hw/d3d9/dxva2_deinterlace.c | 1 +
modules/hw/nvdec/nvdec.c | 1 +
modules/hw/vaapi/vlc_vaapi.c | 1 +
modules/hw/vdpau/picture.c | 1 +
src/misc/picture.c | 3 +++
13 files changed, 20 insertions(+)
diff --git a/include/vlc_picture.h b/include/vlc_picture.h
index 3298630e02..75a87c8a81 100644
--- a/include/vlc_picture.h
+++ b/include/vlc_picture.h
@@ -69,6 +69,7 @@ typedef struct picture_context_t
{
void (*destroy)(struct picture_context_t *);
struct picture_context_t *(*copy)(struct picture_context_t *);
+ struct vlc_video_context *vctx;
} picture_context_t;
typedef struct picture_buffer_t
@@ -161,6 +162,11 @@ struct picture_t
atomic_uintptr_t refs;
};
+static inline vlc_video_context* picture_GetVideoContext(picture_t *pic)
+{
+ return pic->context ? pic->context->vctx : NULL;
+}
+
/**
* This function will create a new picture.
* The picture created will implement a default release management compatible
diff --git a/modules/codec/avcodec/d3d11va.c b/modules/codec/avcodec/d3d11va.c
index d4319df743..7f2c8e88ad 100644
--- a/modules/codec/avcodec/d3d11va.c
+++ b/modules/codec/avcodec/d3d11va.c
@@ -177,6 +177,7 @@ static struct d3d11va_pic_context *CreatePicContext(
return NULL;
pic_ctx->ctx.s = (picture_context_t) {
d3d11va_pic_context_destroy, d3d11va_pic_context_copy,
+ NULL /*TODO*/
};
D3D11_TEXTURE2D_DESC txDesc;
diff --git a/modules/codec/avcodec/dxva2.c b/modules/codec/avcodec/dxva2.c
index 7b42d6a663..a3c708e4ff 100644
--- a/modules/codec/avcodec/dxva2.c
+++ b/modules/codec/avcodec/dxva2.c
@@ -187,6 +187,7 @@ static struct dxva2_pic_context *CreatePicContext(IDirect3DSurface9 *surface)
return NULL;
pic_ctx->ctx.s = (picture_context_t) {
dxva2_pic_context_destroy, dxva2_pic_context_copy,
+ NULL /*TODO*/
};
pic_ctx->ctx.picsys.surface = surface;
AcquireD3D9PictureSys(&pic_ctx->ctx.picsys);
diff --git a/modules/codec/avcodec/vaapi.c b/modules/codec/avcodec/vaapi.c
index 36cb5a1487..5a5c86cff9 100644
--- a/modules/codec/avcodec/vaapi.c
+++ b/modules/codec/avcodec/vaapi.c
@@ -163,6 +163,7 @@ static int Get(vlc_va_t *va, picture_t *pic, uint8_t **data)
}
vaapi_ctx->ctx.s = (picture_context_t) {
vaapi_dec_pic_context_destroy, vaapi_dec_pic_context_copy,
+ NULL /*TODO*/
};
vaapi_ctx->ctx.surface = sys->render_targets[va_surface_GetIndex(va_surface)];
vaapi_ctx->ctx.va_dpy = sys->hw_ctx.display;
diff --git a/modules/codec/vt_utils.c b/modules/codec/vt_utils.c
index cb71dae139..cac1389199 100644
--- a/modules/codec/vt_utils.c
+++ b/modules/codec/vt_utils.c
@@ -89,6 +89,7 @@ cvpxpic_attach_common(picture_t *p_pic, CVPixelBufferRef cvpx,
}
ctx->s = (picture_context_t) {
pf_destroy, cvpxpic_copy_cb,
+ NULL // no video context for now
};
ctx->cvpx = CVPixelBufferRetain(cvpx);
ctx->nb_fields = p_pic->i_nb_fields;
diff --git a/modules/hw/d3d11/d3d11_deinterlace.c b/modules/hw/d3d11/d3d11_deinterlace.c
index 90215efbd7..5c58632e59 100644
--- a/modules/hw/d3d11/d3d11_deinterlace.c
+++ b/modules/hw/d3d11/d3d11_deinterlace.c
@@ -266,6 +266,7 @@ picture_t *AllocPicture( filter_t *p_filter )
{
pic_ctx->s = (picture_context_t) {
d3d11_pic_context_destroy, d3d11_pic_context_copy,
+ NULL /*TODO*/
};
pic_ctx->picsys = *pic_sys;
AcquireD3D11PictureSys( &pic_ctx->picsys );
diff --git a/modules/hw/d3d11/d3d11_surface.c b/modules/hw/d3d11/d3d11_surface.c
index 9f0a71e60b..8b24f34bdf 100644
--- a/modules/hw/d3d11/d3d11_surface.c
+++ b/modules/hw/d3d11/d3d11_surface.c
@@ -585,6 +585,7 @@ static void NV12_D3D11(filter_t *p_filter, picture_t *src, picture_t *dst)
{
pic_ctx->s = (picture_context_t) {
d3d11_pic_context_destroy, d3d11_pic_context_copy,
+ NULL /*TODO*/
};
pic_ctx->picsys = *p_sys;
AcquireD3D11PictureSys(&pic_ctx->picsys);
diff --git a/modules/hw/d3d9/dxa9.c b/modules/hw/d3d9/dxa9.c
index cd1619be40..2ff00276bb 100644
--- a/modules/hw/d3d9/dxa9.c
+++ b/modules/hw/d3d9/dxa9.c
@@ -272,6 +272,7 @@ static void YV12_D3D9(filter_t *p_filter, picture_t *src, picture_t *dst)
{
pic_ctx->s = (picture_context_t) {
d3d9_pic_context_destroy, d3d9_pic_context_copy,
+ NULL /*TODO*/
};
pic_ctx->picsys = *p_sys;
AcquireD3D9PictureSys(&pic_ctx->picsys);
diff --git a/modules/hw/d3d9/dxva2_deinterlace.c b/modules/hw/d3d9/dxva2_deinterlace.c
index 2564752818..48b59a2336 100644
--- a/modules/hw/d3d9/dxva2_deinterlace.c
+++ b/modules/hw/d3d9/dxva2_deinterlace.c
@@ -326,6 +326,7 @@ picture_t *AllocPicture( filter_t *p_filter )
{
pic_ctx->s = (picture_context_t) {
d3d9_pic_context_destroy, d3d9_pic_context_copy,
+ NULL /*TODO*/
};
pic_ctx->picsys = *pic_sys;
AcquireD3D9PictureSys( &pic_ctx->picsys );
diff --git a/modules/hw/nvdec/nvdec.c b/modules/hw/nvdec/nvdec.c
index e82338dcd4..3b22088d94 100644
--- a/modules/hw/nvdec/nvdec.c
+++ b/modules/hw/nvdec/nvdec.c
@@ -372,6 +372,7 @@ static int CUDAAPI HandlePictureDisplay(void *p_opaque, CUVIDPARSERDISPINFO *p_d
goto error;
picctx->ctx = (picture_context_t) {
NVDecCtxDestroy, NVDecCtxClone,
+ NULL /*TODO*/
};
uintptr_t pool_idx = (uintptr_t)p_pic->p_sys;
picctx->devidePtr = p_sys->outputDevicePtr[pool_idx];
diff --git a/modules/hw/vaapi/vlc_vaapi.c b/modules/hw/vaapi/vlc_vaapi.c
index 4c4a30d9b3..a871085967 100644
--- a/modules/hw/vaapi/vlc_vaapi.c
+++ b/modules/hw/vaapi/vlc_vaapi.c
@@ -509,6 +509,7 @@ vlc_vaapi_PoolNew(vlc_object_t *o, vlc_decoder_device *dec_device,
p_sys->instance = instance;
p_sys->ctx.ctx.s = (picture_context_t) {
pic_sys_ctx_destroy_cb, pic_ctx_copy_cb,
+ NULL /*TODO*/
};
p_sys->ctx.ctx.surface = instance->render_targets[i];
p_sys->ctx.ctx.va_dpy = dpy;
diff --git a/modules/hw/vdpau/picture.c b/modules/hw/vdpau/picture.c
index d834d0303a..e50a3f3e47 100644
--- a/modules/hw/vdpau/picture.c
+++ b/modules/hw/vdpau/picture.c
@@ -96,6 +96,7 @@ vlc_vdp_video_field_t *vlc_vdp_video_create(vdp_t *vdp,
field->context = (picture_context_t) {
VideoSurfaceDestroy, VideoSurfaceCopy,
+ NULL /*TODO*/
};
field->frame = frame;
field->structure = VDP_VIDEO_MIXER_PICTURE_STRUCTURE_FRAME;
diff --git a/src/misc/picture.c b/src/misc/picture.c
index 3288aa6514..990277ef15 100644
--- a/src/misc/picture.c
+++ b/src/misc/picture.c
@@ -43,7 +43,10 @@ static void PictureDestroyContext( picture_t *p_picture )
picture_context_t *ctx = p_picture->context;
if (ctx != NULL)
{
+ vlc_video_context *vctx = ctx->vctx;
ctx->destroy(ctx);
+ if (vctx)
+ vlc_video_context_Release(vctx);
p_picture->context = NULL;
}
}
More information about the vlc-commits
mailing list