Allow to use nvenc and nvdec in Windows for nVidia cards.

nVidia card don't use the DX API like intel or AMD cards.
If ffmpeg and the libraries are compiled with nvenc and
nvdec support on WIndows this should(!) now work.
This commit is contained in:
eisneinechse
2019-02-15 10:11:45 -08:00
parent 56ae085d8b
commit a2b8eaff37
2 changed files with 33 additions and 3 deletions

View File

@@ -224,6 +224,23 @@ static enum AVPixelFormat get_hw_dec_format_d3(AVCodecContext *ctx, const enum A
ZmqLogger::Instance()->AppendDebugMethod("FFmpegReader::ReadStream (Unable to decode this file using hardware decode.)", "", -1, "", -1, "", -1, "", -1, "", -1, "", -1);
return AV_PIX_FMT_NONE;
}
static enum AVPixelFormat get_hw_dec_format_cu(AVCodecContext *ctx, const enum AVPixelFormat *pix_fmts)
{
const enum AVPixelFormat *p;
for (p = pix_fmts; *p != AV_PIX_FMT_NONE; p++) {
switch (*p) {
case AV_PIX_FMT_CUDA:
hw_de_av_pix_fmt_global = AV_PIX_FMT_CUDA;
hw_de_av_device_type_global = AV_HWDEVICE_TYPE_CUDA;
return *p;
break;
}
}
ZmqLogger::Instance()->AppendDebugMethod("FFmpegReader::ReadStream (Unable to decode this file using hardware decode.)", "", -1, "", -1, "", -1, "", -1, "", -1, "", -1);
return AV_PIX_FMT_NONE;
}
#endif
#if defined(__APPLE__)
@@ -378,6 +395,10 @@ void FFmpegReader::Open()
hw_de_av_device_type = AV_HWDEVICE_TYPE_DXVA2;
pCodecCtx->get_format = get_hw_dec_format_dx;
break;
case 2:
hw_de_av_device_type = AV_HWDEVICE_TYPE_CUDA;
pCodecCtx->get_format = get_hw_dec_format_cu;
break;
case 3:
hw_de_av_device_type = AV_HWDEVICE_TYPE_DXVA2;
pCodecCtx->get_format = get_hw_dec_format_dx;