MIT License

技术解读

以下内容由 GitRead 中文社区 编辑团队基于项目 README 与官方资料整理, 结合中文开发者的常见使用场景补充技术选型建议。具体以项目官方文档为准。

Intel® Media SDK 深度技术分析

项目背景与痛点

Intel® Media SDK (MediaSDK) 是一款性能强劲、功能丰富的多媒体处理框架,专为 Intel 平台上高效视频编解码任务设计。这一项目不仅集成了 Intel 硬件加速特性,还提供了丰富的 API 接口,让用户能够灵活地调用各种多媒体处理功能。MediaSDK 直指在高性能计算环境中处理大量多媒体数据时无法兼顾性能和资源消耗的痛点,通过优化 Intel 平台上的并行处理能力,有效地提升了多媒体处理任务的效率。它能够显著减少资源占用,同时最大限度地提高处理速度,适合视频流处理、图像编辑等高负载任务。

核心技术揭秘

Intel® Media SDK 的设计采用了模块化架构,该结构包括了输入输出接口、参数解析器、核心编解码器、硬件加速引擎和状态管理器等层次。核心编解码器模块集成了多种编码/解码算法,可以根据不同的应用场景自动选择最优算法,如H.264、HEVC等视频编解码标准。而在硬件加速方面,MediaSDK 充分利用了 Intel CPU 的 SIMD 指令集和 GPU 的并行处理能力,提供了一套高效率的加速逻辑。

下图展示了 MediaSDK 的架构概览,从用户接口到内部处理流程,具体涉及到的关键路径和组件逻辑可见一斑。

graph TD A[用户接口] --> B[参数解析] B --> C1[编码任务] B --> C2[解码任务] C1 --> D{"参数校验"} C2 --> D D -->|"通过"| E[硬件加速引擎] D -->|"失败"| F[返回错误] E --> G{"编码选择"} G -->|"H.264"| H[执行H.264编码] G -->|"HEVC"| I[执行HEVC编码] C1 --> J[状态管理器] C2 --> J J --> K[资源分配] J --> L[日志管理] J --> M[上下文保存与恢复]

功能亮点与差异

相比同类竞品,MediaSDK 在多方面展现出其优势:

  1. 多样化的编解码支持:除H.264外,该库还支持HEVC、VP8、VP9等格式,满足大多数开发者需求。
  2. 无缝集成Intel硬件加速:自动识别并利用Intel CPU、GPU中的专用Media Processing硬件单元,以加速编码解码过程。
  3. API灵活易用:提供了C++、C、Python等多语言接口,方便快速开发且易于集成进现有代码基。

总体来说,它的杀手锏在于将硬件加速纳入编解码流程的同时还保持了较强的API可塑性。

应用场景与落地建议

在生产环境中应用Intel® Media SDK时需要注意几点:

  • 硬件兼容性:确保自身CPU具有Intel的一项或多项硬件加速技术,诸如Quick Sync Video。
  • 资源预留与负载测试:根据预期业务量进行适当的资源预分配,并做好负载测试,确保所使用的硬件资源稳定高效。
  • 适配特定的编解码格式:根据最终用户的使用习惯或是服务器存储限制等因素,选择符合条件的编解码标准。

综上所述,MediaSDK适用于视频流媒体传输、在线会议录制剪辑、游戏UI渲染等诸多范围广泛的视频处理场景。

综合评价

Intel® Media SDK 是一款具备高能效特点的多媒体处理库,它在设计之初就是为了解决Intel平台上的多媒体数据处理难题。从架构设计到功能实现,MediaSDK 聚焦核心场景,为开发者提供简洁高效的API支持。它的优势自然不言而喻,但同时也存在一定的硬件依赖性及配置成本。总的来说,无论是从技术整合、性能提升还是易用性来看,MediaSDK 都是值得推荐的,特别是对那些在Intel平台上有大规模视频处理需求的开发者来说。

关于

GitHub 原始描述(英文)

The Intel® Media SDK

描述取自 GitHub 官方 API,保持仓库作者书写的原文。

简要分析

热度分
1869
价值分
707
活跃状态
归档

语言占比

Assembly
Batchfile
C
C#
C++
CMake
M4
Makefile
Python
Shell
Starlark

Release

README

DISCONTINUATION OF PROJECT.

