]> granicus.if.org Git - handbrake/commitdiff
QSV: move QSV-specific common code to dedicated files.
authorRodeo <tdskywalker@gmail.com>
Sat, 3 Aug 2013 10:53:25 +0000 (10:53 +0000)
committerRodeo <tdskywalker@gmail.com>
Sat, 3 Aug 2013 10:53:25 +0000 (10:53 +0000)
git-svn-id: svn://svn.handbrake.fr/HandBrake/branches/qsv@5679 b64f7644-9d1e-0410-96f1-a4d463321fa5

libhb/common.c
libhb/decavcodec.c
libhb/enc_qsv.c
libhb/hb.c
libhb/hb.h
libhb/qsv_common.c [new file with mode: 0644]
libhb/qsv_common.h [new file with mode: 0644]
test/test.c

index 225bc9c2b42095f8f95f91fa756b3f01945a3166..1a0fa5398dae5090b070bd4947c85f694ccb7c27 100644 (file)
 #include <ctype.h>
 #include <sys/time.h>
 
-#include "common.h"
-#include "lang.h"
 #include "hb.h"
+#include "lang.h"
+#include "common.h"
+#ifdef USE_QSV
+#include "qsv_common.h"
+#endif
 
 /**********************************************************************
  * Global variables
index 4092ef8eef0c0c383184503e18c905311fb12f16..8b0860fadbc9a5ebf92c13b9de6ed18e3e932441 100644 (file)
@@ -44,6 +44,7 @@
 
 #ifdef USE_QSV
 #include "enc_qsv.h"
+#include "qsv_common.h"
 #endif
 
 static void compute_frame_duration( hb_work_private_t *pv );
index 830412703970c61ea228204677c9fd29c7a91346..83a20482cc407de36312de377d5df19f0bde8da3 100644 (file)
@@ -29,6 +29,7 @@ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 #include <stdarg.h>
 #include "hb.h"
 #include "enc_qsv.h"
+#include "qsv_common.h"
 #include "h264_common.h"
 
 /**
index 804fa5d9f496138de594963ae11f121ed54a6e2b..96c28d259382b12688c5f4de56db3d04fb032696 100644 (file)
 #include <stdio.h>
 #include <unistd.h>
 #include <fcntl.h>
-#include "libavutil/cpu.h"
+
+#ifdef USE_QSV
+#include "qsv_common.h"
+#endif
 
 #if defined( SYS_MINGW )
 #include <io.h>
@@ -345,242 +348,6 @@ void hb_ff_set_sample_fmt(AVCodecContext *context, AVCodec *codec,
     }
 }
 
-/* Intel Quick Sync Video utilities */
-#ifdef USE_QSV
-// make the Intel QSV information available to the UIs
-hb_qsv_info_t *hb_qsv_info = NULL;
-
-// minimum supported version (currently 1.3, for Sandy Bridge support)
-#define HB_QSV_MINVERSION_MAJOR AV_QSV_MSDK_VERSION_MAJOR
-#define HB_QSV_MINVERSION_MINOR AV_QSV_MSDK_VERSION_MINOR
-
-// check available hardware & software versions against a minimum
-#define HB_QSV_MIN_HARDWARE(MAJOR, MINOR)           \
-    ((hb_qsv_info->hardware_version.Major >  MAJOR) || \
-     (hb_qsv_info->hardware_version.Major == MAJOR  && hb_qsv_info->hardware_version.Minor >= MINOR))
-#define HB_QSV_MIN_SOFTWARE(MAJOR, MINOR)           \
-    ((hb_qsv_info->software_version.Major >  MAJOR) || \
-     (hb_qsv_info->software_version.Major == MAJOR  && hb_qsv_info->software_version.Minor >= MINOR))
-
-static int hb_qsv_info_init()
-{
-    static int init_done = 0;
-    if (init_done)
-        return (hb_qsv_info == NULL);
-    init_done = 1;
-
-    hb_qsv_info = calloc(sizeof(*hb_qsv_info),1);
-    if (hb_qsv_info == NULL)
-    {
-        hb_error("hb_qsv_info_init: malloc failure");
-        return -1;
-    }
-
-    // detect the CPU platform to check for hardware-specific capabilities
-    if (av_get_cpu_flags() & AV_CPU_FLAG_SSE)
-    {
-        int eax, ebx, ecx, edx;
-        int family = 0, model = 0;
-
-        ff_cpu_cpuid(1, &eax, &ebx, &ecx, &edx);
-        family = ((eax >> 8) & 0xf) + ((eax >> 20) & 0xff);
-        model  = ((eax >> 4) & 0xf) + ((eax >> 12) & 0xf0);
-
-        // Intel 64 and IA-32 Architectures Software Developer's Manual, Vol. 2A
-        // Figure 3-8: Determination of Support for the Processor Brand String
-        // Table 3-17: Information Returned by CPUID Instruction
-        ff_cpu_cpuid(0x80000000, &eax, &ebx, &ecx, &edx);
-        if ((eax & 0x80000004) < 0x80000004)
-        {
-            int offset = 0;
-            ff_cpu_cpuid(0x80000002,
-                         &hb_qsv_info->cpu_name[offset],
-                         &hb_qsv_info->cpu_name[offset+4],
-                         &hb_qsv_info->cpu_name[offset+8],
-                         &hb_qsv_info->cpu_name[offset+12]);
-            offset += 16;
-            ff_cpu_cpuid(0x80000003,
-                         &hb_qsv_info->cpu_name[offset],
-                         &hb_qsv_info->cpu_name[offset+4],
-                         &hb_qsv_info->cpu_name[offset+8],
-                         &hb_qsv_info->cpu_name[offset+12]);
-            offset += 16;
-            ff_cpu_cpuid(0x80000004,
-                         &hb_qsv_info->cpu_name[offset],
-                         &hb_qsv_info->cpu_name[offset+4],
-                         &hb_qsv_info->cpu_name[offset+8],
-                         &hb_qsv_info->cpu_name[offset+12]);
-        }
-
-        // Intel 64 and IA-32 Architectures Software Developer's Manual, Vol. 3C
-        // Table 35-1: CPUID Signature Values of DisplayFamily_DisplayModel
-        if (family == 0x06)
-        {
-            switch (model)
-            {
-                case 0x2A:
-                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:
-                case 0x46:
-                    hb_qsv_info->cpu_platform = HB_CPU_PLATFORM_INTEL_HSW;
-                    break;
-                default:
-                    hb_qsv_info->cpu_platform = HB_CPU_PLATFORM_UNSPECIFIED;
-                    break;
-            }
-        }
-    }
-
-    mfxSession session;
-    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_OPTION2_BRC;
-            hb_qsv_info->capabilities |= HB_QSV_CAP_BITSTREAM_DTS;
-        }
-        if (HB_QSV_MIN_HARDWARE(1, 7))
-        {
-        if (hb_qsv_info->cpu_platform == HB_CPU_PLATFORM_INTEL_HSW)
-        {
-                hb_qsv_info->capabilities |= HB_QSV_CAP_OPTION2_LOOKAHEAD;
-        }
-    }
-        if (hb_qsv_info->cpu_platform == HB_CPU_PLATFORM_INTEL_HSW)
-    {
-            hb_qsv_info->capabilities |= HB_QSV_CAP_H264_BPYRAMID;
-        }
-    }
-    else if (hb_qsv_info->software_available)
-    {
-        if (HB_QSV_MIN_SOFTWARE(1, 6))
-        {
-            hb_qsv_info->capabilities |= HB_QSV_CAP_OPTION2_BRC;
-            hb_qsv_info->capabilities |= HB_QSV_CAP_BITSTREAM_DTS;
-            hb_qsv_info->capabilities |= HB_QSV_CAP_H264_BPYRAMID;
-        }
-    }
-
-    // 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 ||
-        hb_qsv_info->minimum_version.Minor != HB_QSV_MINVERSION_MINOR)
-    {
-        hb_error("hb_qsv_info_init: minimum version (%d.%d) was modified",
-                 hb_qsv_info->minimum_version.Major,
-                 hb_qsv_info->minimum_version.Minor);
-    }
-
-    // success
-    return 0;
-}
-
-// we don't need those beyond this point
-#undef HB_QSV_MINVERSION_MAJOR
-#undef HB_QSV_MINVERSION_MINOR
-#undef HB_QSV_MIN_HARDWARE
-#undef HB_QSV_MIN_SOFTWARE
-
-static void hb_qsv_info_print()
-{
-    if (hb_qsv_info == NULL)
-        return;
-
-    // is QSV available?
-    hb_log("Intel Quick Sync Video support: %s",
-           hb_qsv_info->qsv_available ? "yes": "no");
-    // print the hardware summary too
-    switch (hb_qsv_info->cpu_platform)
-    {
-        case HB_CPU_PLATFORM_INTEL_SNB:
-            hb_log(" - 2nd gen. Intel Core processor");
-            break;
-
-        case HB_CPU_PLATFORM_INTEL_IVB:
-            hb_log(" - 3rd gen. Intel Core processor");
-            break;
-
-        case HB_CPU_PLATFORM_INTEL_HSW:
-            hb_log(" - 4th gen. Intel Core processor");
-            break;
-
-        default:
-            break;
-    }
-
-    // skip leading whitespace to prettify
-    char *cpu_name = hb_qsv_info->cpu_name;
-    while (isspace(*cpu_name))
-    {
-        cpu_name++;
-    }
-    hb_log(" - hardware name:    %s", cpu_name);
-
-    // if we have Quick Sync Video support, also print the details
-    if (hb_qsv_info->qsv_available)
-    {
-        if (hb_qsv_info->hardware_available)
-        {
-            hb_log(" - hardware version: %d.%d (minimum: %d.%d)",
-                   hb_qsv_info->hardware_version.Major,
-                   hb_qsv_info->hardware_version.Minor,
-                   hb_qsv_info->minimum_version.Major,
-                   hb_qsv_info->minimum_version.Minor);
-        }
-        if (hb_qsv_info->software_available)
-        {
-            hb_log(" - software version: %d.%d (minimum: %d.%d)",
-                   hb_qsv_info->software_version.Major,
-                   hb_qsv_info->software_version.Minor,
-                   hb_qsv_info->minimum_version.Major,
-                   hb_qsv_info->minimum_version.Minor);
-        }
-    }
-}
-
-int hb_qsv_available()
-{
-    return hb_qsv_info != NULL && hb_qsv_info->qsv_available;
-}
-#endif // USE_QSV
-
 /**
  * Registers work objects, by adding the work object to a liked list.
  * @param w Handle to hb_work_object_t to register.
@@ -748,11 +515,6 @@ hb_handle_t * hb_init_dl( int verbose, int update_check )
 
     h->pause_lock = hb_lock_init();
 
-#ifdef USE_QSV
-    /* Intel Quick Sync Video */
-    hb_qsv_info_print();
-#endif
-
     /* Start library thread */
     hb_log( "hb_init: starting libhb thread" );
     h->die         = 0;
