summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMark Thompson <sw@jkqxz.net>2016-06-12 17:28:28 +0100
committerMark Thompson <sw@jkqxz.net>2016-07-02 14:09:58 +0100
commit221ffca6314ed3ba9d38464ea50cd85251c04e74 (patch)
treeb696f5f12e5f00c8473efe7c699b2845ea605442
parent4926fa9a4aa03f3b751f52e900b9efb87fea0591 (diff)
downloadffmpeg-streaming-221ffca6314ed3ba9d38464ea50cd85251c04e74.zip
ffmpeg-streaming-221ffca6314ed3ba9d38464ea50cd85251c04e74.tar.gz
vaapi_encode: Respect driver quirks around buffer destruction
No longer leaks memory when used with a driver with the "render does not destroy param buffers" quirk (i.e. Intel i965).
-rw-r--r--libavcodec/vaapi_encode.c22
1 files changed, 21 insertions, 1 deletions
diff --git a/libavcodec/vaapi_encode.c b/libavcodec/vaapi_encode.c
index 7d56145..cdda485 100644
--- a/libavcodec/vaapi_encode.c
+++ b/libavcodec/vaapi_encode.c
@@ -385,7 +385,27 @@ static int vaapi_encode_issue(AVCodecContext *avctx,
av_log(avctx, AV_LOG_ERROR, "Failed to end picture encode issue: "
"%d (%s).\n", vas, vaErrorStr(vas));
err = AVERROR(EIO);
- goto fail_at_end;
+ // vaRenderPicture() has been called here, so we should not destroy
+ // the parameter buffers unless separate destruction is required.
+ if (ctx->hwctx->driver_quirks &
+ AV_VAAPI_DRIVER_QUIRK_RENDER_PARAM_BUFFERS)
+ goto fail;
+ else
+ goto fail_at_end;
+ }
+
+ if (ctx->hwctx->driver_quirks &
+ AV_VAAPI_DRIVER_QUIRK_RENDER_PARAM_BUFFERS) {
+ for (i = 0; i < pic->nb_param_buffers; i++) {
+ vas = vaDestroyBuffer(ctx->hwctx->display,
+ pic->param_buffers[i]);
+ if (vas != VA_STATUS_SUCCESS) {
+ av_log(avctx, AV_LOG_ERROR, "Failed to destroy "
+ "param buffer %#x: %d (%s).\n",
+ pic->param_buffers[i], vas, vaErrorStr(vas));
+ // And ignore.
+ }
+ }
}
pic->encode_issued = 1;
OpenPOWER on IntegriCloud