This project will no longer be maintained by Intel.

This project has been identified as having known security escapes.

Intel has ceased development and contributions including, but not limited to, maintenance, bug and security fixes, new releases, or updates, to this project.

Intel no longer accepts patches to this project.

If you have an ongoing need to use this project, are interested in independently developing it, or would like to maintain patches for the open source software community, please create your own fork of this project.

For continued support and access to new features, Intel® Media SDK users are encouraged to read the transition guide on upgrading from Intel® Media SDK to Intel® oneAPI Video Processing Library (oneVPL) <https://www.intel.com/content/www/us/en/docs/onevpl/upgrade-from-msdk/2023-1/overview.html>_, and to move to oneVPL as soon as possible.

Please also refer to the Media SDK Support Matrix_ for more information.

Intel® Media SDK

… contents::

Intel® Media SDK provides a plain C API to access hardware-accelerated video decode, encode and filtering on Intel® Gen graphics hardware platforms. Implementation written in C++ 11 with parts in C-for-Media (CM).

Supported video encoders: HEVC, AVC, MPEG-2, JPEG, VP9

Supported video decoders: HEVC, AVC, VP8, VP9, MPEG-2, VC1, JPEG, AV1

Supported video pre-processing filters: Color Conversion, Deinterlace, Denoise, Resize, Rotate, Composition

Media SDK is a part of Intel software stack for graphics:

  • Linux Graphics Drivers - General Purpose GPU Drivers for Linux* Operating Systems

    • Visit documentation <https://dgpu-docs.intel.com>_ for instructions on installing, deploying, and updating Intel software to enable general purpose GPU (GPGPU) capabilities for Linux*-based operating system distributions.

Media SDK Support Matrix

Pay attention that Intel® Media SDK lifetime comes to an end in a form it exists right now. In particular,

  • API 1.35 is projected to be the last API of 1.x API series
  • Runtime library (libmfxhw64.so.1) is not planned to get support of new Gen platforms

All future development is planned to happen within oneVPL <https://github.com/oneapi-src/oneVPL>_ library and its runtime implementations which are direct successors of Intel® Media SDK. oneVPL introduces API 2.x series which is not backward compatible with API 1.x series (some features got dropped <https://spec.oneapi.com/versions/latest/elements/oneVPL/source/appendix/VPL_intel_media_sdk.html>). New VPL Runtime for Gen Graphics <https://github.com/oneapi-src/oneVPL-intel-gpu> (libmfx-gen.so.1.2) comes with the support of new Gen platforms.

Pay attention that Intel® Media SDK has forward compatibility with new VPL runtime (libmfx-gen.so.1.2) in the scope of API features supported by both 1.x and 2.x API series. As such, if application is built against Intel® Media SDK, it still can work on new platforms. For that purpose Media SDK Dispatcher loads either Media SDK Legacy Runtime (libmfxhw64.so.1) or VPL Runtime (libmfx-gen.so.1.2) depending on the underlying platform. See support matrix below.

