You've already forked FFmpeg
mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2025-06-30 22:24:04 +02:00
avcodec/nvenc: support external context in sw mode
This commit is contained in:
@ -400,16 +400,21 @@ static av_cold int nvenc_setup_device(AVCodecContext *avctx)
|
|||||||
return AVERROR_BUG;
|
return AVERROR_BUG;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (avctx->pix_fmt == AV_PIX_FMT_CUDA) {
|
if (avctx->pix_fmt == AV_PIX_FMT_CUDA || avctx->hw_frames_ctx || avctx->hw_device_ctx) {
|
||||||
AVHWFramesContext *frames_ctx;
|
AVHWFramesContext *frames_ctx;
|
||||||
|
AVHWDeviceContext *hwdev_ctx;
|
||||||
AVCUDADeviceContext *device_hwctx;
|
AVCUDADeviceContext *device_hwctx;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
if (!avctx->hw_frames_ctx)
|
if (avctx->hw_frames_ctx) {
|
||||||
return AVERROR(EINVAL);
|
|
||||||
|
|
||||||
frames_ctx = (AVHWFramesContext*)avctx->hw_frames_ctx->data;
|
frames_ctx = (AVHWFramesContext*)avctx->hw_frames_ctx->data;
|
||||||
device_hwctx = frames_ctx->device_ctx->hwctx;
|
device_hwctx = frames_ctx->device_ctx->hwctx;
|
||||||
|
} else if (avctx->hw_device_ctx) {
|
||||||
|
hwdev_ctx = (AVHWDeviceContext*)avctx->hw_device_ctx->data;
|
||||||
|
device_hwctx = hwdev_ctx->hwctx;
|
||||||
|
} else {
|
||||||
|
return AVERROR(EINVAL);
|
||||||
|
}
|
||||||
|
|
||||||
ctx->cu_context = device_hwctx->cuda_ctx;
|
ctx->cu_context = device_hwctx->cuda_ctx;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user