No longer leaks memory when used with a driver with the "render does
not destroy param buffers" quirk (i.e. Intel i965).
(cherry picked from commit 221ffca6314ed3ba9d38464ea50cd85251c04e74)
Fixes ticket #5871.
... | ... |
@@ -385,7 +385,27 @@ static int vaapi_encode_issue(AVCodecContext *avctx, |
385 | 385 |
av_log(avctx, AV_LOG_ERROR, "Failed to end picture encode issue: " |
386 | 386 |
"%d (%s).\n", vas, vaErrorStr(vas)); |
387 | 387 |
err = AVERROR(EIO); |
388 |
- goto fail_at_end; |
|
388 |
+ // vaRenderPicture() has been called here, so we should not destroy |
|
389 |
+ // the parameter buffers unless separate destruction is required. |
|
390 |
+ if (ctx->hwctx->driver_quirks & |
|
391 |
+ AV_VAAPI_DRIVER_QUIRK_RENDER_PARAM_BUFFERS) |
|
392 |
+ goto fail; |
|
393 |
+ else |
|
394 |
+ goto fail_at_end; |
|
395 |
+ } |
|
396 |
+ |
|
397 |
+ if (ctx->hwctx->driver_quirks & |
|
398 |
+ AV_VAAPI_DRIVER_QUIRK_RENDER_PARAM_BUFFERS) { |
|
399 |
+ for (i = 0; i < pic->nb_param_buffers; i++) { |
|
400 |
+ vas = vaDestroyBuffer(ctx->hwctx->display, |
|
401 |
+ pic->param_buffers[i]); |
|
402 |
+ if (vas != VA_STATUS_SUCCESS) { |
|
403 |
+ av_log(avctx, AV_LOG_ERROR, "Failed to destroy " |
|
404 |
+ "param buffer %#x: %d (%s).\n", |
|
405 |
+ pic->param_buffers[i], vas, vaErrorStr(vas)); |
|
406 |
+ // And ignore. |
|
407 |
+ } |
|
408 |
+ } |
|
389 | 409 |
} |
390 | 410 |
|
391 | 411 |
pic->encode_issued = 1; |