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

Function nvdec_decoder_create

libavcodec/nvdec.c:184–239  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

182}
183
184static int nvdec_decoder_create(NVDECDecoder **out, AVBufferRef *hw_device_ref,
185 CUVIDDECODECREATEINFO *params, void *logctx)
186{
187 AVHWDeviceContext *hw_device_ctx = (AVHWDeviceContext*)hw_device_ref->data;
188 AVCUDADeviceContext *device_hwctx = hw_device_ctx->hwctx;
189
190 NVDECDecoder *decoder;
191
192 CUcontext dummy;
193 int ret;
194
195 decoder = av_refstruct_alloc_ext(sizeof(*decoder), 0,
196 NULL, nvdec_decoder_free);
197 if (!decoder)
198 return AVERROR(ENOMEM);
199
200 decoder->hw_device_ref = av_buffer_ref(hw_device_ref);
201 if (!decoder->hw_device_ref) {
202 ret = AVERROR(ENOMEM);
203 goto fail;
204 }
205 decoder->cuda_ctx = device_hwctx->cuda_ctx;
206 decoder->cudl = device_hwctx->internal->cuda_dl;
207 decoder->stream = device_hwctx->stream;
208
209 ret = cuvid_load_functions(&decoder->cvdl, logctx);
210 if (ret < 0) {
211 av_log(logctx, AV_LOG_ERROR, "Failed loading nvcuvid.\n");
212 goto fail;
213 }
214
215 ret = CHECK_CU(decoder->cudl->cuCtxPushCurrent(decoder->cuda_ctx));
216 if (ret < 0)
217 goto fail;
218
219 ret = nvdec_test_capabilities(decoder, params, logctx);
220 if (ret < 0) {
221 CHECK_CU(decoder->cudl->cuCtxPopCurrent(&dummy));
222 goto fail;
223 }
224
225 ret = CHECK_CU(decoder->cvdl->cuvidCreateDecoder(&decoder->decoder, params));
226
227 CHECK_CU(decoder->cudl->cuCtxPopCurrent(&dummy));
228
229 if (ret < 0) {
230 goto fail;
231 }
232
233 *out = decoder;
234
235 return 0;
236fail:
237 av_refstruct_unref(&decoder);
238 return ret;
239}
240
241static int nvdec_decoder_frame_init(AVRefStructOpaque opaque, void *obj)

Callers 1

ff_nvdec_decode_initFunction · 0.85

Calls 5

av_refstruct_alloc_extFunction · 0.85
av_buffer_refFunction · 0.85
av_logFunction · 0.85
nvdec_test_capabilitiesFunction · 0.85
av_refstruct_unrefFunction · 0.85

Tested by

no test coverage detected