| 307 | } |
| 308 | |
| 309 | static int hwframe_pool_prealloc(AVBufferRef *ref) |
| 310 | { |
| 311 | AVHWFramesContext *ctx = (AVHWFramesContext*)ref->data; |
| 312 | AVFrame **frames; |
| 313 | int i, ret = 0; |
| 314 | |
| 315 | frames = av_calloc(ctx->initial_pool_size, sizeof(*frames)); |
| 316 | if (!frames) |
| 317 | return AVERROR(ENOMEM); |
| 318 | |
| 319 | for (i = 0; i < ctx->initial_pool_size; i++) { |
| 320 | frames[i] = av_frame_alloc(); |
| 321 | if (!frames[i]) |
| 322 | goto fail; |
| 323 | |
| 324 | ret = av_hwframe_get_buffer(ref, frames[i], 0); |
| 325 | if (ret < 0) |
| 326 | goto fail; |
| 327 | } |
| 328 | |
| 329 | fail: |
| 330 | for (i = 0; i < ctx->initial_pool_size; i++) |
| 331 | av_frame_free(&frames[i]); |
| 332 | av_freep(&frames); |
| 333 | |
| 334 | return ret; |
| 335 | } |
| 336 | |
| 337 | int av_hwframe_ctx_init(AVBufferRef *ref) |
| 338 | { |
no test coverage detected