Skip to content

Commit

Permalink
Add Intel Quick Sync Video acceleration (QSV) support
Browse files Browse the repository at this point in the history
Signed-off-by: Javier Marcet <[email protected]>
  • Loading branch information
jmarcet authored and cdecker08 committed Dec 6, 2024
1 parent ce0eb23 commit d9e1498
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
9 changes: 9 additions & 0 deletions comskip.c
Original file line number Diff line number Diff line change
Expand Up @@ -468,6 +468,7 @@ int hardware_decode = 0;
int use_cuvid = 0;
int use_vdpau = 0;
int use_dxva2 = 0;
int use_qsv = 0;
int skip_B_frames = 0;
int lowres = 0;
bool live_tv = false;
Expand Down Expand Up @@ -8767,6 +8768,7 @@ FILE* LoadSettings(int argc, char ** argv)
struct arg_lit* cl_use_cuvid = arg_lit0(NULL, "cuvid", "Use NVIDIA Video Decoder (CUVID), if available");
struct arg_lit* cl_use_vdpau = arg_lit0(NULL, "vdpau", "Use NVIDIA Video Decode and Presentation API (VDPAU), if available");
struct arg_lit* cl_use_dxva2 = arg_lit0(NULL, "dxva2", "Use DXVA2 Video Decode and Presentation API (DXVA2), if available");
struct arg_lit* cl_use_qsv = arg_lit0(NULL, "qsv", "Use Intel Quick Sync Video acceleration (QSV), if available");
struct arg_lit* cl_list_decoders = arg_lit0(NULL, "decoders", "List all decoders and exit");
struct arg_int* cl_threads = arg_int0(NULL, "threads", "<int>", "The number of threads to use");
struct arg_int* cl_verbose = arg_intn("v", "verbose", NULL, 0, 1, "Verbose level");
Expand Down Expand Up @@ -8797,6 +8799,7 @@ FILE* LoadSettings(int argc, char ** argv)
cl_use_cuvid,
cl_use_vdpau,
cl_use_dxva2,
cl_use_qsv,
cl_list_decoders,
cl_threads,
cl_pid,
Expand Down Expand Up @@ -9259,6 +9262,12 @@ FILE* LoadSettings(int argc, char ** argv)
use_dxva2 = 1;
}

if (cl_use_qsv->count)
{
printf("Enabling use_qsv\n");
use_qsv = 1;
}

if (cl_threads->count)
{
thread_count = cl_threads->ival[0];
Expand Down
15 changes: 15 additions & 0 deletions mpeg2dec.c
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@ const HWAccel hwaccels[] = {
#endif
#if CONFIG_VDA
{ "vda", vda_init, HWACCEL_VDA, AV_PIX_FMT_VDA },
#endif
#if HAVE_QSV
{ "qsv", qsv_init, HWACCEL_QSV, AV_PIX_FMT_QSV },
#endif
{ 0 },
};
Expand All @@ -68,6 +71,7 @@ extern int hardware_decode;
extern int use_cuvid;
extern int use_vdpau;
extern int use_dxva2;
extern int use_qsv;
int av_log_level=AV_LOG_INFO;


Expand Down Expand Up @@ -1664,6 +1668,17 @@ int stream_component_open(VideoState *is, int stream_index)

codec = avcodec_find_decoder(codecPar->codec_id);

if (use_qsv && !codec_hw) {
if (codecPar->codec_id == AV_CODEC_ID_MJPEG) codec_hw = avcodec_find_decoder_by_name("mjpeg_qsv");
if (codecPar->codec_id == AV_CODEC_ID_MPEG2VIDEO) codec_hw = avcodec_find_decoder_by_name("mpeg2_qsv");
if (codecPar->codec_id == AV_CODEC_ID_H264) codec_hw = avcodec_find_decoder_by_name("h264_qsv");
if (codecPar->codec_id == AV_CODEC_ID_VC1) codec_hw = avcodec_find_decoder_by_name("vc1_qsv");
if (codecPar->codec_id == AV_CODEC_ID_HEVC) codec_hw = avcodec_find_decoder_by_name("hevc_qsv");
if (codecPar->codec_id == AV_CODEC_ID_AV1) codec_hw = avcodec_find_decoder_by_name("av1_qsv");
if (codecPar->codec_id == AV_CODEC_ID_VP8) codec_hw = avcodec_find_decoder_by_name("vp8_qsv");
if (codecPar->codec_id == AV_CODEC_ID_VP9) codec_hw = avcodec_find_decoder_by_name("vp9_qsv");
}

if (use_dxva2 && !codec_hw) {
if (codecPar->codec_id == AV_CODEC_ID_MPEG2VIDEO) codec_hw = avcodec_find_decoder_by_name("mpeg2_dxva2");
if (codecPar->codec_id == AV_CODEC_ID_H264) codec_hw = avcodec_find_decoder_by_name("h264_dxva2");
Expand Down

0 comments on commit d9e1498

Please sign in to comment.