Even though libmfx might not need them anymore, avcodec might still
access the surfaces. So free them separately at the end.
---
doc/examples/qsvdec.c | 21 ++++++++++++---------
1 file changed, 12 insertions(+), 9 deletions(-)
diff --git a/doc/examples/qsvdec.c b/doc/examples/qsvdec.c
index 04e5b5f..2f26f41 100644
--- a/doc/examples/qsvdec.c
+++ b/doc/examples/qsvdec.c
@@ -116,15 +116,6 @@ fail:
static mfxStatus frame_free(mfxHDL pthis, mfxFrameAllocResponse *resp)
{
- DecodeContext *decode = pthis;
-
- if (decode->surfaces)
- vaDestroySurfaces(decode->va_dpy, decode->surfaces,
decode->nb_surfaces);
- av_freep(&decode->surfaces);
- av_freep(&decode->surface_ids);
- av_freep(&decode->surface_used);
- decode->nb_surfaces = 0;
-
return MFX_ERR_NONE;
}
@@ -144,6 +135,16 @@ static mfxStatus frame_get_hdl(mfxHDL pthis, mfxMemId mid,
mfxHDL *hdl)
return MFX_ERR_NONE;
}
+static void free_surfaces(DecodeContext *decode)
+{
+ if (decode->surfaces)
+ vaDestroySurfaces(decode->va_dpy, decode->surfaces,
decode->nb_surfaces);
+ av_freep(&decode->surfaces);
+ av_freep(&decode->surface_ids);
+ av_freep(&decode->surface_used);
+ decode->nb_surfaces = 0;
+}
+
static void free_buffer(void *opaque, uint8_t *data)
{
int *used = opaque;
@@ -467,6 +468,8 @@ finish:
av_frame_free(&frame);
+ free_surfaces(&decode);
+
if (decode.mfx_session)
MFXClose(decode.mfx_session);
if (decode.va_dpy)
--
2.0.0
_______________________________________________
libav-devel mailing list
[email protected]
https://lists.libav.org/mailman/listinfo/libav-devel