<html><head></head><body>Hi,<br><br>The macro is not expansion-safe, and IMO it could and should be.<br><br><div class="gmail_quote">Le 15 novembre 2019 15:51:03 GMT+01:00, Steve Lhomme <robux4@ycbcr.xyz> a écrit :<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
<pre class="k9mail">The creator of the picture_context_t must set the video context if needed.<br>If set, the picture context must hold a reference to the video context.<br><br>When "copying" a picture (using the same surface in another picture context) a<br>new reference has to be acquired.<br><br>Also add a macro to get the video context from a picture as the picture context<br>may be NULL.<hr> include/vlc_picture.h | 4 ++++<br> modules/codec/avcodec/d3d11va.c | 1 +<br> modules/codec/avcodec/dxva2.c | 1 +<br> modules/codec/avcodec/vaapi.c | 1 +<br> modules/hw/d3d11/d3d11_deinterlace.c | 1 +<br> modules/hw/d3d11/d3d11_surface.c | 1 +<br> modules/hw/d3d9/dxa9.c | 1 +<br> modules/hw/d3d9/dxva2_deinterlace.c | 1 +<br> src/misc/picture.c | 11 +++++++++++<br> 9 files changed, 22 insertions(+)<br><br>diff --git a/include/vlc_picture.h b/include/vlc_picture.h<br>index 3298630e02a..4bc2e63d88e 100644<br>--- a/include/vlc_picture.h<br>+++ b/include/vlc_picture.h<br>@@ -69,6 +69,7 @@ typedef struct picture_context_t<br> {<br> void (*destroy)(struct picture_context_t *);<br> struct picture_context_t *(*copy)(struct picture_context_t *);<br>+ struct vlc_video_context *vctx;<br> } picture_context_t;<br> <br> typedef struct picture_buffer_t<br>@@ -161,6 +162,9 @@ struct picture_t<br> atomic_uintptr_t refs;<br> };<br> <br>+#define picture_GetVideoContext(pic) \<br>+ ((pic)->context ? (pic)->context->vctx : NULL)<br>+<br> /**<br> * This function will create a new picture.<br> * The picture created will implement a default release management compatible<br>diff --git a/modules/codec/avcodec/d3d11va.c b/modules/codec/avcodec/d3d11va.c<br>index a15830c7f29..174e2d0d40c 100644<br>--- a/modules/codec/avcodec/d3d11va.c<br>+++ b/modules/codec/avcodec/d3d11va.c<br>@@ -177,6 +177,7 @@ static struct d3d11va_pic_context *CreatePicContext(<br> return NULL;<br> pic_ctx->ctx.s = (picture_context_t) {<br> d3d11va_pic_context_destroy, d3d11va_pic_context_copy,<br>+ NULL /*TODO*/<br> };<br> <br> D3D11_TEXTURE2D_DESC txDesc;<br>diff --git a/modules/codec/avcodec/dxva2.c b/modules/codec/avcodec/dxva2.c<br>index 3caa648a315..62b14476e43 100644<br>--- a/modules/codec/avcodec/dxva2.c<br>+++ b/modules/codec/avcodec/dxva2.c<br>@@ -190,6 +190,7 @@ static struct dxva2_pic_context *CreatePicContext(IDirect3DSurface9 *surface)<br> return NULL;<br> pic_ctx->ctx.s = (picture_context_t) {<br> dxva2_pic_context_destroy, dxva2_pic_context_copy,<br>+ NULL /*TODO*/<br> };<br> pic_ctx->ctx.picsys.surface = surface;<br> AcquireD3D9PictureSys(&pic_ctx->ctx.picsys);<br>diff --git a/modules/codec/avcodec/vaapi.c b/modules/codec/avcodec/vaapi.c<br>index daec9b4b4e7..110a6492d2d 100644<br>--- a/modules/codec/avcodec/vaapi.c<br>+++ b/modules/codec/avcodec/vaapi.c<br>@@ -163,6 +163,7 @@ static int Get(vlc_va_t *va, picture_t *pic, uint8_t **data)<br> }<br> vaapi_ctx->ctx.s = (picture_context_t) {<br> vaapi_dec_pic_context_destroy, vaapi_dec_pic_context_copy,<br>+ NULL /*TODO*/<br> };<br> vaapi_ctx->ctx.surface = sys->render_targets[va_surface_GetIndex(va_surface)];<br> vaapi_ctx->ctx.va_dpy = sys->hw_ctx.display;<br>diff --git a/modules/hw/d3d11/d3d11_deinterlace.c b/modules/hw/d3d11/d3d11_deinterlace.c<br>index 90215efbd70..5c58632e59e 100644<br>--- a/modules/hw/d3d11/d3d11_deinterlace.c<br>+++ b/modules/hw/d3d11/d3d11_deinterlace.c<br>@@ -266,6 +266,7 @@ picture_t *AllocPicture( filter_t *p_filter )<br> {<br> pic_ctx->s = (picture_context_t) {<br> d3d11_pic_context_destroy, d3d11_pic_context_copy,<br>+ NULL /*TODO*/<br> };<br> pic_ctx->picsys = *pic_sys;<br> AcquireD3D11PictureSys( &pic_ctx->picsys );<br>diff --git a/modules/hw/d3d11/d3d11_surface.c b/modules/hw/d3d11/d3d11_surface.c<br>index 3989a0a37bf..93ce6377a27 100644<br>--- a/modules/hw/d3d11/d3d11_surface.c<br>+++ b/modules/hw/d3d11/d3d11_surface.c<br>@@ -578,6 +578,7 @@ static void NV12_D3D11(filter_t *p_filter, picture_t *src, picture_t *dst)<br> {<br> pic_ctx->s = (picture_context_t) {<br> d3d11_pic_context_destroy, d3d11_pic_context_copy,<br>+ NULL /*TODO*/<br> };<br> pic_ctx->picsys = *p_sys;<br> AcquireD3D11PictureSys(&pic_ctx->picsys);<br>diff --git a/modules/hw/d3d9/dxa9.c b/modules/hw/d3d9/dxa9.c<br>index 0f5700b9e87..4f1ea9708bb 100644<br>--- a/modules/hw/d3d9/dxa9.c<br>+++ b/modules/hw/d3d9/dxa9.c<br>@@ -265,6 +265,7 @@ static void YV12_D3D9(filter_t *p_filter, picture_t *src, picture_t *dst)<br> {<br> pic_ctx->s = (picture_context_t) {<br> d3d9_pic_context_destroy, d3d9_pic_context_copy,<br>+ NULL /*TODO*/<br> };<br> pic_ctx->picsys = *p_sys;<br> AcquireD3D9PictureSys(&pic_ctx->picsys);<br>diff --git a/modules/hw/d3d9/dxva2_deinterlace.c b/modules/hw/d3d9/dxva2_deinterlace.c<br>index 2564752818e..48b59a23369 100644<br>--- a/modules/hw/d3d9/dxva2_deinterlace.c<br>+++ b/modules/hw/d3d9/dxva2_deinterlace.c<br>@@ -326,6 +326,7 @@ picture_t *AllocPicture( filter_t *p_filter )<br> {<br> pic_ctx->s = (picture_context_t) {<br> d3d9_pic_context_destroy, d3d9_pic_context_copy,<br>+ NULL /*TODO*/<br> };<br> pic_ctx->picsys = *pic_sys;<br> AcquireD3D9PictureSys( &pic_ctx->picsys );<br>diff --git a/src/misc/picture.c b/src/misc/picture.c<br>index cdde6f9951a..c128c804055 100644<br>--- a/src/misc/picture.c<br>+++ b/src/misc/picture.c<br>@@ -43,7 +43,10 @@ static void PictureDestroyContext( picture_t *p_picture )<br> picture_context_t *ctx = p_picture->context;<br> if (ctx != NULL)<br> {<br>+ vlc_video_context *vctx = ctx->vctx;<br> ctx->destroy(ctx);<br>+ if (vctx)<br>+ vlc_video_context_Release(vctx);<br> p_picture->context = NULL;<br> }<br> }<br>@@ -389,7 +392,11 @@ void picture_CopyPixels( picture_t *p_dst, const picture_t *p_src )<br> assert( p_dst->context == NULL );<br> <br> if( p_src->context != NULL )<br>+ {<br> p_dst->context = p_src->context->copy( p_src->context );<br>+ if ( p_dst->context != NULL && p_dst->context->vctx != NULL )<br>+ vlc_video_context_Hold( p_dst->context->vctx );<br>+ }<br> }<br> <br> void picture_Copy( picture_t *p_dst, const picture_t *p_src )<br>@@ -425,7 +432,11 @@ picture_t *picture_Clone(picture_t *picture)<br> picture_Hold(picture);<br> <br> if (picture->context != NULL)<br>+ {<br> clone->context = picture->context->copy(picture->context);<br>+ if ( clone->context != NULL && clone->context->vctx != NULL )<br>+ vlc_video_context_Hold( clone->context->vctx );<br>+ }<br> }<br> return clone;<br> }</pre></blockquote></div><br>-- <br>Envoyé de mon appareil Android avec Courriel K-9 Mail. Veuillez excuser ma brièveté.</body></html>