±---------------------±-------------±------------------------------------±------------------------------------+ | | | GPU supported by | Runtime loaded by libmfx.so.1 | ±---------------------±-------------±----------------±------------------±----------------±------------------+ | GPU | Type | libmfxhw64.so.1 | libmfx-gen.so.1.2 | libmfxhw64.so.1 | libmfx-gen.so.1.2 | +======================+==============+=================+===================+=================+===================+ | BDW (Broadwell) | Legacy | ✔ | | ✔ | | ±---------------------±-------------±----------------±------------------±----------------±------------------+ | SKL (Skylake) | Legacy | ✔ | | ✔ | | ±---------------------±-------------±----------------±------------------±----------------±------------------+ | BXT (Broxton) | Legacy | ✔ | | ✔ | | ±---------------------±-------------±----------------±------------------±----------------±------------------+ | APL (Apollo Lake) | Legacy | ✔ | | ✔ | | ±---------------------±-------------±----------------±------------------±----------------±------------------+ | KBLx [1] | Legacy | ✔ | | ✔ | | ±---------------------±-------------±----------------±------------------±----------------±------------------+ | ICL (Ice Lake) | Legacy | ✔ | | ✔ | | ±---------------------±-------------±----------------±------------------±----------------±------------------+ | JSL (Jasper Lake) | Legacy | ✔ | | ✔ | | ±---------------------±-------------±----------------±------------------±----------------±------------------+ | EHL (Elkhart Lake) | Legacy | ✔ | | ✔ | | ±---------------------±-------------±----------------±------------------±----------------±------------------+ | TGL (Tiger Lake) | Legacy | ✔ | ✔ | ✔ | | ±---------------------±-------------±----------------±------------------±----------------±------------------+ | DG1 (Xe MAX) | Legacy | ✔ | ✔ | ✔ | | ±---------------------±-------------±----------------±------------------±----------------±------------------+ | SG1 | Legacy | ✔ | | ✔ | | ±---------------------±-------------±----------------±------------------±----------------±------------------+ | RKL (Rocket Lake) | Legacy | ✔ | ✔ | ✔ | | ±---------------------±-------------±----------------±------------------±----------------±------------------+ | ADL-S (Alder Lake S) | VPL | | ✔ | | ✔ | ±---------------------±-------------±----------------±------------------±----------------±------------------+ | ADL-P (Alder Lake P) | VPL | | ✔ | | ✔ | ±---------------------±-------------±----------------±------------------±----------------±------------------+ | Future platforms… | VPL | | ✔ | | ✔ | ±---------------------±-------------±----------------±------------------±----------------±------------------+ | Multi GPU | Legacy + VPL | See above | ✔ | via env var [2] | ±---------------------±-------------±----------------±------------------±----------------±------------------+

Notes:

  • [1] KBLx is one of: KBL (Kaby Lake), CFL (Coffe Lake), WHL (Whiskey Lake), CML (Comet Lake), AML (Amber Lake)

  • [2] On the multi GPU system which has both “Legacy” and “VPL” GPUs Media SDK Dispatcher loads Media SDK Legacy Runtime (libmfxhw64.so.1) by default. VPL Runtime (libmfx-gen.so.1.2) or Media SDK Runtime (libmfxhw64.so.1) can be explicitly selected via the following environment variable::

    export INTEL_MEDIA_RUNTIME=ONEVPL # for VPL Runtime: libmfx-gen.so.1.2 or export INTEL_MEDIA_RUNTIME=MSDK # for Media SDK Runtime: libmfxhw64.so.1

Dependencies

Intel Media SDK depends on LibVA <https://github.com/intel/libva/>. This version of Intel Media SDK is compatible with the open source Intel Media Driver for VAAPI <https://github.com/intel/media-driver>.

License

Intel Media SDK is licensed under MIT license. See LICENSE <./LICENSE>_ for details.

How to contribute

See CONTRIBUTING <./CONTRIBUTING.md>_ for details. Thank you!

Documentation

To get copy of Media SDK documentation use Git* with LFS <https://git-lfs.github.com/>_ support.

Please find full documentation under the ./doc <./doc>_ folder. Key documents:

  • Media SDK Manual <./doc/mediasdk-man.md>_

  • Additional Per-Codec Manuals:

    • Media SDK JPEG Manual <./doc/mediasdkjpeg-man.md>_
    • Media SDK VP8 Manual <./doc/mediasdkvp8-man.md>_
  • Advanced Topics:

    • Media SDK User Plugins Manual <./doc/mediasdkusr-man.md>_
    • Media SDK FEI Manual <./doc/mediasdkfei-man.md>_
    • Media SDK HEVC FEI Manual <./doc/mediasdkhevcfei-man.md>_
    • MFE Overview <./doc/MFE-Overview.md>_
    • HEVC FEI Overview <./doc/HEVC_FEI_overview.pdf>_
    • Interlace content support in HEVC encoder <./doc/mediasdk_hevc_interlace_whitepaper.md>_

Generic samples information is available in Media Samples Guide <./doc/samples/Media_Samples_Guide_Linux.md>_

Linux Samples Readme Documents:

  • Sample Multi Transcode <./doc/samples/readme-multi-transcode_linux.md>_
  • Sample Decode <./doc/samples/readme-decode_linux.md>_
  • Sample Encode <./doc/samples/readme-encode_linux.md>_
  • Sample VPP <./doc/samples/readme-vpp_linux.md>_
  • Metrics Monitor <./doc/samples/readme-metrics_monitor_linux.md>_