index 34bd93530a512b52c4f0c1ba839e3cd729c40db8..768a66feb381b65ced99ec1db28277e0c06fc449 100644 (file)
@@ -18,10 +18,6 @@ extern "C" {
 #include "common.h"
 #include "hb_dict.h"
 
-#ifdef USE_QSV
-#include "msdk/mfxvideo.h"
-#endif
-
 /* hb_init()
    Initializes a libhb session (launches his own thread, detects CPUs,
    etc) */
@@ -141,54 +137,6 @@ void          hb_global_close();
    Return the unique instance id of an libhb instance created by hb_init. */
 int hb_get_instance_id( hb_handle_t * h );
 
-#ifdef USE_QSV
-/*
- * Get & store all available Intel Quick Sync information:
- *
- * - general availability
- * - available implementations (hardware-accelerated, software fallback, etc.)
- * - available codecs, filters, etc. for direct access (convenience)
- * - supported API version
- * - supported resolutions
- */
-typedef struct hb_qsv_info_s
-{
-    // availability
-    int qsv_available; // if this is 0, the rest must be ignored
-    int hardware_available, software_available;
-
-    // version information
-    mfxVersion minimum_version, hardware_version, software_version;
-
-    // supported version-specific or hardware-specific capabilities
-    int capabilities;
-#define HB_QSV_CAP_H264_BPYRAMID     1 << 0 // H.264: reference B-frames
-#define HB_QSV_CAP_BITSTREAM_DTS     1 << 1 // mfxBitStream: DecodeTimeStamp
-#define HB_QSV_CAP_OPTION2_BRC       1 << 2 // mfxExtCodingOption2: MBBRC/ExtBRC
-#define HB_QSV_CAP_OPTION2_LOOKAHEAD 1 << 3 // mfxExtCodingOption2: LookAhead
-
-    // if a feature depends on the cpu generation
-    enum
-    {
-        // list of microarchitecture codenames
-        HB_CPU_PLATFORM_UNSPECIFIED = 0,
-        HB_CPU_PLATFORM_INTEL_SNB,
-        HB_CPU_PLATFORM_INTEL_IVB,
-        HB_CPU_PLATFORM_INTEL_HSW,
-    }    cpu_platform;
-    char cpu_name[48];
-
-    // TODO: add available decoders, filters, encoders,
-    //       maximum decode and encode resolution, etc.
-} hb_qsv_info_t;
-
-/* Global Intel QSV information for use by the UIs */
-extern hb_qsv_info_t *hb_qsv_info;
-
-/* Whether QSV is available at all */
-int hb_qsv_available();
-#endif
-
 #ifdef __cplusplus
 }
 #endif
