@@ -259,7 +259,7 @@ static enum AVPixelFormat get_hw_dec_format_cu(AVCodecContext *ctx, const enum A
259259#endif
260260
261261#if defined(__APPLE__)
262- static enum AVPixelFormat get_hw_dec_format_qs (AVCodecContext *ctx, const enum AVPixelFormat *pix_fmts)
262+ static enum AVPixelFormat get_hw_dec_format_vt (AVCodecContext *ctx, const enum AVPixelFormat *pix_fmts)
263263{
264264 const enum AVPixelFormat *p;
265265
@@ -272,11 +272,28 @@ static enum AVPixelFormat get_hw_dec_format_qs(AVCodecContext *ctx, const enum A
272272 break ;
273273 }
274274 }
275- ZmqLogger::Instance ()->AppendDebugMethod (" FFmpegReader::get_hw_dec_format_qs (Unable to decode this file using hardware decode.)" , " " , -1 , " " , -1 , " " , -1 , " " , -1 , " " , -1 , " " , -1 );
275+ ZmqLogger::Instance ()->AppendDebugMethod (" FFmpegReader::get_hw_dec_format_vt (Unable to decode this file using hardware decode.)" , " " , -1 , " " , -1 , " " , -1 , " " , -1 , " " , -1 , " " , -1 );
276276 return AV_PIX_FMT_NONE;
277277}
278278#endif
279279
280+ static enum AVPixelFormat get_hw_dec_format_qs (AVCodecContext *ctx, const enum AVPixelFormat *pix_fmts)
281+ {
282+ const enum AVPixelFormat *p;
283+
284+ for (p = pix_fmts; *p != AV_PIX_FMT_NONE; p++) {
285+ switch (*p) {
286+ case AV_PIX_FMT_QSV:
287+ hw_de_av_pix_fmt_global = AV_PIX_FMT_QSV;
288+ hw_de_av_device_type_global = AV_HWDEVICE_TYPE_QSV;
289+ return *p;
290+ break ;
291+ }
292+ }
293+ ZmqLogger::Instance ()->AppendDebugMethod (" FFmpegReader::get_hw_dec_format_qs (Unable to decode this file using hardware decode.)" , " " , -1 , " " , -1 , " " , -1 , " " , -1 , " " , -1 , " " , -1 );
294+ return AV_PIX_FMT_NONE;
295+ }
296+
280297int FFmpegReader::IsHardwareDecodeSupported (int codecid)
281298{
282299 int ret;
@@ -382,10 +399,6 @@ void FFmpegReader::Open() {
382399 adapter_ptr = adapter;
383400 i_decoder_hw = openshot::Settings::Instance ()->HARDWARE_DECODER ;
384401 switch (i_decoder_hw) {
385- case 0 :
386- hw_de_av_device_type = AV_HWDEVICE_TYPE_VAAPI;
387- pCodecCtx->get_format = get_hw_dec_format_va;
388- break ;
389402 case 1 :
390403 hw_de_av_device_type = AV_HWDEVICE_TYPE_VAAPI;
391404 pCodecCtx->get_format = get_hw_dec_format_va;
@@ -398,6 +411,10 @@ void FFmpegReader::Open() {
398411 hw_de_av_device_type = AV_HWDEVICE_TYPE_VDPAU;
399412 pCodecCtx->get_format = get_hw_dec_format_vd;
400413 break ;
414+ case 7 :
415+ hw_de_av_device_type = AV_HWDEVICE_TYPE_QSV;
416+ pCodecCtx->get_format = get_hw_dec_format_qs;
417+ break ;
401418 default :
402419 hw_de_av_device_type = AV_HWDEVICE_TYPE_VAAPI;
403420 pCodecCtx->get_format = get_hw_dec_format_va;
@@ -408,10 +425,6 @@ void FFmpegReader::Open() {
408425 adapter_ptr = NULL ;
409426 i_decoder_hw = openshot::Settings::Instance ()->HARDWARE_DECODER ;
410427 switch (i_decoder_hw) {
411- case 0 :
412- hw_de_av_device_type = AV_HWDEVICE_TYPE_DXVA2;
413- pCodecCtx->get_format = get_hw_dec_format_dx;
414- break ;
415428 case 2 :
416429 hw_de_av_device_type = AV_HWDEVICE_TYPE_CUDA;
417430 pCodecCtx->get_format = get_hw_dec_format_cu;
@@ -424,6 +437,10 @@ void FFmpegReader::Open() {
424437 hw_de_av_device_type = AV_HWDEVICE_TYPE_D3D11VA;
425438 pCodecCtx->get_format = get_hw_dec_format_d3;
426439 break ;
440+ case 7 :
441+ hw_de_av_device_type = AV_HWDEVICE_TYPE_QSV;
442+ pCodecCtx->get_format = get_hw_dec_format_qs;
443+ break ;
427444 default :
428445 hw_de_av_device_type = AV_HWDEVICE_TYPE_DXVA2;
429446 pCodecCtx->get_format = get_hw_dec_format_dx;
@@ -433,17 +450,17 @@ void FFmpegReader::Open() {
433450 adapter_ptr = NULL ;
434451 i_decoder_hw = openshot::Settings::Instance ()->HARDWARE_DECODER ;
435452 switch (i_decoder_hw) {
436- case 0 :
437- hw_de_av_device_type = AV_HWDEVICE_TYPE_VIDEOTOOLBOX;
438- pCodecCtx->get_format = get_hw_dec_format_qs;
439- break ;
440453 case 5 :
441454 hw_de_av_device_type = AV_HWDEVICE_TYPE_VIDEOTOOLBOX;
455+ pCodecCtx->get_format = get_hw_dec_format_vt;
456+ break ;
457+ case 7 :
458+ hw_de_av_device_type = AV_HWDEVICE_TYPE_QSV;
442459 pCodecCtx->get_format = get_hw_dec_format_qs;
443460 break ;
444461 default :
445462 hw_de_av_device_type = AV_HWDEVICE_TYPE_VIDEOTOOLBOX;
446- pCodecCtx->get_format = get_hw_dec_format_qs ;
463+ pCodecCtx->get_format = get_hw_dec_format_vt ;
447464 break ;
448465 }
449466#endif
0 commit comments