Visit our Github Wiki <https://github.com/Intel-Media-SDK/MediaSDK/wiki>_ for the detailed setting and building instructions, runtime tips and other information.

Tutorials

  • Tutorials Overview <./doc/tutorials/mediasdk-tutorials-readme.md>_
  • Tutorials Command Line Reference <./doc/tutorials/mediasdk-tutorials-cmd-reference.md>_

Products which use Media SDK

Use Media SDK via popular frameworks:

  • FFmpeg <http://ffmpeg.org/>_ via ffmpeg-qsv <https://trac.ffmpeg.org/wiki/Hardware/QuickSync>_ plugins
  • GStreamer <https://gstreamer.freedesktop.org/>_ via plugins set included into gst-plugins-bad <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad>_

Learn best practises and borrow fragments for final solutions:

  • https://github.com/intel/media-delivery

    • This collection of samples demonstrates best practices to achieve optimal video quality and performance on Intel GPUs for content delivery networks. Check out the demo, recommended command lines and quality and performance measuring tools.

Use Media SDK via other Intel products:

  • OpenVINO Toolkit <https://github.com/openvinotoolkit/openvino>_

    • This toolkit allows developers to deploy pre-trained deep learning models through a high-level C++ Inference Engine API integrated with application logic.
  • Open Visual Cloud <https://github.com/OpenVisualCloud>_

    • The Open Visual Cloud is a set of open source software stacks (with full end-to-end sample pipelines) for media, analytics, graphics and immersive media, optimized for cloud native deployment on commercial-off-the-shelf x86 CPU architecture.

System requirements

Operating System:

  • Linux x86-64 fully supported
  • Linux x86 only build
  • Windows (not all features are supported in Windows build - see Known Limitations for details)

Software:

  • `LibVA https://github.com/intel/libva)

  • VAAPI backend driver:

    • Intel Media Driver for VAAPI <https://github.com/intel/media-driver>_
  • Some features require CM Runtime library (part of Intel Media Driver for VAAPI <https://github.com/intel/media-driver>_ package)

Hardware: Intel platforms supported by the Intel Media Driver for VAAPI <https://github.com/intel/media-driver>_

Media SDK test and sample applications may require additional software packages (for example, X Server, Wayland, LibDRM, etc.) to be functional.

Operating System: Windows (experimental)

Requires Microsoft Visual Studio 2017 for building.

How to build

Build steps


Get sources with the following Git* command (pay attention that to get full Media SDK sources bundle it is required to have Git* with `LFS <https://git-lfs.github.com/>`_
support)::

  git clone https://github.com/Intel-Media-SDK/MediaSDK msdk
  cd msdk

To configure and build Media SDK install cmake version 3.6 or later and run the following commands::

  mkdir build && cd build
  cmake ..
  make
  make install

Media SDK depends on a number of packages which are identified and checked for the proper version during configuration stage. Please, make sure to install these packages to satisfy Media SDK requirements. After successful configuration 'make' will build Media SDK binaries and samples. The following cmake configuration options can be used to customize the build:

