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

Function alloc_frame

libavcodec/qsvdec.c:494–561  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

492}
493
494static int alloc_frame(AVCodecContext *avctx, QSVContext *q, QSVFrame *frame)
495{
496 int ret;
497
498 if (q->pool)
499 ret = qsv_get_continuous_buffer(avctx, frame->frame, q->pool);
500 else
501 ret = ff_get_buffer(avctx, frame->frame, AV_GET_BUFFER_FLAG_REF);
502
503 if (ret < 0)
504 return ret;
505
506 if (frame->frame->format == AV_PIX_FMT_QSV) {
507 frame->surface = *(mfxFrameSurface1*)frame->frame->data[3];
508 } else {
509 ret = ff_qsv_map_frame_to_surface(frame->frame, &frame->surface);
510 if (ret < 0) {
511 av_log(avctx, AV_LOG_ERROR, "map frame to surface failed.\n");
512 return ret;
513 }
514 }
515
516 frame->surface.Info = q->frame_info;
517
518 if (q->frames_ctx.mids) {
519 ret = ff_qsv_find_surface_idx(&q->frames_ctx, frame);
520 if (ret < 0)
521 return ret;
522
523 frame->surface.Data.MemId = &q->frames_ctx.mids[ret];
524 }
525
526 frame->surface.Data.ExtParam = frame->ext_param;
527 frame->surface.Data.NumExtParam = 0;
528 frame->num_ext_params = 0;
529 frame->dec_info.Header.BufferId = MFX_EXTBUFF_DECODED_FRAME_INFO;
530 frame->dec_info.Header.BufferSz = sizeof(frame->dec_info);
531 ff_qsv_frame_add_ext_param(avctx, frame, (mfxExtBuffer *)&frame->dec_info);
532#if QSV_VERSION_ATLEAST(1, 34)
533 if (QSV_RUNTIME_VERSION_ATLEAST(q->ver, 1, 34) && avctx->codec_id == AV_CODEC_ID_AV1) {
534 frame->av1_film_grain_param.Header.BufferId = MFX_EXTBUFF_AV1_FILM_GRAIN_PARAM;
535 frame->av1_film_grain_param.Header.BufferSz = sizeof(frame->av1_film_grain_param);
536 frame->av1_film_grain_param.FilmGrainFlags = 0;
537 ff_qsv_frame_add_ext_param(avctx, frame, (mfxExtBuffer *)&frame->av1_film_grain_param);
538 }
539#endif
540
541#if QSV_VERSION_ATLEAST(1, 35)
542 if ((QSV_RUNTIME_VERSION_ATLEAST(q->ver, 1, 35) && avctx->codec_id == AV_CODEC_ID_HEVC) ||
543 (QSV_RUNTIME_VERSION_ATLEAST(q->ver, 2, 9) && avctx->codec_id == AV_CODEC_ID_AV1)) {
544 frame->mdcv.Header.BufferId = MFX_EXTBUFF_MASTERING_DISPLAY_COLOUR_VOLUME;
545 frame->mdcv.Header.BufferSz = sizeof(frame->mdcv);
546 // The data in mdcv is valid when this flag is 1
547 frame->mdcv.InsertPayloadToggle = 0;
548 ff_qsv_frame_add_ext_param(avctx, frame, (mfxExtBuffer *)&frame->mdcv);
549
550 frame->clli.Header.BufferId = MFX_EXTBUFF_CONTENT_LIGHT_LEVEL_INFO;
551 frame->clli.Header.BufferSz = sizeof(frame->clli);

Callers 1

get_surfaceFunction · 0.70

Calls 6

ff_get_bufferFunction · 0.85
av_logFunction · 0.85
ff_qsv_find_surface_idxFunction · 0.85

Tested by

no test coverage detected