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

Function av_hwframe_get_buffer

libavutil/hwcontext.c:506–568  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

504}
505
506int av_hwframe_get_buffer(AVBufferRef *hwframe_ref, AVFrame *frame, int flags)
507{
508 FFHWFramesContext *ctxi = (FFHWFramesContext*)hwframe_ref->data;
509 AVHWFramesContext *ctx = &ctxi->p;
510 int ret;
511
512 if (ctxi->source_frames) {
513 // This is a derived frame context, so we allocate in the source
514 // and map the frame immediately.
515 AVFrame *src_frame;
516
517 frame->format = ctx->format;
518 frame->hw_frames_ctx = av_buffer_ref(hwframe_ref);
519 if (!frame->hw_frames_ctx)
520 return AVERROR(ENOMEM);
521
522 src_frame = av_frame_alloc();
523 if (!src_frame)
524 return AVERROR(ENOMEM);
525
526 ret = av_hwframe_get_buffer(ctxi->source_frames,
527 src_frame, 0);
528 if (ret < 0) {
529 av_frame_free(&src_frame);
530 return ret;
531 }
532
533 ret = av_hwframe_map(frame, src_frame,
534 ctxi->source_allocation_map_flags);
535 if (ret) {
536 av_log(ctx, AV_LOG_ERROR, "Failed to map frame into derived "
537 "frame context: %d.\n", ret);
538 av_frame_free(&src_frame);
539 return ret;
540 }
541
542 // Free the source frame immediately - the mapped frame still
543 // contains a reference to it.
544 av_frame_free(&src_frame);
545
546 return 0;
547 }
548
549 if (!ctxi->hw_type->frames_get_buffer)
550 return AVERROR(ENOSYS);
551
552 if (!ctx->pool)
553 return AVERROR(EINVAL);
554
555 frame->hw_frames_ctx = av_buffer_ref(hwframe_ref);
556 if (!frame->hw_frames_ctx)
557 return AVERROR(ENOMEM);
558
559 ret = ctxi->hw_type->frames_get_buffer(ctx, frame);
560 if (ret < 0) {
561 av_buffer_unref(&frame->hw_frames_ctx);
562 return ret;
563 }

Callers 15

av_frame_make_writableFunction · 0.85
hwframe_pool_preallocFunction · 0.85
qsv_dynamic_pool_allocFunction · 0.85
transfer_frameFunction · 0.85
vulkan_encode_create_dpbFunction · 0.85
cuvid_output_frameFunction · 0.85
vk_get_dpb_poolFunction · 0.85
vk_ffv1_start_frameFunction · 0.85
nppsharpen_configFunction · 0.85

Calls 6

av_buffer_refFunction · 0.85
av_frame_allocFunction · 0.85
av_frame_freeFunction · 0.85
av_hwframe_mapFunction · 0.85
av_logFunction · 0.85
av_buffer_unrefFunction · 0.85

Tested by

no test coverage detected