+--------------------+-----------------------------+----------------------------------------------------------------------------------------------------+
| Option             | Values                      | Description                                                                                        |
+====================+=============================+====================================================================================================+
| API                | master, latest, major.minor | Build mediasdk library with specified API. 'latest'                                                |
|                    |                             | will enable experimental features. 'master' will                                                   |
|                    |                             | configure the most recent available published API                                                  |
|                    |                             | (default: master).                                                                                 |
+--------------------+-----------------------------+----------------------------------------------------------------------------------------------------+
| ENABLE_OPENCL      | ``ON|OFF``                  | Enable OpenCL dependent code to be built (default: ON)                                             |
+--------------------+-----------------------------+----------------------------------------------------------------------------------------------------+
| ENABLE_X11_DRI3    | ``ON|OFF``                  | Enable X11 DRI3 dependent code to be built (default: OFF)                                          |
+--------------------+-----------------------------+----------------------------------------------------------------------------------------------------+
| ENABLE_WAYLAND     | ``ON|OFF``                  | Enable Wayland dependent code to be built (default: OFF)                                           |
+--------------------+-----------------------------+----------------------------------------------------------------------------------------------------+
| ENABLE_ITT         | ``ON|OFF``                  | Enable ITT (VTune) instrumentation support (default: OFF)                                          |
+--------------------+-----------------------------+----------------------------------------------------------------------------------------------------+
| ENABLE_TEXTLOG     | ``ON|OFF``                  | Enable textlog trace support (default: OFF)                                                        |
+--------------------+-----------------------------+----------------------------------------------------------------------------------------------------+
| ENABLE_STAT        | ``ON|OFF``                  | Enable stat trace support (default: OFF)                                                           |
+--------------------+-----------------------------+----------------------------------------------------------------------------------------------------+
| BUILD_ALL          | ``ON|OFF``                  | Build all the BUILD_* targets below (default: OFF)                                                 |
+--------------------+-----------------------------+----------------------------------------------------------------------------------------------------+
| BUILD_RUNTIME      | ``ON|OFF``                  | Build mediasdk runtime, library and plugins (default: ON)                                          |
+--------------------+-----------------------------+----------------------------------------------------------------------------------------------------+
| BUILD_SAMPLES      | ``ON|OFF``                  | Build samples (default: ON)                                                                        |
+--------------------+-----------------------------+----------------------------------------------------------------------------------------------------+
| BUILD_TESTS        | ``ON|OFF``                  | Build unit tests (default: OFF)                                                                    |
+--------------------+-----------------------------+----------------------------------------------------------------------------------------------------+
| USE_SYSTEM_GTEST   | ``ON|OFF``                  | Use system gtest version instead of bundled (default: OFF)                                         |
+--------------------+-----------------------------+----------------------------------------------------------------------------------------------------+
| BUILD_TOOLS        | ``ON|OFF``                  | Build tools (default: OFF)                                                                         |
+--------------------+-----------------------------+----------------------------------------------------------------------------------------------------+
| MFX_ENABLE_KERNELS | ``ON|OFF``                  | Build mediasdk with                                                                                |
|                    |                             | `media shaders <https://github.com/Intel-Media-SDK/MediaSDK/wiki/Media-SDK-Shaders-(EU-Kernels)>`_ |
|                    |                             | support (default: ON)                                                                              |
+--------------------+-----------------------------+----------------------------------------------------------------------------------------------------+

The following cmake settings can be used to adjust search path locations for some components Media SDK build may depend on:

+------------------+-------------------+---------------------------------------------+
| Setting          | Values            | Description                                 |
+==================+===================+=============================================+
| CMAKE_ITT_HOME   | Valid system path | Location of ITT installation,               |
|                  |                   | takes precendence over ``CMAKE_VTUNE_HOME`` |
|                  |                   | (by default not defined)                    |
+------------------+-------------------+---------------------------------------------+
| CMAKE_VTUNE_HOME | Valid system path | Location of VTune installation              |
|                  |                   | (default: /opt/intel/vtune_amplifier)       |
+------------------+-------------------+---------------------------------------------+

Visit our [Github Wiki](https://github.com/Intel-Media-SDK/MediaSDK/wiki) for advanced topics on setting and building Media SDK.

Enabling Instrumentation and Tracing Technology (ITT)

To enable the Instrumentation and Tracing Technology (ITT) API you need to:

  • Either install Intel® VTune™ Amplifier <https://software.intel.com/en-us/intel-vtune-amplifier-xe>_
  • Or manually build an open source version (see IntelSEAPI <https://github.com/intel/IntelSEAPI/tree/master/ittnotify>_ for details)

and configure Media SDK with the -DENABLE_ITT=ON. In case of VTune it will be searched in the default location (/opt/intel/vtune_amplifier). You can adjust ITT search path with either CMAKE_ITT_HOME or CMAKE_VTUNE_HOME.

Once Media SDK was built with ITT support, enable it in a runtime creating per-user configuration file ($HOME/.mfx_trace) or a system wide configuration file (/etc/mfx_trace) with the following content::

Output=0x10

Known limitations

Windows build contains only samples and dispatcher library. MediaSDK library DLL is provided with Windows GFX driver.

Recommendations

  • In case of GCC compiler it is strongly recommended to use GCC version 6 or later since that’s the first GCC version which has non-experimental support of C++11 being used in Media SDK.

See also

Intel Media SDK: https://software.intel.com/en-us/media-sdk

评论

暂无评论