]> granicus.if.org Git - handbrake/commitdiff
QSV: hb_qsv_info refactoring.
authorRodeo <tdskywalker@gmail.com>
Sun, 23 Jun 2013 18:09:20 +0000 (18:09 +0000)
committerRodeo <tdskywalker@gmail.com>
Sun, 23 Jun 2013 18:09:20 +0000 (18:09 +0000)
Rename hb_qsv_info_t.features to hb_qsv_info_t.capabilities

Group capabilities that are always found together to a single define.

Detect CPU platform earlier to be able to check for hardware-specific capabilities later on.

git-svn-id: svn://svn.handbrake.fr/HandBrake/branches/qsv@5598 b64f7644-9d1e-0410-96f1-a4d463321fa5

libhb/enc_qsv.c
libhb/hb.c
libhb/hb.h
test/test.c

index 6693b6f0183a931f8bd1fc7e76f0169a0cf1f3d4..c8c0e66e6c74ded1fe86aebca6e71b7c999d479c 100644 (file)
@@ -349,7 +349,7 @@ int qsv_enc_init( av_qsv_context* qsv, hb_work_private_t * pv ){
     }
 
     // version-specific encoder options
-    if (hb_qsv_info->features & HB_QSV_FEATURE_CODEC_OPTIONS_2)
+    if (hb_qsv_info->capabilities & HB_QSV_CAP_MSDK_1_6)
     {
         if ((entry = hb_dict_get(qsv_opts_dict, QSV_NAME_mbbrc)) != NULL && entry->value != NULL)
         {
@@ -643,7 +643,7 @@ int encqsvInit( hb_work_object_t * w, hb_job_t * job )
     // note: MKV only has PTS so it's unaffected
     if ((job->mux & HB_MUX_MASK_MP4)  &&
         (profile != PROFILE_BASELINE) &&
-        (hb_qsv_info->features & HB_QSV_FEATURE_DECODE_TIMESTAMPS) == 0)
+        (hb_qsv_info->capabilities & HB_QSV_CAP_MSDK_1_6) == 0)
     {
         if (hb_qsv_info->cpu_platform == HB_CPU_PLATFORM_INTEL_SNB)
         {
@@ -934,7 +934,7 @@ int encqsvWork( hb_work_object_t * w, hb_buffer_t ** buf_in,
                 // renderOffset -> DTS
                 buf->s.start = buf->s.renderOffset = task->bs->TimeStamp;
                 buf->s.stop  = buf->s.start + duration;
-                if (hb_qsv_info->features & HB_QSV_FEATURE_DECODE_TIMESTAMPS)
+                if (hb_qsv_info->capabilities & HB_QSV_CAP_MSDK_1_6)
                     buf->s.renderOffset = task->bs->DecodeTimeStamp;
 
                 if(pv->qsv_config.gop_ref_dist > 1)
index 0664e08f8743e33647f99570e7a2a593dc6b3f18..2f88816f6de4d4b41146adbf37799872289c2562 100644 (file)
@@ -377,55 +377,7 @@ static int hb_qsv_info_init()
         return -1;
     }
 
-    mfxSession session;
-    hb_qsv_info->features              = 0;
-    hb_qsv_info->minimum_version.Major = HB_QSV_MINVERSION_MAJOR;
-    hb_qsv_info->minimum_version.Minor = HB_QSV_MINVERSION_MINOR;
-    hb_qsv_info->software_available    = hb_qsv_info->hardware_available = 0;
-
-    // check for software fallback
-    if (MFXInit(MFX_IMPL_SOFTWARE,
-                &hb_qsv_info->minimum_version, &session) == MFX_ERR_NONE)
-    {
-        hb_qsv_info->software_available = 1;
-        // our minimum is supported, but query the actual version
-        MFXQueryVersion(session, &hb_qsv_info->software_version);
-        MFXClose(session);
-    }
-
-    // check for actual hardware support, Hardware acceleration via any supported OS infrastructure
-    if (MFXInit(MFX_IMPL_HARDWARE_ANY|MFX_IMPL_VIA_ANY,
-                &hb_qsv_info->minimum_version, &session) == MFX_ERR_NONE)
-    {
-        hb_qsv_info->hardware_available = 1;
-        // our minimum is supported, but query the actual version
-        MFXQueryVersion(session, &hb_qsv_info->hardware_version);
-        MFXClose(session);
-    }
-
-    // support either implementation (at least for now)
-    hb_qsv_info->qsv_available = (hb_qsv_info->hardware_available ||
-                                  hb_qsv_info->software_available);
-
-    // check for version-dependent features
-    // we only use software as a fallback, so check hardware first
-    if (hb_qsv_info->hardware_available)
-    {
-        if (HB_QSV_MIN_HARDWARE(1, 6))
-        {
-            hb_qsv_info->features |= HB_QSV_FEATURE_DECODE_TIMESTAMPS;
-            hb_qsv_info->features |= HB_QSV_FEATURE_CODEC_OPTIONS_2;
-        }
-    }
-    else
-    {
-        if (HB_QSV_MIN_SOFTWARE(1, 6))
-        {
-            hb_qsv_info->features |= HB_QSV_FEATURE_DECODE_TIMESTAMPS;
-            hb_qsv_info->features |= HB_QSV_FEATURE_CODEC_OPTIONS_2;
-        }
-    }
-
+    // detect the CPU platform to check for hardware-specific capabilities
     if (av_get_cpu_flags() & AV_CPU_FLAG_SSE)
     {
         int eax, ebx, ecx, edx;
@@ -457,7 +409,7 @@ static int hb_qsv_info_init()
                          &hb_qsv_info->cpu_name[offset+8],
                          &hb_qsv_info->cpu_name[offset+12]);
         }
-
+        
         // Intel 64 and IA-32 Architectures Software Developer's Manual
         // Table 35-1. CPUID Signature Values of DisplayFamily_DisplayModel
         if (family == 0x06)
@@ -468,17 +420,14 @@ static int hb_qsv_info_init()
                 case 0x2D:
                     hb_qsv_info->cpu_platform = HB_CPU_PLATFORM_INTEL_SNB;
                     break;
-
                 case 0x3A:
                 case 0x3E:
                     hb_qsv_info->cpu_platform = HB_CPU_PLATFORM_INTEL_IVB;
                     break;
-
                 case 0x3C:
                 case 0x45:
                     hb_qsv_info->cpu_platform = HB_CPU_PLATFORM_INTEL_HSW;
                     break;
-
                 default:
                     hb_qsv_info->cpu_platform = HB_CPU_PLATFORM_UNSPECIFIED;
                     break;
@@ -486,6 +435,53 @@ static int hb_qsv_info_init()
         }
     }
 
