| 286 | } |
| 287 | |
| 288 | static int nvdec_init_hwframes(AVCodecContext *avctx, AVBufferRef **out_frames_ref, int dummy) |
| 289 | { |
| 290 | AVHWFramesContext *frames_ctx; |
| 291 | int ret; |
| 292 | |
| 293 | ret = avcodec_get_hw_frames_parameters(avctx, |
| 294 | avctx->hw_device_ctx, |
| 295 | avctx->hwaccel->pix_fmt, |
| 296 | out_frames_ref); |
| 297 | if (ret < 0) |
| 298 | return ret; |
| 299 | |
| 300 | frames_ctx = (AVHWFramesContext*)(*out_frames_ref)->data; |
| 301 | |
| 302 | if (dummy) { |
| 303 | // Copied from ff_decode_get_hw_frames_ctx for compatibility |
| 304 | frames_ctx->initial_pool_size += 3; |
| 305 | |
| 306 | frames_ctx->free = nvdec_free_dummy; |
| 307 | frames_ctx->pool = av_buffer_pool_init(0, nvdec_alloc_dummy); |
| 308 | |
| 309 | if (!frames_ctx->pool) { |
| 310 | av_buffer_unref(out_frames_ref); |
| 311 | return AVERROR(ENOMEM); |
| 312 | } |
| 313 | } else { |
| 314 | // This is normally not used to actually allocate frames from |
| 315 | frames_ctx->initial_pool_size = 0; |
| 316 | } |
| 317 | |
| 318 | ret = av_hwframe_ctx_init(*out_frames_ref); |
| 319 | if (ret < 0) { |
| 320 | av_buffer_unref(out_frames_ref); |
| 321 | return ret; |
| 322 | } |
| 323 | |
| 324 | return 0; |
| 325 | } |
| 326 | |
| 327 | int ff_nvdec_decode_init(AVCodecContext *avctx) |
| 328 | { |
no test coverage detected