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

Function ff_nvdec_decode_init

libavcodec/nvdec.c:327–455  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

325}
326
327int ff_nvdec_decode_init(AVCodecContext *avctx)
328{
329 NVDECContext *ctx = avctx->internal->hwaccel_priv_data;
330
331 NVDECDecoder *decoder;
332 AVBufferRef *real_hw_frames_ref;
333 NVDECFramePool *pool;
334 AVHWFramesContext *frames_ctx;
335 const AVPixFmtDescriptor *sw_desc;
336
337 CUVIDDECODECREATEINFO params = { 0 };
338
339 cudaVideoSurfaceFormat output_format;
340 int cuvid_codec_type, cuvid_chroma_format, chroma_444;
341 int ret = 0;
342
343 int unsafe_output = !!(avctx->hwaccel_flags & AV_HWACCEL_FLAG_UNSAFE_OUTPUT);
344
345 sw_desc = av_pix_fmt_desc_get(avctx->sw_pix_fmt);
346 if (!sw_desc)
347 return AVERROR_BUG;
348
349 cuvid_codec_type = map_avcodec_id(avctx->codec_id);
350 if (cuvid_codec_type < 0) {
351 av_log(avctx, AV_LOG_ERROR, "Unsupported codec ID\n");
352 return AVERROR_BUG;
353 }
354
355 cuvid_chroma_format = map_chroma_format(avctx->sw_pix_fmt);
356 if (cuvid_chroma_format < 0) {
357 av_log(avctx, AV_LOG_ERROR, "Unsupported chroma format\n");
358 return AVERROR(ENOSYS);
359 }
360 chroma_444 = ctx->supports_444 && cuvid_chroma_format == cudaVideoChromaFormat_444;
361
362 if (!avctx->hw_frames_ctx) {
363 ret = nvdec_init_hwframes(avctx, &avctx->hw_frames_ctx, 1);
364 if (ret < 0)
365 return ret;
366
367 ret = nvdec_init_hwframes(avctx, &real_hw_frames_ref, 0);
368 if (ret < 0)
369 return ret;
370 } else {
371 real_hw_frames_ref = av_buffer_ref(avctx->hw_frames_ctx);
372 if (!real_hw_frames_ref)
373 return AVERROR(ENOMEM);
374 }
375
376 switch (sw_desc->comp[0].depth) {
377 case 8:
378 if (chroma_444) {
379 output_format = cudaVideoSurfaceFormat_YUV444;
380#ifdef NVDEC_HAVE_422_SUPPORT
381 } else if (cuvid_chroma_format == cudaVideoChromaFormat_422) {
382 output_format = cudaVideoSurfaceFormat_NV16;
383#endif
384 } else {

Callers 1

nvdec_hevc_decode_initFunction · 0.85

Calls 11

av_pix_fmt_desc_getFunction · 0.85
map_avcodec_idFunction · 0.85
av_logFunction · 0.85
map_chroma_formatFunction · 0.85
nvdec_init_hwframesFunction · 0.85
av_buffer_refFunction · 0.85
av_buffer_unrefFunction · 0.85
nvdec_decoder_createFunction · 0.85
ff_nvdec_decode_uninitFunction · 0.85
av_malloczFunction · 0.50

Tested by

no test coverage detected