+    mfxSession session;
+    hb_qsv_info->capabilities          = 0;
+    hb_qsv_info->minimum_version.Major = HB_QSV_MINVERSION_MAJOR;
+    hb_qsv_info->minimum_version.Minor = HB_QSV_MINVERSION_MINOR;
+    hb_qsv_info->software_available    = hb_qsv_info->hardware_available = 0;
+
+    // check for software fallback
+    if (MFXInit(MFX_IMPL_SOFTWARE,
+                &hb_qsv_info->minimum_version, &session) == MFX_ERR_NONE)
+    {
+        hb_qsv_info->software_available = 1;
+        // our minimum is supported, but query the actual version
+        MFXQueryVersion(session, &hb_qsv_info->software_version);
+        MFXClose(session);
+    }
+
+    // check for actual hardware support, Hardware acceleration via any supported OS infrastructure
+    if (MFXInit(MFX_IMPL_HARDWARE_ANY|MFX_IMPL_VIA_ANY,
+                &hb_qsv_info->minimum_version, &session) == MFX_ERR_NONE)
+    {
+        hb_qsv_info->hardware_available = 1;
+        // our minimum is supported, but query the actual version
+        MFXQueryVersion(session, &hb_qsv_info->hardware_version);
+        MFXClose(session);
+    }
+
+    // support either implementation (at least for now)
+    hb_qsv_info->qsv_available = (hb_qsv_info->hardware_available ||
+                                  hb_qsv_info->software_available);
+
+    // check for version-specific or hardware-specific capabilities
+    // we only use software as a fallback, so check hardware first
+    if (hb_qsv_info->hardware_available)
+    {
+        if (HB_QSV_MIN_HARDWARE(1, 6))
+        {
+            hb_qsv_info->capabilities |= HB_QSV_CAP_MSDK_1_6;
+        }
+    }
+    else
+    {
+        if (HB_QSV_MIN_SOFTWARE(1, 6))
+        {
+            hb_qsv_info->capabilities |= HB_QSV_CAP_MSDK_1_6;
+        }
+    }
+
     // note: we pass a pointer to MFXInit but it never gets modified
     //       let's make sure of it just to be safe though
     if (hb_qsv_info->minimum_version.Major != HB_QSV_MINVERSION_MAJOR ||
index eca9f0e842e6e298e2b11f0281d9b69e03156430..bd6ba55e9d042c6f287cee8273ac24490b1f872c 100644 (file)
@@ -160,10 +160,9 @@ typedef struct hb_qsv_info_s
     // version information
     mfxVersion minimum_version, hardware_version, software_version;
 
-    // supported version-dependent features
-    int features;
-#define HB_QSV_FEATURE_DECODE_TIMESTAMPS 0x0000001
-#define HB_QSV_FEATURE_CODEC_OPTIONS_2   0x0000002 // see mfxExtCodingOption2
+    // supported version-specific or hardware-specific capabilities
+    int capabilities;
+#define HB_QSV_CAP_MSDK_1_6 0x0000001
 
     // if a feature depends on the cpu generation
     enum
index 79381ab97ecf54a24b8e75b1569bc617ee859cb2..fc1c6cff7017ca6db98fd5d59e33b753d2d54b35 100644 (file)
@@ -4205,22 +4205,7 @@ static int ParseOptions( int argc, char ** argv )
                 if (hb_qsv_available())
                 {
                     /* XXX: for testing workarounds */
-                    hb_qsv_info->features     = 0;
-                    hb_qsv_info->cpu_platform = HB_CPU_PLATFORM_UNSPECIFIED;
-                    if (hb_qsv_info->hardware_available)
-                    {
-                        hb_qsv_info->hardware_version.Major =
-                            hb_qsv_info->minimum_version.Major;
-                        hb_qsv_info->hardware_version.Minor =
-                            hb_qsv_info->minimum_version.Minor;
-                    }
-                    if (hb_qsv_info->software_available)
-                    {
-                        hb_qsv_info->software_version.Major =
-                            hb_qsv_info->minimum_version.Major;
-                        hb_qsv_info->software_version.Minor =
-                            hb_qsv_info->minimum_version.Minor;
-                    }
+                    hb_qsv_info->capabilities &= ~HB_QSV_CAP_MSDK_1_6;
                 }
 #endif
                 break;