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

Function qsv_decode_preinit

libavcodec/qsvdec.c:297–394  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

295}
296
297static int qsv_decode_preinit(AVCodecContext *avctx, QSVContext *q, enum AVPixelFormat pix_fmt, mfxVideoParam *param)
298{
299 mfxSession session = NULL;
300 int iopattern = 0;
301 int ret;
302 enum AVPixelFormat pix_fmts[3] = {
303 AV_PIX_FMT_QSV, /* opaque format in case of video memory output */
304 pix_fmt, /* system memory format obtained from bitstream parser */
305 AV_PIX_FMT_NONE };
306
307 ret = ff_get_format(avctx, pix_fmts);
308 if (ret < 0) {
309 q->orig_pix_fmt = avctx->pix_fmt = AV_PIX_FMT_NONE;
310 return ret;
311 }
312
313 if (!q->async_fifo) {
314 q->async_fifo = av_fifo_alloc2(q->async_depth, sizeof(QSVAsyncFrame), 0);
315 if (!q->async_fifo)
316 return AVERROR(ENOMEM);
317 }
318
319 if (avctx->pix_fmt == AV_PIX_FMT_QSV && avctx->hwaccel_context) {
320 AVQSVContext *user_ctx = avctx->hwaccel_context;
321 session = user_ctx->session;
322 iopattern = user_ctx->iopattern;
323 q->ext_buffers = user_ctx->ext_buffers;
324 q->nb_ext_buffers = user_ctx->nb_ext_buffers;
325 }
326
327 if (avctx->hw_device_ctx && !avctx->hw_frames_ctx && ret == AV_PIX_FMT_QSV) {
328 AVHWFramesContext *hwframes_ctx;
329 AVQSVFramesContext *frames_hwctx;
330
331 avctx->hw_frames_ctx = av_hwframe_ctx_alloc(avctx->hw_device_ctx);
332
333 if (!avctx->hw_frames_ctx) {
334 av_log(avctx, AV_LOG_ERROR, "av_hwframe_ctx_alloc failed\n");
335 return AVERROR(ENOMEM);
336 }
337
338 hwframes_ctx = (AVHWFramesContext*)avctx->hw_frames_ctx->data;
339 frames_hwctx = hwframes_ctx->hwctx;
340 hwframes_ctx->width = FFALIGN(avctx->coded_width, 32);
341 hwframes_ctx->height = FFALIGN(avctx->coded_height, 32);
342 hwframes_ctx->format = AV_PIX_FMT_QSV;
343 hwframes_ctx->sw_format = avctx->sw_pix_fmt;
344 if (QSV_RUNTIME_VERSION_ATLEAST(q->ver, 2, 9) && q->handle_type != MFX_HANDLE_D3D9_DEVICE_MANAGER)
345 hwframes_ctx->initial_pool_size = 0;
346 else
347 hwframes_ctx->initial_pool_size = q->suggest_pool_size + 16 + avctx->extra_hw_frames;
348 frames_hwctx->frame_type = MFX_MEMTYPE_VIDEO_MEMORY_DECODER_TARGET;
349
350 ret = av_hwframe_ctx_init(avctx->hw_frames_ctx);
351
352 if (ret < 0) {
353 av_log(NULL, AV_LOG_ERROR, "Error initializing a QSV frame pool\n");
354 av_buffer_unref(&avctx->hw_frames_ctx);

Callers 2

qsv_decode_headerFunction · 0.85
qsv_process_dataFunction · 0.85

Calls 8

ff_get_formatFunction · 0.85
av_fifo_alloc2Function · 0.85
av_hwframe_ctx_allocFunction · 0.85
av_logFunction · 0.85
av_hwframe_ctx_initFunction · 0.85
av_buffer_unrefFunction · 0.85
ff_qsv_print_iopatternFunction · 0.85
qsv_init_sessionFunction · 0.85

Tested by

no test coverage detected