* still need that session for QSV filtering and/or encoding, so we
* we can't close the context here until we implement a proper fix.
*/
- if (!pv->qsv.decode)
+ if (pv->qsv.decode == NULL ||
+ pv->qsv.config.io_pattern != MFX_IOPATTERN_OUT_OPAQUE_MEMORY)
#endif
{
hb_avcodec_close(pv->context);
}
#ifdef USE_QSV
- if (pv->qsv.decode && pv->job->qsv.ctx == NULL && pv->video_codec_opened > 0)
+ if (pv->qsv.decode &&
+ pv->qsv.config.io_pattern == MFX_IOPATTERN_OUT_OPAQUE_MEMORY &&
+ pv->job->qsv.ctx == NULL && pv->video_codec_opened > 0)
{
// this is quite late, but we can't be certain that the QSV context is
// available until after we call avcodec_decode_video2() at least once
continue;
}
#ifdef USE_QSV
- if (pv->qsv.decode)
+ if (pv->qsv.decode &&
+ pv->qsv.config.io_pattern == MFX_IOPATTERN_OUT_OPAQUE_MEMORY)
{
// flush a second time
while (decodeFrame(w, NULL))
hb_buffer_list_clear(&pv->list);
#ifdef USE_QSV
- if (hb_qsv_decode_is_enabled(job))
+ if ((pv->qsv.decode = hb_qsv_decode_is_enabled(job)))
{
- // determine which encoder we're using
+ pv->qsv.codec_name = hb_qsv_decode_get_codec_name(w->codec_param);
+ pv->qsv.config.io_pattern = MFX_IOPATTERN_OUT_SYSTEM_MEMORY;
+#if 0 // TODO: re-implement QSV zerocopy path
hb_qsv_info_t *info = hb_qsv_info_get(job->vcodec);
- pv->qsv.decode = info != NULL;
- if (pv->qsv.decode)
+ if (info != NULL)
{
// setup the QSV configuration
pv->qsv.config.io_pattern = MFX_IOPATTERN_OUT_OPAQUE_MEMORY;
// more surfaces may be needed for the lookahead
pv->qsv.config.additional_buffers = 160;
}
- pv->qsv.codec_name = hb_qsv_decode_get_codec_name(w->codec_param);
}
- }
- else
- {
- pv->qsv.decode = 0;
+#endif // QSV zerocopy path
}
#endif
pv->context->error_concealment = FF_EC_GUESS_MVS|FF_EC_DEBLOCK;
#ifdef USE_QSV
- if (pv->qsv.decode)
+ if (pv->qsv.decode &&
+ pv->qsv.config.io_pattern == MFX_IOPATTERN_OUT_OPAQUE_MEMORY)
{
// set the QSV configuration before opening the decoder
pv->context->hwaccel_context = &pv->qsv.config;
}
#ifdef USE_QSV
- if (pv->qsv.decode)
+ if (pv->qsv.decode &&
+ pv->qsv.config.io_pattern == MFX_IOPATTERN_OUT_OPAQUE_MEMORY)
{
// set the QSV configuration before opening the decoder
pv->context->hwaccel_context = &pv->qsv.config;
}
info->video_decode_support = HB_DECODE_SUPPORT_SW;
- switch (pv->context->codec_id)
- {
- case AV_CODEC_ID_H264:
- if (pv->context->pix_fmt == AV_PIX_FMT_YUV420P ||
- pv->context->pix_fmt == AV_PIX_FMT_YUVJ420P)
- {
+
#ifdef USE_QSV
- info->video_decode_support |= HB_DECODE_SUPPORT_QSV;
-#endif
- }
- break;
+ if (avcodec_find_decoder_by_name(hb_qsv_decode_get_codec_name(pv->context->codec_id)))
+ {
+ switch (pv->context->codec_id)
+ {
+ case AV_CODEC_ID_H264:
+ if (pv->context->pix_fmt == AV_PIX_FMT_YUV420P ||
+ pv->context->pix_fmt == AV_PIX_FMT_YUVJ420P)
+ {
+ info->video_decode_support |= HB_DECODE_SUPPORT_QSV;
+ }
+ break;
- default:
- break;
+ default:
+ break;
+ }
}
+#endif
return 1;
}
case AV_CODEC_ID_H264:
return "h264_qsv";
+ case AV_CODEC_ID_HEVC:
+ return "hevc_qsv";
+
+ case AV_CODEC_ID_MPEG2VIDEO:
+ return "mpeg2_qsv";
+
default:
return NULL;
}
int hb_qsv_decode_is_enabled(hb_job_t *job)
{
- /*
- * XXX: we haven't yet adjusted our QSV decoder wrapper to use libav's new
- * QSV-accelerated decoder, and our old custom QSV-accelerated decoder
- * for libav hasn't been updated to work with newer libav releases, so
- * we can't use QSV-accelerated decoding at all for the time being.
- *
- * return ((job != NULL && job->qsv.decode) &&
- * (job->vcodec & HB_VCODEC_QSV_MASK) &&
- * (job->title->video_decode_support & HB_DECODE_SUPPORT_QSV));
- */
- return 0;
+ return ((job != NULL && job->qsv.decode) &&
+ (job->title->video_decode_support & HB_DECODE_SUPPORT_QSV));
}
int hb_qsv_copyframe_is_slow(int encoder)
static int sanitize_qsv( hb_job_t * job )
{
#ifdef USE_QSV
+#if 0 // TODO: re-implement QSV VPP filtering and QSV zerocopy path
int i;
/*
}
/*
- * When QSV is used for decoding, not all CPU-based filters are supported,
- * so we need to do a little extra setup here.
+ * When QSV's VPP is used for filtering, not all CPU filters
+ * are supported, so we need to do a little extra setup here.
*/
- if (hb_qsv_decode_is_enabled(job))
+ if (job->vcodec & HB_VCODEC_QSV_MASK)
{
int vpp_settings[7];
int num_cpu_filters = 0;
}
}
}
-#endif
+#endif // QSV VPP filtering and QSV zerocopy path
+#endif // USE_QSV
return 0;
}
job->vrate.num, job->vrate.den);
#ifdef USE_QSV
- if (hb_qsv_decode_is_enabled(job))
+#if 0 // TODO: re-implement QSV zerocopy path
+ if (hb_qsv_decode_is_enabled(job) && (job->vcodec & HB_VCODEC_QSV_MASK))
{
job->fifo_mpeg2 = hb_fifo_init( FIFO_MINI, FIFO_MINI_WAKE );
job->fifo_raw = hb_fifo_init( FIFO_MINI, FIFO_MINI_WAKE );
}
}
else
+#endif // QSV zerocopy path
#endif
{
job->fifo_mpeg2 = hb_fifo_init( FIFO_SMALL, FIFO_SMALL_WAKE );