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

Function nvdec_retrieve_data

libavcodec/nvdec.c:495–573  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

493}
494
495static int nvdec_retrieve_data(void *logctx, AVFrame *frame)
496{
497 FrameDecodeData *fdd = frame->private_ref;
498 NVDECFrame *cf = (NVDECFrame*)fdd->hwaccel_priv;
499 NVDECDecoder *decoder = cf->decoder;
500
501 AVHWFramesContext *hwctx = (AVHWFramesContext *)frame->hw_frames_ctx->data;
502
503 CUVIDPROCPARAMS vpp = { 0 };
504 NVDECFrame *unmap_data = NULL;
505
506 CUcontext dummy;
507 CUdeviceptr devptr;
508
509 unsigned int pitch, i;
510 unsigned int offset = 0;
511 int shift_h = 0, shift_v = 0;
512 int ret = 0;
513
514 vpp.progressive_frame = 1;
515 vpp.output_stream = decoder->stream;
516
517 ret = CHECK_CU(decoder->cudl->cuCtxPushCurrent(decoder->cuda_ctx));
518 if (ret < 0)
519 return ret;
520
521 ret = CHECK_CU(decoder->cvdl->cuvidMapVideoFrame(decoder->decoder,
522 cf->idx, &devptr,
523 &pitch, &vpp));
524 if (ret < 0)
525 goto finish;
526
527 unmap_data = av_mallocz(sizeof(*unmap_data));
528 if (!unmap_data) {
529 ret = AVERROR(ENOMEM);
530 goto copy_fail;
531 }
532
533 frame->buf[1] = av_buffer_create((uint8_t *)unmap_data, sizeof(*unmap_data),
534 nvdec_unmap_mapped_frame, (void*)devptr,
535 AV_BUFFER_FLAG_READONLY);
536 if (!frame->buf[1]) {
537 ret = AVERROR(ENOMEM);
538 goto copy_fail;
539 }
540
541 ret = av_buffer_replace(&frame->hw_frames_ctx, decoder->real_hw_frames_ref);
542 if (ret < 0)
543 goto copy_fail;
544
545 unmap_data->idx = cf->idx;
546 unmap_data->idx_ref = av_refstruct_ref(cf->idx_ref);
547 unmap_data->decoder = av_refstruct_ref(cf->decoder);
548
549 av_pix_fmt_get_chroma_sub_sample(hwctx->sw_format, &shift_h, &shift_v);
550 for (i = 0; frame->linesize[i]; i++) {
551 frame->data[i] = (uint8_t*)(devptr + offset);
552 frame->linesize[i] = pitch;

Callers

nothing calls this directly

Calls 8

av_buffer_createFunction · 0.85
av_buffer_replaceFunction · 0.85
av_refstruct_refFunction · 0.85
av_freepFunction · 0.85
av_buffer_unrefFunction · 0.85
av_frame_make_writableFunction · 0.85
av_malloczFunction · 0.50

Tested by

no test coverage detected