]> granicus.if.org Git - handbrake/commitdiff
QSV: create a dedicated option for "AsyncDepth".
authorRodeo <tdskywalker@gmail.com>
Sat, 3 Aug 2013 12:10:32 +0000 (12:10 +0000)
committerRodeo <tdskywalker@gmail.com>
Sat, 3 Aug 2013 12:10:32 +0000 (12:10 +0000)
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

libhb/common.c
libhb/common.h
libhb/decavcodec.c
libhb/enc_qsv.c
libhb/qsv_filter.c
test/test.c

index b328120a5d2163bc0dce4671fafbcd0cd20b055f..77f7ef0d73d3f95450095e08b71dcad1d3b44484 100644 (file)
@@ -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
 }
 
index 2e412757fcd2db39572240d2cfd8ac3d2c688196..bf7495e4e002cd58541cbd268edd9c0d2b5afa36 100644 (file)
@@ -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__
index 4c95b89cf620b04efc7d355fd0492a86d1d14c9e..fbb0a4ee1f5c4f1cdc52b8850c14ef55002b4535 100644 (file)
@@ -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
index 3557a0e56a2a050a0bfc559e10bcd8a136aa8195..4c57e9e97486c851d89a0c13e64cf397a9bab264 100644 (file)
@@ -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
index 31f938824cf8b576d644117f43aa84fcce8418bb..e3f794f1cb8f9654f069146b5e4c74fff064c5c6 100644 (file)
@@ -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);
 
index a38258b818093894bf2917a2464a6a121cf461aa..c97ec99b54581650023b3bda20156281a6e5bf3c 100644 (file)
@@ -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"
     "          <number>          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"
-    "          <number>          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"
     "          <number>          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;