| 2343 | } |
| 2344 | |
| 2345 | av_cold int ff_vaapi_encode_close(AVCodecContext *avctx) |
| 2346 | { |
| 2347 | FFHWBaseEncodeContext *base_ctx = avctx->priv_data; |
| 2348 | VAAPIEncodeContext *ctx = avctx->priv_data; |
| 2349 | FFHWBaseEncodePicture *pic, *next; |
| 2350 | |
| 2351 | /* We check ctx->frame to know whether ff_vaapi_encode_init() |
| 2352 | * has been called and va_config/va_context initialized. */ |
| 2353 | if (!base_ctx->frame) |
| 2354 | return 0; |
| 2355 | |
| 2356 | for (pic = base_ctx->pic_start; pic; pic = next) { |
| 2357 | next = pic->next; |
| 2358 | vaapi_encode_free(avctx, pic); |
| 2359 | } |
| 2360 | |
| 2361 | av_refstruct_pool_uninit(&ctx->output_buffer_pool); |
| 2362 | |
| 2363 | if (ctx->va_context != VA_INVALID_ID) { |
| 2364 | if (ctx->hwctx) |
| 2365 | vaDestroyContext(ctx->hwctx->display, ctx->va_context); |
| 2366 | ctx->va_context = VA_INVALID_ID; |
| 2367 | } |
| 2368 | |
| 2369 | if (ctx->va_config != VA_INVALID_ID) { |
| 2370 | if (ctx->hwctx) |
| 2371 | vaDestroyConfig(ctx->hwctx->display, ctx->va_config); |
| 2372 | ctx->va_config = VA_INVALID_ID; |
| 2373 | } |
| 2374 | |
| 2375 | av_freep(&ctx->codec_sequence_params); |
| 2376 | av_freep(&ctx->codec_picture_params); |
| 2377 | |
| 2378 | ff_hw_base_encode_close(base_ctx); |
| 2379 | |
| 2380 | return 0; |
| 2381 | } |
no test coverage detected