diff --git a/libhb/qsv_common.c b/libhb/qsv_common.c
new file mode 100644 (file)
index 0000000..60c3927
--- /dev/null
@@ -0,0 +1,234 @@
+/* qsv_common.c
+ *
+ * Copyright (c) 2003-2013 HandBrake Team
+ * This file is part of the HandBrake source code.
+ * Homepage: <http://handbrake.fr/>.
+ * It may be used under the terms of the GNU General Public License v2.
+ * For full terms see the file COPYING file or visit http://www.gnu.org/licenses/gpl-2.0.html
+ */
+
+#include "common.h"
+#include "qsv_common.h"
+
+// avoids a warning
+#include "libavutil/cpu.h"
+extern void ff_cpu_cpuid(int index, int *eax, int *ebx, int *ecx, int *edx);
+
+// make the Intel QSV information available to the UIs
+hb_qsv_info_t *hb_qsv_info = NULL;
+
+// availability and versions
+static mfxVersion qsv_hardware_version;
+static mfxVersion qsv_software_version;
+static mfxVersion qsv_minimum_version;
+static int qsv_hardware_available = 0;
+static int qsv_software_available = 0;
+static char cpu_name_buf[48];
+
+// check available Intel Media SDK version against a minimum
+#define HB_CHECK_MFX_VERSION(MFX_VERSION, MAJOR, MINOR) \
+    (MFX_VERSION.Major == MAJOR  && MFX_VERSION.Minor >= MINOR)
+
+int hb_qsv_available()
+{
+    return hb_qsv_info != NULL && (qsv_hardware_available ||
+                                   qsv_software_available);
+}
+
+int hb_qsv_info_init()
+{
+    static int init_done = 0;
+    if (init_done)
+        return (hb_qsv_info == NULL);
+    init_done = 1;
+
+    hb_qsv_info = calloc(1, sizeof(*hb_qsv_info));
+    if (hb_qsv_info == NULL)
+    {
+        hb_error("hb_qsv_info_init: alloc failure");
+        return -1;
+    }
+
+    hb_qsv_info->cpu_name = NULL;
+    // detect the CPU platform to check for hardware-specific capabilities
+    if (av_get_cpu_flags() & AV_CPU_FLAG_SSE)
+    {
+        int eax, ebx, ecx, edx;
+        int family = 0, model = 0;
+
+        ff_cpu_cpuid(1, &eax, &ebx, &ecx, &edx);
+        family = ((eax >> 8) & 0xf) + ((eax >> 20) & 0xff);
+        model  = ((eax >> 4) & 0xf) + ((eax >> 12) & 0xf0);
+
+        // Intel 64 and IA-32 Architectures Software Developer's Manual, Vol. 2A
+        // Figure 3-8: Determination of Support for the Processor Brand String
+        // Table 3-17: Information Returned by CPUID Instruction
+        ff_cpu_cpuid(0x80000000, &eax, &ebx, &ecx, &edx);
+        if ((eax & 0x80000004) < 0x80000004)
+        {
+            ff_cpu_cpuid(0x80000002,
+                         (int*)&cpu_name_buf[ 0], (int*)&cpu_name_buf[ 4],
+                         (int*)&cpu_name_buf[ 8], (int*)&cpu_name_buf[12]);
+            ff_cpu_cpuid(0x80000003,
+                         (int*)&cpu_name_buf[16], (int*)&cpu_name_buf[20],
+                         (int*)&cpu_name_buf[24], (int*)&cpu_name_buf[28]);
+            ff_cpu_cpuid(0x80000004,
+                         (int*)&cpu_name_buf[32], (int*)&cpu_name_buf[36],
+                         (int*)&cpu_name_buf[40], (int*)&cpu_name_buf[44]);
+
+            cpu_name_buf[47]      = '\0'; // just in case
+            hb_qsv_info->cpu_name = (const char*)cpu_name_buf;
+            while (isspace(*hb_qsv_info->cpu_name))
+            {
+                // skip leading whitespace to prettify
+                hb_qsv_info->cpu_name++;
+            }
+        }
+        
+        // Intel 64 and IA-32 Architectures Software Developer's Manual, Vol. 3C
+        // Table 35-1: CPUID Signature Values of DisplayFamily_DisplayModel
+        if (family == 0x06)
+        {
+            switch (model)
+            {
+                case 0x2A:
+                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:
+                case 0x46:
+                    hb_qsv_info->cpu_platform = HB_CPU_PLATFORM_INTEL_HSW;
+                    break;
+                default:
+                    hb_qsv_info->cpu_platform = HB_CPU_PLATFORM_UNSPECIFIED;
+                    break;
+            }
+        }
+    }
+
+    mfxSession session;
+    qsv_minimum_version.Major = HB_QSV_MINVERSION_MAJOR;
+    qsv_minimum_version.Minor = HB_QSV_MINVERSION_MINOR;
+
+    // check for software fallback
+    if (MFXInit(MFX_IMPL_SOFTWARE,
+                &qsv_minimum_version, &session) == MFX_ERR_NONE)
+    {
+        qsv_software_available = 1;
+        // our minimum is supported, but query the actual version
+        MFXQueryVersion(session, &qsv_software_version);
+        MFXClose(session);
+    }
+
+    // check for actual hardware support
+    if (MFXInit(MFX_IMPL_HARDWARE_ANY|MFX_IMPL_VIA_ANY,
+                &qsv_minimum_version, &session) == MFX_ERR_NONE)
+    {
+        qsv_hardware_available = 1;
+        // our minimum is supported, but query the actual version
+        MFXQueryVersion(session, &qsv_hardware_version);
+        MFXClose(session);
+    }
+
+    // check for version-specific or hardware-specific capabilities
+    // we only use software as a fallback, so check hardware first
+    if (qsv_hardware_available)
+    {
+        if (HB_CHECK_MFX_VERSION(qsv_hardware_version, 1, 6))
+        {
+            hb_qsv_info->capabilities |= HB_QSV_CAP_OPTION2_BRC;
+            hb_qsv_info->capabilities |= HB_QSV_CAP_BITSTREAM_DTS;
+        }
+        if (HB_CHECK_MFX_VERSION(qsv_hardware_version, 1, 7))
+        {
+            if (hb_qsv_info->cpu_platform == HB_CPU_PLATFORM_INTEL_HSW)
+            {
+                hb_qsv_info->capabilities |= HB_QSV_CAP_OPTION2_LOOKAHEAD;
+            }
+        }
+        if (hb_qsv_info->cpu_platform == HB_CPU_PLATFORM_INTEL_HSW)
+        {
+            hb_qsv_info->capabilities |= HB_QSV_CAP_H264_BPYRAMID;
+        }
+    }
+    else if (qsv_software_available)
+    {
+        if (HB_CHECK_MFX_VERSION(qsv_software_version, 1, 6))
+        {
+            hb_qsv_info->capabilities |= HB_QSV_CAP_OPTION2_BRC;
+            hb_qsv_info->capabilities |= HB_QSV_CAP_BITSTREAM_DTS;
+            hb_qsv_info->capabilities |= HB_QSV_CAP_H264_BPYRAMID;
+        }
+    }
+
+    // note: we pass a pointer to MFXInit but it never gets modified
+    //       let's make sure of it just to be safe though
+    if (qsv_minimum_version.Major != HB_QSV_MINVERSION_MAJOR ||
+        qsv_minimum_version.Minor != HB_QSV_MINVERSION_MINOR)
+    {
+        hb_error("hb_qsv_info_init: minimum version (%d.%d) was modified",
+                 qsv_minimum_version.Major,
+                 qsv_minimum_version.Minor);
+    }
+
+    // success
+    return 0;
+}
+
+// we don't need it beyond this point
+#undef HB_CHECK_MFX_VERSION
+
+void hb_qsv_info_print()
+{
+    if (hb_qsv_info == NULL)
+        return;
+
+    // is QSV available?
+    hb_log("Intel Quick Sync Video support: %s",
+           hb_qsv_available() ? "yes": "no");
+
+    // print the hardware summary too
+    hb_log(" - CPU name: %s", hb_qsv_info->cpu_name);
+    switch (hb_qsv_info->cpu_platform)
+    {
+        // Intel 64 and IA-32 Architectures Software Developer's Manual, Vol. 3C
+        // Table 35-1: CPUID Signature Values of DisplayFamily_DisplayModel
+        case HB_CPU_PLATFORM_INTEL_SNB:
+            hb_log(" - Intel microarchitecture Sandy Bridge");
+            break;
+        case HB_CPU_PLATFORM_INTEL_IVB:
+            hb_log(" - Intel microarchitecture Ivy Bridge");
+            break;
+        case HB_CPU_PLATFORM_INTEL_HSW:
+            hb_log(" - Intel microarchitecture Haswell");
+            break;
+        default:
+            break;
+    }
+
+    // if we have Quick Sync Video support, also print the details
+    if (hb_qsv_available())
+    {
+        if (qsv_hardware_available)
+        {
+            hb_log(" - Intel Media SDK hardware: API %d.%d (minimum: %d.%d)",
+                   qsv_hardware_version.Major,
+                   qsv_hardware_version.Minor,
+                   qsv_minimum_version.Major,
+                   qsv_minimum_version.Minor);
+        }
+        if (qsv_software_available)
+        {
+            hb_log(" - Intel Media SDK software: API %d.%d (minimum: %d.%d)",
+                   qsv_software_version.Major,
+                   qsv_software_version.Minor,
+                   qsv_minimum_version.Major,
+                   qsv_minimum_version.Minor);
+        }
+    }
+}
diff --git a/libhb/qsv_common.h b/libhb/qsv_common.h
new file mode 100644 (file)
index 0000000..95b68d4
--- /dev/null
@@ -0,0 +1,62 @@
+/* qsv_common.h
+ *
+ * Copyright (c) 2003-2013 HandBrake Team
+ * This file is part of the HandBrake source code.
+ * Homepage: <http://handbrake.fr/>.
+ * It may be used under the terms of the GNU General Public License v2.
+ * For full terms see the file COPYING file or visit http://www.gnu.org/licenses/gpl-2.0.html
+ */
+#ifndef HB_QSV_COMMON_H
+#define HB_QSV_COMMON_H
+
+#include "msdk/mfxvideo.h"
+#include "libavcodec/avcodec.h"
+
+/* Minimum Intel Media SDK version (currently 1.3, for Sandy Bridge support) */
+#define HB_QSV_MINVERSION_MAJOR AV_QSV_MSDK_VERSION_MAJOR
+#define HB_QSV_MINVERSION_MINOR AV_QSV_MSDK_VERSION_MINOR
+
+/*
+ * Get & store all available Intel Quick Sync information:
+ *
+ * - general availability
+ * - available implementations (hardware-accelerated, software fallback, etc.)
+ * - available codecs, filters, etc. for direct access (convenience)
+ * - supported API version
+ * - supported resolutions
+ */
+typedef struct hb_qsv_info_s
+{
+    // supported version-specific or hardware-specific capabilities
+    int capabilities;
+#define HB_QSV_CAP_H264_BPYRAMID     (1 << 0) // H.264: reference B-frames
+#define HB_QSV_CAP_BITSTREAM_DTS     (1 << 1) // mfxBitStream: DecodeTimeStamp
+#define HB_QSV_CAP_OPTION2_BRC       (1 << 2) // mfxExtCodingOption2: MBBRC/ExtBRC
+#define HB_QSV_CAP_OPTION2_LOOKAHEAD (1 << 3) // mfxExtCodingOption2: LookAhead
+
+    // if a feature depends on the cpu generation
+    enum
+    {
+        // list of microarchitecture codenames
+        HB_CPU_PLATFORM_UNSPECIFIED = 0,
+        HB_CPU_PLATFORM_INTEL_SNB,
+        HB_CPU_PLATFORM_INTEL_IVB,
+        HB_CPU_PLATFORM_INTEL_HSW,
+    }
+    cpu_platform;
+    const char *cpu_name;
+
+    // TODO: add available decoders, filters, encoders,
+    //       maximum decode and encode resolution, etc.
+} hb_qsv_info_t;
+
+/* Global Intel QSV information for use by the UIs */
+extern hb_qsv_info_t *hb_qsv_info;
+
+/* Intel Quick Sync Video utilities */
+int  hb_qsv_available();
+int  hb_qsv_info_init();
+void hb_qsv_info_print();
+
+#endif
index 2bae606d3d41bdfbca65b083084108a00db003d2..4e3d21d051d2c596a6ddb9688198a641275a51be 100644 (file)
@@ -27,7 +27,7 @@
 #include "parsecsv.h"
 
 #ifdef USE_QSV
-#include "libavcodec/qsv.h"
+#include "qsv_common.h"
 #endif
 
 #if defined( __APPLE_CC__ )