- if (!avctx->hw_frames_ctx && !avctx->hw_device_ctx) {
- av_log(avctx, AV_LOG_ERROR, "Either a hw_frames_ctx or a hw_device_ctx needs to be set for hardware decoding.\n");
- return AVERROR(EINVAL);
- }
-
- if (avctx->hw_frames_ctx) {
- frames_ctx = (AVHWFramesContext*)avctx->hw_frames_ctx->data;
- } else {
- avctx->hw_frames_ctx = av_hwframe_ctx_alloc(avctx->hw_device_ctx);
- if (!avctx->hw_frames_ctx)
- return AVERROR(ENOMEM);
-
- frames_ctx = (AVHWFramesContext*)avctx->hw_frames_ctx->data;
-
- dxva_adjust_hwframes(avctx, frames_ctx);
-
- ret = av_hwframe_ctx_init(avctx->hw_frames_ctx);
- if (ret < 0)
- goto fail;
- }