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).
This commit is contained in:
parent
4926fa9a4a
commit
221ffca631
1 changed files with 21 additions and 1 deletions
|
@ -385,9 +385,29 @@ static int vaapi_encode_issue(AVCodecContext *avctx,
|
||||||
av_log(avctx, AV_LOG_ERROR, "Failed to end picture encode issue: "
|
av_log(avctx, AV_LOG_ERROR, "Failed to end picture encode issue: "
|
||||||
"%d (%s).\n", vas, vaErrorStr(vas));
|
"%d (%s).\n", vas, vaErrorStr(vas));
|
||||||
err = AVERROR(EIO);
|
err = AVERROR(EIO);
|
||||||
|
// 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;
|
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;
|
pic->encode_issued = 1;
|
||||||
|
|
||||||
if (ctx->issue_mode == ISSUE_MODE_SERIALISE_EVERYTHING)
|
if (ctx->issue_mode == ISSUE_MODE_SERIALISE_EVERYTHING)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue