### Build and Install Intel® VPL on Windows Source: https://github.com/intel/libvpl/blob/main/INSTALL.md These commands are for building and installing the Intel® VPL on Windows using a command prompt. It includes cloning the repo, setting the install path, bootstrapping, and using CMake for building and installation with a Release configuration. ```bat git clone https://github.com/intel/libvpl cd libvpl set VPL_INSTALL_DIR=%cd%\..\_vplinstall script\bootstrap.bat cmake -B _build -DCMAKE_INSTALL_PREFIX=%VPL_INSTALL_DIR% cmake --build _build --config Release cmake --install _build --config Release ``` -------------------------------- ### Basic Project Setup with VPL Source: https://github.com/intel/libvpl/blob/main/examples/api2x/hello-vpp/CMakeLists.txt Configures a basic C++ executable project, sets source files, and links against the VPL dispatcher library. Ensure VPL is installed and findable by CMake. ```cmake cmake_minimum_required(VERSION 3.13.0) project(hello-vpp) set(TARGET hello-vpp) set(SOURCES src/hello-vpp.cpp) add_executable(${TARGET} ${SOURCES}) find_package(VPL REQUIRED) target_link_libraries(${TARGET} VPL::dispatcher) ``` -------------------------------- ### Build and Install Intel® VPL on Linux Source: https://github.com/intel/libvpl/blob/main/INSTALL.md Use these commands to clone the repository, set the installation directory, bootstrap dependencies, configure with CMake, build, and install the Intel® VPL on a Linux system. ```bash git clone https://github.com/intel/libvpl cd libvpl export VPL_INSTALL_DIR=`pwd`/../_vplinstall sudo script/bootstrap cmake -B _build -DCMAKE_INSTALL_PREFIX=$VPL_INSTALL_DIR cmake --build _build cmake --install _build ``` -------------------------------- ### Install Project Targets Source: https://github.com/intel/libvpl/blob/main/libvpl/test/ext/googletest/googlemock/CMakeLists.txt Installs the Google Mock and Google Mock Main targets, along with their associated headers and libraries, according to the project's installation rules. ```cmake install_project(gmock gmock_main) ``` -------------------------------- ### Configure Video Processing Source: https://github.com/intel/libvpl/blob/main/doc/spec/source/programming_guide/VPL_prg_vpp.rst Example demonstrating video processing configuration. Ensure necessary structures are initialized before use. ```c++ #include "vpl/mfxvpl.h" // ... mfxStatus sts = MFX_ERR_NONE; mfxVideoParam param; // Initialize param structure with desired video processing parameters // ... sts = VPLVideoProcessing_Init(session, ¶m); if (sts != MFX_ERR_NONE) { // Handle error } // ... // Cleanup VPLVideoProcessing_Close(session); ``` -------------------------------- ### Basic CMake Project Setup Source: https://github.com/intel/libvpl/blob/main/examples/api2x/hello-encode/CMakeLists.txt Sets up the minimum CMake version, project name, and default build type. Ensures a 64-bit build on Windows if not specified. ```cmake cmake_minimum_required(VERSION 3.13.0) project(hello-encode) ``` ```cmake if(WIN32 AND CMAKE_SIZEOF_VOID_P EQUAL 4) set(CMAKE_LIBRARY_ARCHITECTURE x86) endif() ``` ```cmake if(WIN32) if(NOT DEFINED CMAKE_GENERATOR_PLATFORM) set(CMAKE_GENERATOR_PLATFORM x64 CACHE STRING "") message(STATUS "Generator Platform set to ${CMAKE_GENERATOR_PLATFORM}") endif() endif() ``` ```cmake set(TARGET hello-encode) set(SOURCES src/hello-encode.cpp) ``` ```cmake if(NOT CMAKE_BUILD_TYPE) message( STATUS "Default CMAKE_BUILD_TYPE not set using Release with Debug Info") set(CMAKE_BUILD_TYPE "RelWithDebInfo" CACHE STRING "Choose build type from: None Debug Release RelWithDebInfo MinSizeRel" FORCE) endif() ``` ```cmake add_executable(${TARGET} ${SOURCES}) ``` ```cmake if(MSVC) add_definitions(-D_CRT_SECURE_NO_WARNINGS) if(NOT DEFINED ENV{VSCMD_VER}) set(CMAKE_MSVCIDE_RUN_PATH $ENV{PATH}) endif() endif() ``` -------------------------------- ### Install Linux Prerequisites Source: https://github.com/intel/libvpl/blob/main/examples/api1x_core/legacy-encode/README.md Installs necessary packages for building and running the legacy-encode sample on a Linux system. Ensure you have CMake, build-essential, pkg-config, and VA-API related libraries. ```bash apt update apt install -y cmake build-essential pkg-config libva-dev libva-drm2 vainfo ``` -------------------------------- ### Install Library and Runtime Components Source: https://github.com/intel/libvpl/blob/main/libvpl/CMakeLists.txt Installs the target library to the appropriate destination directory based on the INSTALL_LIB flag. Runtime components are placed in the binary directory. ```cmake if(INSTALL_LIB) install( TARGETS ${TARGET} LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT ${VPL_COMPONENT_LIB} NAMELINK_SKIP RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT ${VPL_COMPONENT_LIB}) ``` -------------------------------- ### Import Shared Surface Example Source: https://github.com/intel/libvpl/blob/main/doc/spec/source/programming_guide/VPL_prg_surface_sharing.rst Demonstrates importing a shared surface for VPL operations. Ensure internal memory management is enabled. ```c++ #include "vpl/mfxdispatcher.h" #include "vpl/mfxvideo.h" #include // ... (rest of the code for import example) ``` -------------------------------- ### Initialize Media SDK Session (1.x API) Source: https://github.com/intel/libvpl/blob/main/examples/tutorials/01_transition/README.md Demonstrates initializing an Intel Media SDK session using the 1.x API (MFXInit). This is the starting point for transitioning applications. ```c++ sts = MFXInit(impl, &ver, &session); ``` -------------------------------- ### Install Development Components (Unix/Windows) Source: https://github.com/intel/libvpl/blob/main/libvpl/CMakeLists.txt Installs development-related files, including CMake configuration and pkgconfig files, for the target. Handles platform-specific archive installations for Windows. ```cmake if(INSTALL_DEV) install( TARGETS ${TARGET} LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT ${VPL_COMPONENT_DEV} NAMELINK_ONLY) if(WIN32) install(TARGETS ${TARGET} ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT ${VPL_COMPONENT_DEV}) endif() file(RELATIVE_PATH cmake_rel_prefix ${CMAKE_INSTALL_FULL_LIBDIR}/cmake/vpl ${CMAKE_INSTALL_PREFIX}) file(RELATIVE_PATH cmake_rel_libdir ${CMAKE_INSTALL_FULL_LIBDIR}/cmake/vpl ${CMAKE_INSTALL_FULL_LIBDIR}) file(RELATIVE_PATH cmake_rel_incdir ${CMAKE_INSTALL_FULL_LIBDIR}/cmake/vpl ${CMAKE_INSTALL_FULL_INCLUDEDIR}) file(RELATIVE_PATH cmake_rel_bindir ${CMAKE_INSTALL_FULL_LIBDIR}/cmake/vpl ${CMAKE_INSTALL_FULL_BINDIR}) configure_file(cmake/VPLConfig.cmake.in cmake/VPLConfig.cmake @ONLY) configure_file(cmake/VPLConfigVersion.cmake.in cmake/VPLConfigVersion.cmake @ONLY) install( FILES "${CMAKE_CURRENT_BINARY_DIR}/cmake/VPLConfig.cmake" "${CMAKE_CURRENT_BINARY_DIR}/cmake/VPLConfigVersion.cmake" DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/vpl" COMPONENT ${VPL_COMPONENT_DEV}) file(RELATIVE_PATH pc_rel_prefix ${CMAKE_INSTALL_FULL_LIBDIR}/pkgconfig ${CMAKE_INSTALL_PREFIX}) file(RELATIVE_PATH pc_rel_libdir ${CMAKE_INSTALL_FULL_LIBDIR}/pkgconfig ${CMAKE_INSTALL_FULL_LIBDIR}) file(RELATIVE_PATH pc_rel_incdir ${CMAKE_INSTALL_FULL_LIBDIR}/pkgconfig ${CMAKE_INSTALL_FULL_INCLUDEDIR}) set(pc_rel_prefix "$\{pcfiledir}/${pc_rel_prefix}") set(pc_rel_libdir "$\{pcfiledir}/${pc_rel_libdir}") set(pc_rel_incdir "$\{pcfiledir}/${pc_rel_incdir}") if(CMAKE_DL_LIBS) set(DL_LIBS "-l${CMAKE_DL_LIBS}") endif() if(MINGW) # being conservative by restricting to MinGW, these are probably ok for # WIN32 in general set(MINGW_LIBS "-lole32 -lgdi32 -luuid") endif() set(VPL_PKGCONFIG_DEPENDENT_LIBS "${DL_LIBS} ${CMAKE_THREAD_LIBS_INIT} ${MINGW_LIBS} ${CXX_LIB}") configure_file("pkgconfig/vpl.pc.in" "pkgconfig/vpl.pc" @ONLY) install( FILES "${CMAKE_CURRENT_BINARY_DIR}/pkgconfig/vpl.pc" DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig" COMPONENT ${VPL_COMPONENT_DEV}) ``` -------------------------------- ### Compile hello-multiadapter on Linux Source: https://github.com/intel/libvpl/blob/main/doc/multi-adapter-guide.md Use this command to compile the hello-multiadapter C++ source file on Linux. Ensure you have the VPL library installed. ```bash g++ -o hello-multiadapter hello-multiadapter.cpp -lvpl -DONEVPL_EXPERIMENTAL ``` -------------------------------- ### Install OpenVINO 2025.0.0 on Ubuntu Source: https://github.com/intel/libvpl/blob/main/examples/interop/vpl-infer/README.md Installs Intel® Distribution of OpenVINO™ Toolkit 2025.0.0 using apt repository. Ensure Intel GPG keys are added first. ```bash wget https://apt.repos.intel.com/intel-gpg-keys/GPG-PUB-KEY-INTEL-SW-PRODUCTS.PUB sudo apt-key add GPG-PUB-KEY-INTEL-SW-PRODUCTS.PUB echo "deb https://apt.repos.intel.com/openvino/2025 ubuntu24 main" | sudo tee /etc/apt/sources.list.d/intel-openvino-2025.list sudo apt-get update sudo apt-get install openvino-2025.0.0 ``` -------------------------------- ### Initialize Workload on Discrete Adapter in Legacy Mode C++ Source: https://github.com/intel/libvpl/blob/main/doc/spec/source/programming_guide/VPL_prg_hw.rst This example demonstrates workload initialization on a discrete adapter in legacy mode using Intel® VPL. It involves querying adapters and then initializing the session. ```c++ #include "mfxvideo.h" // ... mfxStatus sts = MFX_ERR_NONE; mfxIMPL impl = MFX_IMPL_HARDWARE; mfxVersion ver = {0, 1}; mfxSession session; // Initialize session sts = MFXInit(impl, &ver, &session); // ... MFXClose(session); ``` -------------------------------- ### Build VPL Infer Example Source: https://github.com/intel/libvpl/blob/main/examples/interop/vpl-infer/README.md Compile the vpl-infer example using CMake after navigating to its directory and ensuring the environment is set up. This command builds the release configuration. ```bash mkdir build && cd build cmake .. && cmake --build . --config release && cd release ``` -------------------------------- ### Configure Install Libdir Search (Unix) Source: https://github.com/intel/libvpl/blob/main/libvpl/CMakeLists.txt Enables runtime search for the installation library directory on Unix-like systems. Requires ENABLE_LIBDIR_IN_RUNTIME_SEARCH to be defined. ```cmake if(UNIX) if(ENABLE_LIBDIR_IN_RUNTIME_SEARCH) file(TO_CMAKE_PATH "${CMAKE_INSTALL_FULL_LIBDIR}" _install_libdir_search) target_compile_definitions( ${TARGET} PRIVATE INSTALL_LIBDIR_SEARCH="${_install_libdir_search}") message(STATUS "Enabled install libdir search: ${_install_libdir_search}") endif() endif() ``` -------------------------------- ### Startup Docker Container Source: https://github.com/intel/libvpl/blob/main/doc/spec/README.md Starts the Docker container with the build environment. This command should be executed after the Docker image has been built. ```console python3 doc/spec/build-spec.py dockerrun ``` -------------------------------- ### Basic CMake Project Setup Source: https://github.com/intel/libvpl/blob/main/examples/api2x/hello-decode/CMakeLists.txt Initializes a CMake project named 'hello-decode' and sets the minimum required CMake version. It also handles default build type settings. ```cmake cmake_minimum_required(VERSION 3.13.0) project(hello-decode) ``` ```cmake # Default install places 64 bit runtimes in the environment, so we want to do a # 64 bit build by default. if(WIN32 AND CMAKE_SIZEOF_VOID_P EQUAL 4) set(CMAKE_LIBRARY_ARCHITECTURE x86) endif() if(WIN32) if(NOT DEFINED CMAKE_GENERATOR_PLATFORM) set(CMAKE_GENERATOR_PLATFORM x64 CACHE STRING "") message(STATUS "Generator Platform set to ${CMAKE_GENERATOR_PLATFORM}") endif() endif() set(TARGET hello-decode) set(SOURCES src/hello-decode.cpp) # Set default build type to RelWithDebInfo if not specified if(NOT CMAKE_BUILD_TYPE) message( STATUS "Default CMAKE_BUILD_TYPE not set using Release with Debug Info") set(CMAKE_BUILD_TYPE "RelWithDebInfo" CACHE STRING "Choose build type from: None Debug Release RelWithDebInfo MinSizeRel" FORCE) endif() add_executable(${TARGET} ${SOURCES}) ``` -------------------------------- ### Set Up Linux Environment Source: https://github.com/intel/libvpl/blob/main/examples/api1x_core/legacy-encode/README.md Configures the environment variables for Intel® VPL on Linux. Replace `` with your actual Intel® VPL installation path. ```bash source /etc/vpl/vars.sh ``` -------------------------------- ### Run hello-multiadapter on Linux Source: https://github.com/intel/libvpl/blob/main/doc/multi-adapter-guide.md Execute the compiled hello-multiadapter application on Linux, providing the render node number as an argument. For example, to use the device at /dev/dri/renderD128, pass '128'. ```bash ./hello-multiadapter 128 ``` -------------------------------- ### Initialize CMake Project Source: https://github.com/intel/libvpl/blob/main/libvpl/test/ext/googletest/googletest/CMakeLists.txt Sets the minimum CMake version, policy, and project name with version and languages. This is a standard CMake setup for a project. ```cmake cmake_minimum_required(VERSION 3.5) cmake_policy(SET CMP0048 NEW) project(gtest VERSION ${GOOGLETEST_VERSION} LANGUAGES CXX C) ``` -------------------------------- ### Set Up Windows Environment Source: https://github.com/intel/libvpl/blob/main/examples/api1x_core/legacy-encode/README.md Configures the environment variables for Intel® VPL on Windows. Replace `` with your actual Intel® VPL installation path. This script is typically run from a Visual Studio command prompt. ```bat \etc\vpl\vars.bat ``` -------------------------------- ### Project Build Options Source: https://github.com/intel/libvpl/blob/main/CMakeLists.txt Defines project-wide build options such as building shared libraries, enabling tests, installing development files, and building examples. ```cmake option(BUILD_SHARED_LIBS "Build shared instead of static libraries." ON) option(BUILD_TESTS "Build tests." OFF) set(INSTALL_DEV ON CACHE BOOL "Install files that are only needed for development.") set(INSTALL_LIB ON CACHE BOOL "Install dispatcher library.") set(INSTALL_EXAMPLES ON CACHE BOOL "Install example source code and content.") set(BUILD_EXAMPLES OFF CACHE BOOL "Build examples when building dev package.") set(BUILD_EXPERIMENTAL ON CACHE BOOL "Build dispatcher with EXPERIMENTAL APIs.") ``` -------------------------------- ### Run Import (Encoding) Sample Source: https://github.com/intel/libvpl/blob/main/examples/api2x/hello-sharing-ocl/README.md Execute the import sample to encode a video file. The output file 'out.h265' will be generated in the build directory. ```bash Release\hello-sharing-ocl-import -i ..\..\..\content\cars_320x240.nv12 -w 320 -h 240 ``` -------------------------------- ### Run hello-sharing-dx11-import Sample Source: https://github.com/intel/libvpl/blob/main/examples/api2x/hello-sharing-dx11/README.md Execute this command to run the import sample. It encodes a raw video file into H.265 format. The output file 'out.h265' will be created in the build directory. ```bash Release\hello-sharing-dx11-import -i ..\..\..\content\cars_320x240.nv12 -w 320 -h 240 ``` -------------------------------- ### Install CMake Package Configuration Source: https://github.com/intel/libvpl/blob/main/libvpl/test/ext/googletest/googletest/CMakeLists.txt Installs CMake package configuration files (Config.cmake and ConfigVersion.cmake) to enable find_package() for the installed Google Test. This requires the INSTALL_GTEST option to be ON. ```cmake if (INSTALL_GTEST) include(CMakePackageConfigHelpers) set(targets_export_name ${cmake_package_name}Targets CACHE INTERNAL "") set(generated_dir "${CMAKE_CURRENT_BINARY_DIR}/generated" CACHE INTERNAL "") set(cmake_files_install_dir "${CMAKE_INSTALL_LIBDIR}/cmake/${cmake_package_name}") set(version_file "${generated_dir}/${cmake_package_name}ConfigVersion.cmake") write_basic_package_version_file(${version_file} VERSION ${GOOGLETEST_VERSION} COMPATIBILITY AnyNewerVersion) install(EXPORT ${targets_export_name} NAMESPACE ${cmake_package_name}:: DESTINATION ${cmake_files_install_dir}) set(config_file "${generated_dir}/${cmake_package_name}Config.cmake") configure_package_config_file("${gtest_SOURCE_DIR}/cmake/Config.cmake.in" "${config_file}" INSTALL_DESTINATION ${cmake_files_install_dir}) install(FILES ${version_file} ${config_file} DESTINATION ${cmake_files_install_dir}) endif() ``` -------------------------------- ### Run Import Sample Source: https://github.com/intel/libvpl/blob/main/examples/api2x/hello-sharing-vaapi/README.md Execute the import sample with input file, width, and height. The output is an encoded H.265 file. ```bash ./hello-sharing-vaapi-import -i ../../../content/cars_320x240.nv12 -w 320 -h 240 ``` -------------------------------- ### Basic Intel Media SDK Hello World Source: https://github.com/intel/libvpl/blob/main/examples/tutorials/01_transition/README.md A simple C++ program demonstrating a basic Intel Media SDK application. It initializes a session and prints success or failure messages. ```c++ #include "mfxvideo.h" #include int main() { mfxStatus sts = MFX_ERR_NONE; printf("Hello from Intel Media SDK\n"); mfxIMPL impl = MFX_IMPL_HARDWARE; mfxVersion ver = { 0, 1 }; mfxSession session = {}; sts = MFXInit(impl, &ver, &session); printf("Intel Media SDK 1.x MFXInit %s\n", (sts == MFX_ERR_NONE) ? "succeeded" : "failed"); if (sts == MFX_ERR_NONE) { // Print info about implementation loaded mfxVersion version = { 0, 0 }; MFXQueryVersion(session, &version); printf("Session loaded: ApiVersion = %d.%d \n", version.Major, version.Minor); // Clean up resources if (session) MFXClose(session); } else { printf("Initialization failed, please check system setup\n"); } return 0; } ``` -------------------------------- ### Build hello-multiadapter on Windows using CMake Source: https://github.com/intel/libvpl/blob/main/doc/multi-adapter-guide.md Follow these steps to build the hello-multiadapter application on Windows. This involves creating a build directory, configuring with CMake, and then building the project. ```bash md build cd build cmake -DCMAKE_BUILD_TYPE=Release .. cmake --build . --config Release cd Release ``` -------------------------------- ### Install Google Test Project Source: https://github.com/intel/libvpl/blob/main/libvpl/test/ext/googletest/googletest/CMakeLists.txt Installs the gtest and gtest_main targets using a custom install_project macro. This rule is typically used for deploying the built libraries. ```cmake install_project(gtest gtest_main) ``` -------------------------------- ### MFX_GUID_SURFACE_POOL Source: https://github.com/intel/libvpl/blob/main/doc/spec/source/API_ref/VPL_guids.rst This section details the MFX_GUID_SURFACE_POOL GUID, which is used within the Intel VPL API. ```APIDOC ## MFX_GUID_SURFACE_POOL ### Description Represents a GUID for a surface pool in Intel VPL. ### Method N/A (This is a GUID definition, not an API endpoint) ### Endpoint N/A ### Parameters N/A ### Request Example N/A ### Response N/A ``` -------------------------------- ### VideoDECODE_VPP Get Channel Parameters Source: https://github.com/intel/libvpl/blob/main/doc/spec/source/API_ref/VPL_func_vid_decode_vpp.rst Retrieves the channel parameters for the combined decode and VPP operation. ```APIDOC ## MFXVideoDECODE_VPP_GetChannelParam ### Description Retrieves the channel parameters for the combined decode and VPP operation. ### Method Not specified (likely a library function call, not an HTTP request) ### Endpoint Not applicable ### Parameters Not specified in the provided text. ### Request Example Not applicable ### Response Not specified in the provided text. ``` -------------------------------- ### Run Export (Decoding) Sample Source: https://github.com/intel/libvpl/blob/main/examples/api2x/hello-sharing-ocl/README.md Execute the export sample to decode a video file. The output file 'out.raw' will be generated in the build directory. ```bash Release\hello-sharing-ocl-export -i ..\..\..\content\cars_320x240.h265 ``` -------------------------------- ### Run Export Sample Source: https://github.com/intel/libvpl/blob/main/examples/api2x/hello-sharing-vaapi/README.md Execute the export sample with an input H.265 file. The output is a raw video file. ```bash ./hello-sharing-vaapi-export -i ../../../content/cars_320x240.h265 ``` -------------------------------- ### Build hello-sharing-vaapi Project Source: https://github.com/intel/libvpl/blob/main/examples/api2x/hello-sharing-vaapi/README.md Builds the Intel VPL hello-sharing-vaapi sample project using CMake. Use `-t ` to build a specific application. ```bash mkdir build cd build cmake .. -DBUILD_EXAMPLES=ON cmake --build . --config Release ``` -------------------------------- ### Build `vpl-infer` Program Source: https://github.com/intel/libvpl/blob/main/examples/interop/vpl-infer/README.md Builds the `vpl-infer` program using CMake. Assumes prerequisites are installed and source code is available. ```bash mkdir build && cd build cmake .. && cmake --build . --config release ``` -------------------------------- ### Run hello-sharing-dx11-export Sample Source: https://github.com/intel/libvpl/blob/main/examples/api2x/hello-sharing-dx11/README.md Execute this command to run the export sample. It decodes an H.265 file into a raw video format. The output file 'out.raw' will be created in the build directory. ```bash Release\hello-sharing-dx11-export -i ..\..\..\content\cars_320x240.h265 ``` -------------------------------- ### Build OpenCL SDK with CMake Source: https://github.com/intel/libvpl/blob/main/examples/api2x/hello-sharing-ocl/README.md Commands to clone, build, and install the OpenCL SDK using CMake for OpenCL dependencies. ```bash git clone --recursive https://github.com/KhronosGroup/OpenCL-SDK.git cmake -A x64 -T v143 -D OPENCL_SDK_BUILD_OPENGL_SAMPLES=OFF -B OpenCL-SDK\build -S OpenCL-SDK cmake --build OpenCL-SDK\build --config Release cmake --install OpenCL-SDK\build --prefix OpenCL-SDK\install set OpenCL_DIR=%cd%\OpenCL-SDK\install ``` -------------------------------- ### Define DX11 Targets and Sources Source: https://github.com/intel/libvpl/blob/main/examples/api2x/hello-sharing-dx11/CMakeLists.txt Defines the build targets for DX11 examples, specifying source files and include directories. ```cmake set(DX11_TARGETS hello-sharing-dx11-export hello-sharing-dx11-import) foreach(target IN LISTS DX11_TARGETS) set(TARGET ${target}) set(SOURCES src/${target}.cpp src/device-d3d11.cpp) add_executable(${target} ${SOURCES}) target_include_directories(${target} PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include) ``` -------------------------------- ### Run hello-multiadapter on Windows Source: https://github.com/intel/libvpl/blob/main/doc/multi-adapter-guide.md Execute the built hello-multiadapter application on Windows, specifying the adapter number as an argument. For instance, to use adapter 0, run 'hello-multiadapter 0'. ```bash hello-multiadapter 0 ``` -------------------------------- ### Run the sample on Windows Source: https://github.com/intel/libvpl/blob/main/examples/api2x/hello-encode-jpeg/README.md Executes the `hello-encode-jpeg` program with specified input file, width, and height on a Windows system. The output is saved to `Release\hello-encode-jpeg`. ```bat Release\hello-encode-jpeg -i ..\..\..\content\cars_320x240.nv12 -w 320 -h 240 ``` -------------------------------- ### Get VA Display from X11 Source: https://github.com/intel/libvpl/blob/main/doc/spec/source/programming_guide/VPL_prg_hw.rst Obtain the VA display handle from the X Window System. Ensure XOpenDisplay is called before this. ```cpp Display *x11_display; VADisplay va_display; x11_display = XOpenDisplay(current_display); va_display = vaGetDisplay(x11_display); MFXVideoCORE_SetHandle(session, MFX_HANDLE_VA_DISPLAY, (mfxHDL) va_display); ``` -------------------------------- ### Find and Link OpenCL Package Source: https://github.com/intel/libvpl/blob/main/examples/api2x/hello-sharing-ocl/CMakeLists.txt Locates the OpenCL package and makes it available for linking. Ensure OpenCL is installed and discoverable by CMake. ```cmake find_package(OpenCL CONFIG REQUIRED) set(OCL_TARGETS hello-sharing-ocl-export hello-sharing-ocl-import) foreach(target IN LISTS OCL_TARGETS) set(TARGET ${target}) set(SOURCES src/${target}.cpp src/device-d3d11.cpp src/device-ocl.cpp src/util.cpp) add_executable(${target} ${SOURCES}) target_include_directories(${target} PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include) target_link_libraries(${target} PRIVATE OpenCL::OpenCL) ``` -------------------------------- ### Initialize and Decode with Fused VPP Channels in C Source: https://context7.com/intel/libvpl/llms.txt Demonstrates setting up and using a fused decode and VPP pipeline for multiple output streams. Ensure correct session initialization and parameter configuration for both decoding and VPP channels. The output surfaces are processed based on their ChannelId. ```c #include "vpl/mfxvideo.h" int decode_with_vpp_channels(mfxSession session, FILE* source) { mfxBitstream bitstream = {}; mfxVideoParam decParams = {}; mfxVideoChannelParam* vppChannels[2]; mfxVideoChannelParam vppCh1 = {}, vppCh2 = {}; mfxSurfaceArray* surfArray = NULL; mfxStatus sts; // Setup decode parameters bitstream.MaxLength = 2000000; bitstream.Data = (mfxU8*)calloc(bitstream.MaxLength, sizeof(mfxU8)); bitstream.CodecId = MFX_CODEC_HEVC; bitstream.DataLength = fread(bitstream.Data, 1, bitstream.MaxLength, source); decParams.mfx.CodecId = MFX_CODEC_HEVC; decParams.IOPattern = MFX_IOPATTERN_OUT_SYSTEM_MEMORY; MFXVideoDECODE_DecodeHeader(session, &bitstream, &decParams); // Setup VPP channel 1: Scale to 640x480 vppCh1.VPP.FourCC = MFX_FOURCC_NV12; vppCh1.VPP.CropW = 640; vppCh1.VPP.CropH = 480; vppCh1.VPP.Width = 640; vppCh1.VPP.Height = 480; vppCh1.VPP.ChannelId = 1; // Unique channel ID // Setup VPP channel 2: Scale to 320x240 vppCh2.VPP.FourCC = MFX_FOURCC_NV12; vppCh2.VPP.CropW = 320; vppCh2.VPP.CropH = 240; vppCh2.VPP.Width = 320; vppCh2.VPP.Height = 240; vppCh2.VPP.ChannelId = 2; vppChannels[0] = &vppCh1; vppChannels[1] = &vppCh2; // Initialize fused decode+VPP sts = MFXVideoDECODE_VPP_Init(session, &decParams, vppChannels, 2); if (sts != MFX_ERR_NONE) return -1; // Decode with VPP processing while (1) { sts = MFXVideoDECODE_VPP_DecodeFrameAsync(session, &bitstream, NULL, 0, &surfArray); if (sts == MFX_ERR_NONE && surfArray) { // Process each output surface for (mfxU32 i = 0; i < surfArray->NumSurfaces; i++) { mfxFrameSurface1* surf = surfArray->Surfaces[i]; mfxU32 channelId = surf->Info.ChannelId; // Synchronize and process based on channel ID surf->FrameInterface->Synchronize(surf, 100); if (channelId == 0) { // Original decoded frame printf("Decoded frame: %dx%d\n", surf->Info.CropW, surf->Info.CropH); } else if (channelId == 1) { // VPP output 1 (640x480) printf("VPP Channel 1: %dx%d\n", surf->Info.CropW, surf->Info.CropH); } else if (channelId == 2) { // VPP output 2 (320x240) printf("VPP Channel 2: %dx%d\n", surf->Info.CropW, surf->Info.CropH); } surf->FrameInterface->Release(surf); } surfArray->Release(surfArray); } else if (sts == MFX_ERR_MORE_DATA) { break; } } MFXVideoDECODE_VPP_Close(session); free(bitstream.Data); return 0; } ``` -------------------------------- ### Get Shared Library Path for Implementation Source: https://github.com/intel/libvpl/blob/main/doc/spec/source/programming_guide/VPL_prg_session.rst Use MFXEnumImplementations with MFX_IMPLCAPS_IMPLPATH to retrieve the path of the shared library containing a specific implementation. ```c++ #include #include #include int main() { mfxStatus sts = MFX_ERR_NONE; mfxImplCapsLoader loader; // Initialize loader sts = loader.Init(); if (sts != MFX_ERR_NONE) { std::cerr << "Failed to initialize implementation caps loader." << std::endl; return 1; } // Request implementation path capabilities mfxImplCapsEntry entry; entry.Type = MFX_IMPLCAPS_IMPLPATH; // Iterate through all implementations for (mfxU32 i = 0; loader.GetEntry(i, &entry) == MFX_ERR_NONE; ++i) { // Check if the entry type is implementation path if (entry.Type == MFX_IMPLCAPS_IMPLPATH) { std::cout << "Implementation Path: " << entry.ImplementationPath << std::endl; } } return 0; } ``` -------------------------------- ### Transition Session Initialization Source: https://github.com/intel/libvpl/blob/main/examples/tutorials/01_transition/README.md Replace the MFXInit function with MFXLoad, filtering implementations, and MFXCreateSession for Intel VPL 2.x API. ```c++ #include "vpl/mfx.h" // ... other code ... // Create loader with a list of all available implementations mfxLoader loader = MFXLoad(); // Create a config filter so that loader list only contains HW implementation mfxConfig cfg = MFXCreateConfig(loader); mfxVariant implValue; implValue.Type = MFX_VARIANT_TYPE_U32; implValue.Data.U32 = MFX_IMPL_TYPE_HARDWARE; MFXSetConfigFilterProperty(cfg, (mfxU8 *)"mfxImplDescription.Impl", implValue); mfxSession session = {}; MFXCreateSession(loader, 0, &session); ``` -------------------------------- ### Configure libva Support on Unix Source: https://github.com/intel/libvpl/blob/main/examples/api1x_core/legacy-decode/CMakeLists.txt Enables and configures libva support for hardware acceleration on Unix-like systems. Requires libva and libva-drm to be installed. ```cmake if(UNIX) set(LIBVA_SUPPORT ON CACHE BOOL "Enable hardware support.") if(LIBVA_SUPPORT) find_package(PkgConfig REQUIRED) # note: pkg-config version for libva is *API* version pkg_check_modules(PKG_LIBVA IMPORTED_TARGET libva>=1.2) pkg_check_modules(PKG_LIBVA_DRM IMPORTED_TARGET libva-drm>=1.2) if(PKG_LIBVA_FOUND) target_compile_definitions(${TARGET} PUBLIC -DLIBVA_SUPPORT) set(CMAKE_THREAD_PREFER_PTHREAD TRUE) set(THREADS_PREFER_PTHREAD_FLAG TRUE) find_package(Threads REQUIRED) target_link_libraries(${TARGET} PkgConfig::PKG_LIBVA PkgConfig::PKG_LIBVA_DRM Threads::Threads) target_include_directories(${TARGET} PUBLIC ${PKG_LIBVA_INCLUDE_DIRS}) else() message( SEND_ERROR "libva not found: set LIBVA_SUPPORT=OFF to build ${TARGET} without libva support" ) endif() else() message(STATUS "Building ${TARGET} without hardware support") endif() endif() ``` -------------------------------- ### Set up OpenVINO Toolkit Environment Source: https://github.com/intel/libvpl/blob/main/examples/interop/vpl-infer/README.md Execute the setupvars.bat script to configure the environment variables for the OpenVINO™ toolkit. ```batch "C:\OpenVINO\setupvars.bat" ``` -------------------------------- ### Run Linux Program Source: https://github.com/intel/libvpl/blob/main/examples/api1x_core/legacy-vpp/README.md Executes the legacy-vpp sample on Linux. Provide the input raw video file path and its dimensions. ```bash ./legacy-vpp -i ../../../content/cars_320x240.i420 -w 320 -h 240 ``` -------------------------------- ### Set Parameter in mfxVideoParam Source: https://github.com/intel/libvpl/blob/main/doc/spec/source/programming_guide/VPL_prg_config.rst Example of setting a parameter directly within the mfxVideoParam structure using the SetParameter function. This is useful for basic configuration. ```c++ #include "vpl/mfxdispatcher.h" #include "vpl/mfxvideo.h" // ... mfxStatus SetParameter(mfxConfig config, mfxParamKey key, mfxParamValue value); int main() { // ... mfxConfig config = nullptr; // Create config object // ... mfxStatus sts = MFX_ERR_NONE; // Set parameter in mfxVideoParam sts = SetParameter(config, MFX_CONFIG_KEY_VIDEO_CODEC, MFX_CODEC_AVC); if (sts != MFX_ERR_NONE) { // Handle error } // ... return 0; } ``` -------------------------------- ### Expected Output for VPL Transition Source: https://github.com/intel/libvpl/blob/main/examples/tutorials/01_transition/README.md The expected output indicates successful initialization of the Intel Media SDK 1.x API through the Intel VPL dispatcher. The session reports an API version of 1.255, showing that while the underlying implementation might support newer versions, the application is limited to 1.x features due to the initialization method. ```shell Hello from Intel Media SDK Intel Media SDK 1.x MFXInit succeeded Session loaded: ApiVersion = 1.255 ``` -------------------------------- ### Initialize VPL Session with Dispatcher Filters Source: https://context7.com/intel/libvpl/llms.txt Demonstrates how to initialize an Intel VPL session using the dispatcher. It includes steps for creating a loader, applying filters for hardware implementation, HEVC decoder support, and API version 2.2+, and then creating the session. Remember to unload the loader and close the session when done. ```c #include "vpl/mfxdispatcher.h" #include "vpl/mfxvideo.h" int main() { mfxLoader loader = NULL; mfxConfig cfg[3]; mfxVariant cfgVal[3]; mfxSession session = NULL; mfxStatus sts; // Create the loader loader = MFXLoad(); if (loader == NULL) { printf("MFXLoad failed\n"); return -1; } // Filter 1: Require hardware implementation cfg[0] = MFXCreateConfig(loader); cfgVal[0].Type = MFX_VARIANT_TYPE_U32; cfgVal[0].Data.U32 = MFX_IMPL_TYPE_HARDWARE; sts = MFXSetConfigFilterProperty(cfg[0], (mfxU8*)"mfxImplDescription.Impl", cfgVal[0]); // Filter 2: Require HEVC decoder support cfg[1] = MFXCreateConfig(loader); cfgVal[1].Type = MFX_VARIANT_TYPE_U32; cfgVal[1].Data.U32 = MFX_CODEC_HEVC; sts = MFXSetConfigFilterProperty(cfg[1], (mfxU8*)"mfxImplDescription.mfxDecoderDescription.decoder.CodecID", cfgVal[1]); // Filter 3: Require API version 2.2 or newer cfg[2] = MFXCreateConfig(loader); cfgVal[2].Type = MFX_VARIANT_TYPE_U32; cfgVal[2].Data.U32 = (2 << 16) | 2; // Version 2.2 sts = MFXSetConfigFilterProperty(cfg[2], (mfxU8*)"mfxImplDescription.ApiVersion.Version", cfgVal[2]); // Create session with first matching implementation sts = MFXCreateSession(loader, 0, &session); if (sts != MFX_ERR_NONE) { printf("No implementation found\n"); MFXUnload(loader); return -1; } // Use session for decode/encode/VPP operations... MFXClose(session); MFXUnload(loader); return 0; } ``` -------------------------------- ### Configure Googletest with CMake Source: https://github.com/intel/libvpl/blob/main/libvpl/test/ext/googletest/CMakeLists.txt This CMake script sets up the build environment for Googletest. It includes options to conditionally build Googlemock and control the installation of Googletest. ```cmake cmake_minimum_required(VERSION 3.5) if (POLICY CMP0048) cmake_policy(SET CMP0048 NEW) endif (POLICY CMP0048) if (POLICY CMP0077) cmake_policy(SET CMP0077 NEW) endif (POLICY CMP0077) project(googletest-distribution) set(GOOGLETEST_VERSION 1.12.1) if(NOT CYGWIN AND NOT MSYS AND NOT ${CMAKE_SYSTEM_NAME} STREQUAL QNX) set(CMAKE_CXX_EXTENSIONS OFF) endif() enable_testing() include(CMakeDependentOption) include(GNUInstallDirs) #Note that googlemock target already builds googletest option(BUILD_GMOCK "Builds the googlemock subproject" ON) option(INSTALL_GTEST "Enable installation of googletest. (Projects embedding googletest may want to turn this OFF.)" ON) if(BUILD_GMOCK) add_subdirectory( googlemock ) else() add_subdirectory( googletest ) endif() ``` -------------------------------- ### Initialize VPL Session with 1.x API Source: https://github.com/intel/libvpl/blob/main/examples/tutorials/01_transition/README.md Initialize a media session using the 1.x API (MFXInit) after updating include paths to Intel VPL equivalents. This code is identical to the previous step's initialization, demonstrating minimal changes required for VPL integration. ```c++ #include "vpl/mfx.h" #include int main() { mfxStatus sts = MFX_ERR_NONE; printf("Hello from Intel Media SDK\n"); mfxIMPL impl = MFX_IMPL_HARDWARE; mfxVersion ver = { 0, 1 }; mfxSession session = {}; sts = MFXInit(impl, &ver, &session); printf("Intel Media SDK 1.x MFXInit %s\n", (sts == MFX_ERR_NONE) ? "succeeded" : "failed"); if (sts == MFX_ERR_NONE) { // Print info about implementation loaded mfxVersion version = { 0, 0 }; MFXQueryVersion(session, &version); printf("Session loaded: ApiVersion = %d.%d \n", version.Major, version.Minor); // Clean up resources if (session) MFXClose(session); } else { printf("Initialization failed, please check system setup\n"); } return 0; } ``` -------------------------------- ### Link Intel® VPL with CMake Source: https://github.com/intel/libvpl/blob/main/README.md Add this to your CMakeLists.txt to link your component (TARGET) to the Intel® VPL dispatcher. Ensure VPL is installed and discoverable by CMake. ```cmake if(WIN32 AND CMAKE_SIZEOF_VOID_P EQUAL 4) set(CMAKE_LIBRARY_ARCHITECTURE x86) endif() find_package(VPL REQUIRED) target_link_libraries(${TARGET} VPL::dispatcher) ``` -------------------------------- ### Set VPL and OCL Content Directories Source: https://github.com/intel/libvpl/blob/main/examples/api2x/hello-sharing-ocl/CMakeLists.txt Defines paths to VPL and OpenCL content directories. These are used for specifying input files for tests or examples. ```cmake set(VPL_CONTENT_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../../content CACHE PATH "Path to content.") set(OCL_CONTENT_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../../../libvpl/test/vpl-import-export/ocl_kernels CACHE PATH "Path to OCL content.") ``` -------------------------------- ### Get VA Display from DRM Source: https://github.com/intel/libvpl/blob/main/doc/spec/source/programming_guide/VPL_prg_hw.rst Obtain the VA display handle from the Direct Rendering Manager. Requires opening the DRM device and initializing VA. ```cpp int card; VADisplay va_display; card = open("/dev/dri/card0", O_RDWR); /* primary card */ va_display = vaGetDisplayDRM(card); vaInitialize(va_display, &major_version, &minor_version); MFXVideoCORE_SetHandle(session, MFX_HANDLE_VA_DISPLAY, (mfxHDL) va_display); ``` -------------------------------- ### CMakeLists.txt for hello-multiadapter Source: https://github.com/intel/libvpl/blob/main/doc/multi-adapter-guide.md This CMakeLists.txt file configures the build process for the hello-multiadapter project. It sets up compilation flags, finds the VPL library, and includes optional hardware support configuration for Linux. ```cmake # ############################################################################## # Copyright (C) Intel Corporation # # SPDX-License-Identifier: MIT ############################################################################## cmake_minimum_required(VERSION 3.13.0) project(hello-multiadapter) # Default install places 64 bit runtimes in the environment, so we want to do a # 64 bit build by default. if(WIN32) if(NOT DEFINED CMAKE_GENERATOR_PLATFORM) set(CMAKE_GENERATOR_PLATFORM x64 CACHE STRING "") message(STATUS "Generator Platform set to ${CMAKE_GENERATOR_PLATFORM}") endif() endif() set(TARGET hello-multiadapter) set(SOURCES src/hello-multiadapter.cpp) # set(CONTENTPATH ${CMAKE_CURRENT_SOURCE_DIR}/../../content) # set(RUNARGS -sw -i ${CONTENTPATH}/cars_320x240.h265) # Set default build type to RelWithDebInfo if not specified if(NOT CMAKE_BUILD_TYPE) message( STATUS "Default CMAKE_BUILD_TYPE not set using Release with Debug Info") set(CMAKE_BUILD_TYPE "RelWithDebInfo" CACHE STRING "Choose build type from: None Debug Release RelWithDebInfo MinSizeRel" FORCE) endif() add_compile_definitions(ONEVPL_EXPERIMENTAL) add_executable(${TARGET} ${SOURCES}) if(MSVC) add_definitions(-D_CRT_SECURE_NO_WARNINGS) if(NOT DEFINED ENV{VSCMD_VER}) set(CMAKE_MSVCIDE_RUN_PATH $ENV{PATH}) endif() endif() find_package(VPL REQUIRED) target_link_libraries(${TARGET} VPL::dispatcher) if(UNIX) set(LIBVA_SUPPORT ON CACHE BOOL "Enable hardware support.") if(LIBVA_SUPPORT) find_package(PkgConfig REQUIRED) # note: pkg-config version for libva is *API* version pkg_check_modules(PKG_LIBVA libva>=1.2 libva-drm>=1.2) if(PKG_LIBVA_FOUND) target_compile_definitions(${TARGET} PUBLIC -DLIBVA_SUPPORT) set(CMAKE_THREAD_PREFER_PTHREAD TRUE) set(THREADS_PREFER_PTHREAD_FLAG TRUE) find_package(Threads REQUIRED) target_link_libraries(${TARGET} ${PKG_LIBVA_LIBRARIES} ${PKG_THREAD_LIBRARIES}) target_include_directories(${TARGET} PUBLIC ${PKG_LIBVA_INCLUDE_DIRS}) else() message( SEND_ERROR "libva not found: set LIBVA_SUPPORT=OFF to build ${TARGET} without libva support" ) endif() else() message(STATUS "Building ${TARGET} without hardware support") endif() endif() ``` -------------------------------- ### Include Hermetic Build Configuration Source: https://github.com/intel/libvpl/blob/main/libvpl/test/ext/googletest/googlemock/CMakeLists.txt Includes CMake scripts for hermetic build setup, conditionally based on the determined Google Test directory. This is optional. ```cmake include("${gtest_dir}/cmake/hermetic_build.cmake" OPTIONAL) ``` -------------------------------- ### Build Intel VPL Project with 2.x Init Source: https://github.com/intel/libvpl/blob/main/examples/tutorials/01_transition/README.md These shell commands outline the steps to build the Intel VPL project, enabling the 2.x initialization feature using CMake. Navigate to the VPL directory and create a build subdirectory. ```shell cd VPL mkdir build cd build cmake .. -DUSE_VPL2X_INIT=on cmake --build . --config Release ``` -------------------------------- ### VPP Channel Latency Example Source: https://github.com/intel/libvpl/blob/main/doc/spec/source/programming_guide/VPL_prg_decoding.rst Demonstrates how different video processing channels might have varying latencies. This is relevant when using combined decode and VPP operations. ```c++ // Example illustrating potential latency differences between VPP channels // This snippet is conceptual and shows where latency considerations might apply. // Actual latency depends on the filters and processing pipeline. // Assume 'session' is an initialized mfxSession and 'bitstream' contains compressed data. // 'surf_array_out' is an mfxSurfaceArray to hold the output frames. mfxStatus sts = MFX_ERR_NONE; // When calling MFXVideoDECODE_VPP_DecodeFrameAsync, different channels // within surf_array_out might become ready at different times due to // varying processing latencies. // sts = MFXVideoDECODE_VPP_DecodeFrameAsync(session, &bitstream, &surf_array_out); // Application needs to be aware that frames for different channels // might not be available simultaneously after a single call. // The FrameID, TimeStamp, and FrameOrder fields can be used to match // decoded frames with specific VPP channels. ```