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

Function transfer_data_alloc

libavutil/hwcontext.c:398–446  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

396}
397
398static int transfer_data_alloc(AVFrame *dst, const AVFrame *src, int flags)
399{
400 AVHWFramesContext *ctx;
401 AVFrame *frame_tmp;
402 int ret = 0;
403
404 if (!src->hw_frames_ctx)
405 return AVERROR(EINVAL);
406 ctx = (AVHWFramesContext*)src->hw_frames_ctx->data;
407
408 frame_tmp = av_frame_alloc();
409 if (!frame_tmp)
410 return AVERROR(ENOMEM);
411
412 /* if the format is set, use that
413 * otherwise pick the first supported one */
414 if (dst->format >= 0) {
415 frame_tmp->format = dst->format;
416 } else {
417 enum AVPixelFormat *formats;
418
419 ret = av_hwframe_transfer_get_formats(src->hw_frames_ctx,
420 AV_HWFRAME_TRANSFER_DIRECTION_FROM,
421 &formats, 0);
422 if (ret < 0)
423 goto fail;
424 frame_tmp->format = formats[0];
425 av_freep(&formats);
426 }
427 frame_tmp->width = ctx->width;
428 frame_tmp->height = ctx->height;
429
430 ret = av_frame_get_buffer(frame_tmp, 0);
431 if (ret < 0)
432 goto fail;
433
434 ret = av_hwframe_transfer_data(frame_tmp, src, flags);
435 if (ret < 0)
436 goto fail;
437
438 frame_tmp->width = src->width;
439 frame_tmp->height = src->height;
440
441 av_frame_move_ref(dst, frame_tmp);
442
443fail:
444 av_frame_free(&frame_tmp);
445 return ret;
446}
447
448int av_hwframe_transfer_data(AVFrame *dst, const AVFrame *src, int flags)
449{

Callers 1

av_hwframe_transfer_dataFunction · 0.85

Calls 7

av_frame_allocFunction · 0.85
av_freepFunction · 0.85
av_frame_get_bufferFunction · 0.85
av_hwframe_transfer_dataFunction · 0.85
av_frame_move_refFunction · 0.85
av_frame_freeFunction · 0.85

Tested by

no test coverage detected