summaryrefslogtreecommitdiffstats
path: root/libhb
diff options
context:
space:
mode:
Diffstat (limited to 'libhb')
-rw-r--r--libhb/decavcodec.c59
-rw-r--r--libhb/enc_qsv.c2
-rw-r--r--libhb/qsv_common.c19
-rw-r--r--libhb/work.c14
4 files changed, 51 insertions, 43 deletions
diff --git a/libhb/decavcodec.c b/libhb/decavcodec.c
index 00dd95f4b..3ea4dbed4 100644
--- a/libhb/decavcodec.c
+++ b/libhb/decavcodec.c
@@ -351,7 +351,8 @@ static void closePrivData( hb_work_private_t ** ppv )
* 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);
@@ -1052,7 +1053,9 @@ static int decodeFrame( hb_work_object_t *w, packet_info_t * packet_info )
av_free_packet(&avp);
#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
@@ -1304,7 +1307,8 @@ static void decodeVideo( hb_work_object_t *w, hb_buffer_t * in)
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))
@@ -1333,12 +1337,13 @@ static int decavcodecvInit( hb_work_object_t * w, hb_job_t * job )
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;
@@ -1352,12 +1357,8 @@ static int decavcodecvInit( hb_work_object_t * w, hb_job_t * job )
// 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
@@ -1395,7 +1396,8 @@ static int decavcodecvInit( hb_work_object_t * w, hb_job_t * job )
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;
@@ -1564,7 +1566,8 @@ static int decavcodecvWork( hb_work_object_t * w, hb_buffer_t ** buf_in,
}
#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;
@@ -1792,21 +1795,25 @@ static int decavcodecvInfo( hb_work_object_t *w, hb_work_info_t *info )
info->color_matrix = get_color_matrix(pv->context->colorspace, info->geometry);
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;
}
diff --git a/libhb/enc_qsv.c b/libhb/enc_qsv.c
index 852efed15..c048f93be 100644
--- a/libhb/enc_qsv.c
+++ b/libhb/enc_qsv.c
@@ -669,8 +669,8 @@ int encqsvInit(hb_work_object_t *w, hb_job_t *job)
hb_work_private_t *pv = calloc(1, sizeof(hb_work_private_t));
w->private_data = pv;
+ pv->is_sys_mem = 1; // TODO: re-implement QSV VPP filtering support
pv->job = job;
- pv->is_sys_mem = hb_qsv_decode_is_enabled(job) == 0;
pv->qsv_info = hb_qsv_info_get(job->vcodec);
pv->delayed_processing = hb_list_init();
pv->last_start = INT64_MIN;
diff --git a/libhb/qsv_common.c b/libhb/qsv_common.c
index 2c2d827c6..3c4a8441c 100644
--- a/libhb/qsv_common.c
+++ b/libhb/qsv_common.c
@@ -905,6 +905,12 @@ const char* hb_qsv_decode_get_codec_name(enum AVCodecID codec_id)
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;
}
@@ -912,17 +918,8 @@ const char* hb_qsv_decode_get_codec_name(enum AVCodecID codec_id)
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)
diff --git a/libhb/work.c b/libhb/work.c
index 6b2452d19..7d43ce4c5 100644
--- a/libhb/work.c
+++ b/libhb/work.c
@@ -1125,6 +1125,7 @@ static int sanitize_audio(hb_job_t *job)
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;
/*
@@ -1178,10 +1179,10 @@ static int sanitize_qsv( hb_job_t * job )
}
/*
- * 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;
@@ -1292,7 +1293,8 @@ static int sanitize_qsv( hb_job_t * job )
}
}
}
-#endif
+#endif // QSV VPP filtering and QSV zerocopy path
+#endif // USE_QSV
return 0;
}
@@ -1482,7 +1484,8 @@ static void do_job(hb_job_t *job)
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 );
@@ -1495,6 +1498,7 @@ static void do_job(hb_job_t *job)
}
}
else
+#endif // QSV zerocopy path
#endif
{
job->fifo_mpeg2 = hb_fifo_init( FIFO_SMALL, FIFO_SMALL_WAKE );