MCPcopy Create free account
hub / github.com/FFmpeg/FFmpeg / av_hwframe_ctx_alloc

Function av_hwframe_ctx_alloc

libavutil/hwcontext.c:263–307  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

261}
262
263AVBufferRef *av_hwframe_ctx_alloc(AVBufferRef *device_ref_in)
264{
265 FFHWDeviceContext *device_ctx = (FFHWDeviceContext*)device_ref_in->data;
266 const HWContextType *hw_type = device_ctx->hw_type;
267 FFHWFramesContext *ctxi;
268 AVHWFramesContext *ctx;
269 AVBufferRef *buf, *device_ref = NULL;
270
271 ctxi = av_mallocz(sizeof(*ctxi));
272 if (!ctxi)
273 return NULL;
274 ctx = &ctxi->p;
275
276 if (hw_type->frames_hwctx_size) {
277 ctx->hwctx = av_mallocz(hw_type->frames_hwctx_size);
278 if (!ctx->hwctx)
279 goto fail;
280 }
281
282 device_ref = av_buffer_ref(device_ref_in);
283 if (!device_ref)
284 goto fail;
285
286 buf = av_buffer_create((uint8_t*)ctx, sizeof(*ctx),
287 hwframe_ctx_free, NULL,
288 AV_BUFFER_FLAG_READONLY);
289 if (!buf)
290 goto fail;
291
292 ctx->av_class = &hwframe_ctx_class;
293 ctx->device_ref = device_ref;
294 ctx->device_ctx = &device_ctx->p;
295 ctx->format = AV_PIX_FMT_NONE;
296 ctx->sw_format = AV_PIX_FMT_NONE;
297
298 ctxi->hw_type = hw_type;
299
300 return buf;
301
302fail:
303 av_buffer_unref(&device_ref);
304 av_freep(&ctx->hwctx);
305 av_freep(&ctx);
306 return NULL;
307}
308
309static int hwframe_pool_prealloc(AVBufferRef *ref)
310{

Callers 15

kmsgrab_read_headerFunction · 0.85
qsv_init_child_ctxFunction · 0.85
create_hw_frameFunction · 0.85
qsv_decode_preinitFunction · 0.85
amf_decode_initFunction · 0.85
rkmpp_retrieve_frameFunction · 0.85
qsv_frame_allocFunction · 0.85
vulkan_encode_create_dpbFunction · 0.85

Calls 5

av_buffer_refFunction · 0.85
av_buffer_createFunction · 0.85
av_buffer_unrefFunction · 0.85
av_freepFunction · 0.85
av_malloczFunction · 0.70

Tested by

no test coverage detected