From: Rodeo Date: Sat, 3 Aug 2013 12:10:32 +0000 (+0000) Subject: QSV: create a dedicated option for "AsyncDepth". X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=c39d724f4ebe9c18fa784d341a4e5c451144101e;p=handbrake QSV: create a dedicated option for "AsyncDepth". This parameter applies to all of decode, filtering and encode, whereas the'--encopts' string is for encoding-specific options. git-svn-id: svn://svn.handbrake.fr/HandBrake/branches/qsv@5685 b64f7644-9d1e-0410-96f1-a4d463321fa5 --- diff --git a/libhb/common.c b/libhb/common.c index b328120a5..77f7ef0d7 100644 --- a/libhb/common.c +++ b/libhb/common.c @@ -2831,7 +2831,8 @@ static void job_setup( hb_job_t * job, hb_title_t * title ) job->metadata = hb_metadata_copy( title->metadata ); #ifdef USE_QSV - job->qsv_decode = title->qsv_decode_support; + job->qsv_decode = title->qsv_decode_support; + job->qsv_async_depth = AV_QSV_ASYNC_DEPTH_DEFAULT; #endif } diff --git a/libhb/common.h b/libhb/common.h index 2e412757f..bf7495e4e 100644 --- a/libhb/common.h +++ b/libhb/common.h @@ -515,6 +515,7 @@ struct hb_job_s #ifdef USE_QSV av_qsv_context *qsv; int qsv_decode; + int qsv_async_depth; #endif #ifdef __LIBHB__ diff --git a/libhb/decavcodec.c b/libhb/decavcodec.c index 4c95b89cf..fbb0a4ee1 100644 --- a/libhb/decavcodec.c +++ b/libhb/decavcodec.c @@ -1174,27 +1174,10 @@ static int decavcodecvInit( hb_work_object_t * w, hb_job_t * job ) #ifdef USE_QSV if (hb_qsv_decode_is_enabled(job)) { - int ret; - hb_dict_t *qsv_opts = NULL; - hb_dict_entry_t *entry = NULL; - qsv_param_set_defaults(&pv->qsv_config); - // parse QSV encoding options to determine AsyncDepth - if (job->advanced_opts != NULL && *job->advanced_opts != '\0') - { - qsv_opts = hb_encopts_to_dict(job->advanced_opts, job->vcodec); - } - while ((entry = hb_dict_next(qsv_opts, entry)) != NULL) - { - ret = qsv_param_parse(&pv->qsv_config, entry->key, entry->value); - if (ret == QSV_PARAM_BAD_NAME) - hb_log("QSV options: Unknown suboption %s", entry->key); - if (ret == QSV_PARAM_BAD_VALUE) - hb_log("QSV options: Bad argument %s=%s", entry->key, entry->value); - } - hb_dict_free(&qsv_opts); // setup the QSV configuration pv->qsv_config.impl_requested = MFX_IMPL_AUTO_ANY|MFX_IMPL_VIA_ANY; pv->qsv_config.io_pattern = MFX_IOPATTERN_OUT_OPAQUE_MEMORY; + pv->qsv_config.async_depth = job->qsv_async_depth; pv->qsv_config.sync_need = 0; pv->qsv_config.usage_threaded = 1; pv->qsv_config.additional_buffers = 64; // FIFO_LARGE diff --git a/libhb/enc_qsv.c b/libhb/enc_qsv.c index 3557a0e56..4c57e9e97 100644 --- a/libhb/enc_qsv.c +++ b/libhb/enc_qsv.c @@ -499,11 +499,9 @@ int qsv_enc_init(av_qsv_context *qsv, hb_work_private_t *pv) job->color_transfer = color_transfer; job->color_matrix = color_matrix; - if(pv->qsv_config.async_depth) - qsv_encode->m_mfxVideoParam.AsyncDepth = pv->qsv_config.async_depth; - - pv->max_async_depth = pv->qsv_config.async_depth; - pv->async_depth = 0; + qsv_encode->m_mfxVideoParam.AsyncDepth = job->qsv_async_depth; + pv->max_async_depth = job->qsv_async_depth; + pv->async_depth = 0; char *rc_method = NULL; switch (qsv_encode->m_mfxVideoParam.mfx.RateControlMethod){ @@ -586,7 +584,8 @@ int qsv_enc_init(av_qsv_context *qsv, hb_work_private_t *pv) if(pv->is_sys_mem){ - qsv_encode->surface_num = FFMIN( qsv_encode->request[0].NumFrameSuggested + pv->qsv_config.async_depth,AV_QSV_SURFACE_NUM ); + qsv_encode->surface_num = FFMIN(qsv_encode->request[0].NumFrameSuggested + + pv->job->qsv_async_depth, AV_QSV_SURFACE_NUM); if(qsv_encode->surface_num <= 0 ) qsv_encode->surface_num = AV_QSV_SURFACE_NUM; @@ -1397,9 +1396,6 @@ int qsv_param_parse( av_qsv_config* config, const char *name, const char *value) if(!config) return QSV_PARAM_BAD_CONFIG; - if(!strcmp(name,QSV_NAME_async_depth)) - config->async_depth = FFMAX( atoi(value),0 ); - else if(!strcmp(name,QSV_NAME_target_usage)) config->target_usage = FFMAX( atoi(value),0 ); else diff --git a/libhb/qsv_filter.c b/libhb/qsv_filter.c index 31f938824..e3f794f1c 100644 --- a/libhb/qsv_filter.c +++ b/libhb/qsv_filter.c @@ -48,7 +48,6 @@ struct hb_filter_private_s int is_frc_used; av_qsv_space *vpp_space; - av_qsv_config qsv_config; // FRC param(s) mfxExtVPPFrameRateConversion frc_config; @@ -110,25 +109,6 @@ static int filter_init( av_qsv_context* qsv, hb_filter_private_t * pv ){ av_qsv_add_context_usage(qsv,HAVE_THREADS); - - qsv_param_set_defaults(&pv->qsv_config); - hb_dict_t * qsv_opts = NULL; - if( pv->job->advanced_opts != NULL && *pv->job->advanced_opts != '\0' ) - qsv_opts = hb_encopts_to_dict( pv->job->advanced_opts, pv->job->vcodec ); - - int ret; - hb_dict_entry_t * entry = NULL; - while( ( entry = hb_dict_next( qsv_opts, entry ) ) ) - { - ret = qsv_param_parse( &pv->qsv_config, entry->key, entry->value ); - if( ret == QSV_PARAM_BAD_NAME ) - hb_log( "QSV options: Unknown suboption %s", entry->key ); - else - if( ret == QSV_PARAM_BAD_VALUE ) - hb_log( "QSV options: Bad argument %s=%s", entry->key, entry->value ? entry->value : "(null)" ); - } - hb_dict_free( &qsv_opts ); - // see params needed like at mediasdk-man.pdf:"Appendix A: Configuration Parameter Constraints" // for now - most will take from the decode { @@ -174,7 +154,7 @@ static int filter_init( av_qsv_context* qsv, hb_filter_private_t * pv ){ qsv_vpp->m_mfxVideoParam.IOPattern = MFX_IOPATTERN_IN_OPAQUE_MEMORY | MFX_IOPATTERN_OUT_OPAQUE_MEMORY; - qsv_vpp->m_mfxVideoParam.AsyncDepth = pv->qsv_config.async_depth; + qsv_vpp->m_mfxVideoParam.AsyncDepth = pv->job->qsv_async_depth; memset(&qsv_vpp->request, 0, sizeof(mfxFrameAllocRequest)*2); diff --git a/test/test.c b/test/test.c index a38258b81..c97ec99b5 100644 --- a/test/test.c +++ b/test/test.c @@ -137,7 +137,8 @@ static int64_t stop_at_pts = 0; static int stop_at_frame = 0; static uint64_t min_title_duration = 10; #ifdef USE_QSV -static int qsv_decode = 1; +static int qsv_decode = 1; +static int qsv_async_depth = -1; #endif /* Exit cleanly on Ctrl-C */ @@ -1877,6 +1878,10 @@ static int HandleEvents( hb_handle_t * h ) } #ifdef USE_QSV + if (qsv_async_depth >= 0) + { + job->qsv_async_depth = qsv_async_depth; + } job->qsv_decode = qsv_decode; #endif @@ -3457,6 +3462,9 @@ if (hb_qsv_available()) fprintf( out, "### Intel Quick Sync Video------------------------------------------------------\n\n" " --disable-qsv-decoding Force software decoding of the video track.\n" + " --qsv-async-depth Specifies how many asynchronous operations should be\n" + " performed before the result is explicitly synchronized.\n" + " Default: 4. If zero, the value is not specified.\n" "\n" " Advanced encoding options, via --encopts=\"option1=value1:option2=value2\":\n" " - target-usage A range of numbers that indicate trade-offs between\n" @@ -3470,10 +3478,6 @@ if (hb_qsv_available()) " - gop-ref-dist Distance between I- or P- key frames; if it is zero,\n" " the GOP structure is unspecified.\n" " Note: If GopRefDist = 1, there are no B-frames used.\n" - " - async-depth Specifies how many asynchronous operations an\n" - " application performsbefore the application\n" - " explicitly synchronizes the result.\n" - " If zero, the value is not specified. Default is 4\n" " - mbbrc Setting this flag enables macroblock level bitrate\n" " control that generally improves subjective\n" " visual quality.\n" @@ -3646,6 +3650,7 @@ static int ParseOptions( int argc, char ** argv ) #define NORMALIZE_MIX 287 #define AUDIO_DITHER 288 #define QSV_BASELINE 289 + #define QSV_ASYNC_DEPTH 290 for( ;; ) { @@ -3657,6 +3662,7 @@ static int ParseOptions( int argc, char ** argv ) { "no-dvdnav", no_argument, NULL, DVDNAV }, #ifdef USE_QSV { "qsv-baseline", no_argument, NULL, QSV_BASELINE }, + { "qsv-async-depth", required_argument, NULL, QSV_ASYNC_DEPTH }, { "disable-qsv-decoding", no_argument, &qsv_decode, 0 }, #endif @@ -4275,8 +4281,8 @@ static int ParseOptions( int argc, char ** argv ) case MIN_DURATION: min_title_duration = strtol( optarg, NULL, 0 ); break; - case QSV_BASELINE: #ifdef USE_QSV + case QSV_BASELINE: if (hb_qsv_available()) { /* XXX: for testing workarounds */ @@ -4284,8 +4290,11 @@ static int ParseOptions( int argc, char ** argv ) hb_qsv_info->capabilities &= ~HB_QSV_CAP_OPTION2_BRC; hb_qsv_info->capabilities &= ~HB_QSV_CAP_OPTION2_LOOKAHEAD; } -#endif break; + case QSV_ASYNC_DEPTH: + qsv_async_depth = atoi(optarg); + break; +#endif default: fprintf( stderr, "unknown option (%s)\n", argv[cur_optind] ); return -1;