summaryrefslogtreecommitdiffstats
path: root/libhb
diff options
context:
space:
mode:
authorRodeo <[email protected]>2015-06-23 17:09:34 +0000
committerRodeo <[email protected]>2015-06-23 17:09:34 +0000
commita14dcbd980fc7e75f4a66003808d306e11c609aa (patch)
tree3fc5065c86569b71602fc7dee39dcbc0c8bf4c6a /libhb
parent110c304ff2113e5852a35174a7d51ffe5297483b (diff)
DXVA2: cleanup decode support checks.
This should fix https://forum.handbrake.fr/viewtopic.php?f=11&t=32520 git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@7310 b64f7644-9d1e-0410-96f1-a4d463321fa5
Diffstat (limited to 'libhb')
-rw-r--r--libhb/common.c12
-rw-r--r--libhb/common.h9
-rw-r--r--libhb/cropscale.c2
-rw-r--r--libhb/decavcodec.c18
-rw-r--r--libhb/scan.c8
-rw-r--r--libhb/stream.c34
-rw-r--r--libhb/work.c27
7 files changed, 54 insertions, 56 deletions
diff --git a/libhb/common.c b/libhb/common.c
index 8cc1dc65d..526ee7874 100644
--- a/libhb/common.c
+++ b/libhb/common.c
@@ -4532,15 +4532,3 @@ void hb_hexdump( hb_debug_level_t level, const char * label, const uint8_t * dat
hb_deep_log( level, " %-50s%20s", line, ascii );
}
}
-
-int hb_use_dxva( hb_title_t * title )
-{
- return ( (title->video_codec_param == AV_CODEC_ID_MPEG2VIDEO
- || title->video_codec_param == AV_CODEC_ID_H264
- || title->video_codec_param == AV_CODEC_ID_VC1
- || title->video_codec_param == AV_CODEC_ID_WMV3
- || title->video_codec_param == AV_CODEC_ID_MPEG4
- || title->video_codec_param == AV_CODEC_ID_HEVC )
- && title->opaque_priv );
-}
-
diff --git a/libhb/common.h b/libhb/common.h
index 14faa31fd..a96a3e4e7 100644
--- a/libhb/common.h
+++ b/libhb/common.h
@@ -962,8 +962,9 @@ struct hb_title_s
// additional supported video decoders (e.g. HW-accelerated implementations)
int video_decode_support;
-#define HB_DECODE_SUPPORT_SW 0x01 // software (libavcodec or mpeg2dec)
-#define HB_DECODE_SUPPORT_QSV 0x02 // Intel Quick Sync Video
+#define HB_DECODE_SUPPORT_SW 0x01 // software (libavcodec or mpeg2dec)
+#define HB_DECODE_SUPPORT_QSV 0x02 // Intel Quick Sync Video
+#define HB_DECODE_SUPPORT_DXVA2 0x04 // Microsoft DXVA2
hb_metadata_t * metadata;
@@ -979,7 +980,6 @@ struct hb_title_s
// whether OpenCL scaling is supported for this source
int opencl_support;
- int hwd_support; // TODO: merge to video_decode_support
};
// Update win/CS/HandBrake.Interop/HandBrakeInterop/HbLib/hb_state_s.cs when changing this struct
@@ -1153,8 +1153,6 @@ extern hb_work_object_t hb_reader;
#define HB_FILTER_DROP 3
#define HB_FILTER_DONE 4
-int hb_use_dxva(hb_title_t *title);
-
typedef struct hb_filter_init_s
{
hb_job_t * job;
@@ -1163,7 +1161,6 @@ typedef struct hb_filter_init_s
int crop[4];
hb_rational_t vrate;
int cfr;
- int use_dxva;
} hb_filter_init_t;
typedef struct hb_filter_info_s
diff --git a/libhb/cropscale.c b/libhb/cropscale.c
index fc88e32a4..548bdcc2e 100644
--- a/libhb/cropscale.c
+++ b/libhb/cropscale.c
@@ -71,7 +71,7 @@ static int hb_crop_scale_init( hb_filter_object_t * filter,
pv->height_out = init->geometry.height - (init->crop[0] + init->crop[1]);
/* OpenCL/DXVA2 */
- pv->use_dxva = init->use_dxva;
+ pv->use_dxva = hb_hwd_enabled(init->job->h);
pv->use_decomb = init->job->use_decomb;
pv->use_detelecine = init->job->use_detelecine;
diff --git a/libhb/decavcodec.c b/libhb/decavcodec.c
index bdca1e180..f81205ada 100644
--- a/libhb/decavcodec.c
+++ b/libhb/decavcodec.c
@@ -1669,8 +1669,7 @@ 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_HWD
// QSV decoding is faster, so prefer it to DXVA2
- if (pv->job != NULL && !pv->qsv.decode && pv->job->use_hwd &&
- hb_use_dxva(pv->title))
+ if (pv->job != NULL && !pv->qsv.decode && hb_hwd_enabled(pv->job->h))
{
pv->dxva2 = hb_va_create_dxva2( pv->dxva2, w->codec_param );
if( pv->dxva2 && pv->dxva2->do_job == HB_WORK_OK )
@@ -1685,6 +1684,10 @@ static int decavcodecvInit( hb_work_object_t * w, hb_job_t * job )
memset( pv->opencl_scale, 0, sizeof( hb_oclscale_t ) );
pv->threads = 1;
}
+ else
+ {
+ hb_log("decavcodecvInit: hb_va_create_dxva2 failed, using software decoder");
+ }
}
#endif
@@ -2123,6 +2126,17 @@ static int decavcodecvInfo( hb_work_object_t *w, hb_work_info_t *info )
default:
break;
}
+#ifdef USE_HWD
+ hb_va_dxva2_t *dxva2 = hb_va_create_dxva2(NULL, pv->context->codec_id);
+ if (dxva2 != NULL)
+ {
+ if (hb_check_hwd_fmt(pv->context->pix_fmt))
+ {
+ info->video_decode_support |= HB_DECODE_SUPPORT_DXVA2;
+ }
+ hb_va_close(dxva2);
+ }
+#endif
return 1;
}
diff --git a/libhb/scan.c b/libhb/scan.c
index 3a19d9e19..a446344cd 100644
--- a/libhb/scan.c
+++ b/libhb/scan.c
@@ -1039,6 +1039,14 @@ skip_preview:
aspect_to_string(&title->dar),
title->geometry.par.num, title->geometry.par.den);
+ if (title->video_decode_support != HB_DECODE_SUPPORT_SW)
+ {
+ hb_log("scan: supported video decoders:%s%s%s",
+ !(title->video_decode_support & HB_DECODE_SUPPORT_SW) ? "" : " avcodec",
+ !(title->video_decode_support & HB_DECODE_SUPPORT_QSV) ? "" : " qsv",
+ !(title->video_decode_support & HB_DECODE_SUPPORT_DXVA2) ? "" : " dxva2");
+ }
+
if( interlaced_preview_count >= ( npreviews / 2 ) )
{
hb_log("Title is likely interlaced or telecined (%i out of %i previews). You should do something about that.",
diff --git a/libhb/stream.c b/libhb/stream.c
index be214c4bc..cb669e52f 100644
--- a/libhb/stream.c
+++ b/libhb/stream.c
@@ -842,6 +842,8 @@ hb_stream_open(hb_handle_t *h, char *path, hb_title_t *title, int scan)
d->path = strdup( path );
if (d->path != NULL )
{
+ // XXX: DXVA2 integration code requires an AVFormatContext
+ // use lavf instead of our MPEG demuxer when it's enabled
if (!hb_hwd_enabled(d->h) && hb_stream_get_type( d ) != 0 )
{
if( !scan )
@@ -1104,20 +1106,6 @@ hb_title_t * hb_stream_title_scan(hb_stream_t *stream, hb_title_t * title)
{
hb_log( "transport stream missing PCRs - using video DTS instead" );
}
-#ifdef USE_HWD
- hb_va_dxva2_t * dxva2 = NULL;
- dxva2 = hb_va_create_dxva2( dxva2, title->video_codec_param );
- if ( dxva2 )
- {
- title->hwd_support = 1;
- hb_va_close(dxva2);
- dxva2 = NULL;
- }
- else
- title->hwd_support = 0;
-#else
- title->hwd_support = 0;
-#endif
// Height, width, rate and aspect ratio information is filled in
// when the previews are built
@@ -5594,24 +5582,6 @@ static hb_title_t *ffmpeg_title_scan( hb_stream_t *stream, hb_title_t *title )
chapter->seconds = title->seconds;
hb_list_add( title->list_chapter, chapter );
}
-#ifdef USE_HWD
- hb_va_dxva2_t * dxva2 = NULL;
- dxva2 = hb_va_create_dxva2( dxva2, title->video_codec_param );
- if (dxva2)
- {
- title->hwd_support = 1;
- hb_va_close(dxva2);
- dxva2 = NULL;
- }
- else
- title->hwd_support = 0;
- if ( hb_check_hwd_fmt(pix_fmt) == 0)
- title->hwd_support = 0;
-#else
- // Eliminate compiler warning "pix_fmt set but not used"
- (void)pix_fmt;
- title->hwd_support = 0;
-#endif
return title;
}
diff --git a/libhb/work.c b/libhb/work.c
index 2ac218d27..3d158862b 100644
--- a/libhb/work.c
+++ b/libhb/work.c
@@ -301,6 +301,13 @@ void hb_display_job_info(hb_job_t *job)
}
else
#endif
+#ifdef USE_HWD
+ if (hb_hwd_enabled(job->h))
+ {
+ hb_log(" + decoder: %s (dxva2)", title->video_codec_name);
+ }
+ else
+#endif
{
hb_log(" + decoder: %s", title->video_codec_name);
}
@@ -909,6 +916,23 @@ static void do_job(hb_job_t *job)
}
#endif
+#ifdef USE_HWD
+ /*
+ * Check support for and enable DXVA2-accelerated when applicable; we need:
+ * - a compatible input bitstream (HB_DECODE_SUPPORT_DXVA2)
+ * - DXVA2-accelerated decoding enabled (job->use_hwd)
+ * - an AVFormatContext (title->opaque_priv) for now
+ */
+ if (title->video_decode_support & HB_DECODE_SUPPORT_DXVA2)
+ {
+ hb_hwd_set_enable(job->h, job->use_hwd && title->opaque_priv != NULL);
+ }
+ else
+#endif
+ {
+ hb_hwd_set_enable(job->h, 0);
+ }
+
// Filters have an effect on settings.
// So initialize the filters and update the job.
if( job->list_filter && hb_list_count( job->list_filter ) )
@@ -920,9 +944,6 @@ static void do_job(hb_job_t *job)
init.geometry.width = title->geometry.width;
init.geometry.height = title->geometry.height;
- /* DXVA2 */
- init.use_dxva = hb_use_dxva(title);
-
init.geometry.par = job->par;
memcpy(init.crop, title->crop, sizeof(int[4]));
init.vrate = title->vrate;