Skip to content

Commit

Permalink
vaapi: Add build support
Browse files Browse the repository at this point in the history
  • Loading branch information
xlz committed Feb 15, 2016
1 parent 560b80e commit 52c5a61
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 1 deletion.
24 changes: 23 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ OPTION(BUILD_OPENNI2_DRIVER "Build OpenNI2 driver" ON)
OPTION(ENABLE_CXX11 "Enable C++11 support" OFF)
OPTION(ENABLE_OPENCL "Enable OpenCL support" ON)
OPTION(ENABLE_OPENGL "Enable OpenGL support" ON)
OPTION(ENABLE_VAAPI "Enable VA-API support" ON)

IF(MSVC)
# suppress several "possible loss of data" warnings, and
Expand Down Expand Up @@ -170,9 +171,31 @@ IF(APPLE)
ENDIF(VIDEOTOOLBOX_LIBRARY)
ENDIF(APPLE)

IF(ENABLE_VAAPI)
IF(PKG_CONFIG_FOUND)
PKG_CHECK_MODULES(VAAPI libva libva-drm)
ENDIF()
FIND_PACKAGE(JPEG)

IF(VAAPI_FOUND AND JPEG_FOUND)
SET(LIBFREENECT2_WITH_VAAPI_SUPPORT 1)

INCLUDE_DIRECTORIES(${VAAPI_INCLUDE_DIRS})

LIST(APPEND SOURCES
src/vaapi_rgb_packet_processor.cpp
)
LIST(APPEND LIBRARIES
${VAAPI_LIBRARIES}
${JPEG_LIBRARY}
)
ENDIF()
ENDIF(ENABLE_VAAPI)

IF(LIBFREENECT2_WITH_VT_SUPPORT)
FIND_PACKAGE(TurboJPEG)
ELSE()
# VAAPI can fail to start at runtime. It must have a fallback.
FIND_PACKAGE(TurboJPEG REQUIRED)
ENDIF()

Expand All @@ -192,7 +215,6 @@ IF(TurboJPEG_FOUND)
LIST(APPEND LIBFREENECT2_DLLS
${TurboJPEG_DLL}
)

ENDIF()

IF(ENABLE_OPENGL)
Expand Down
2 changes: 2 additions & 0 deletions include/libfreenect2/config.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@

#cmakedefine LIBFREENECT2_WITH_VT_SUPPORT

#cmakedefine LIBFREENECT2_WITH_VAAPI_SUPPORT

#cmakedefine LIBFREENECT2_WITH_TURBOJPEG_SUPPORT

#cmakedefine LIBFREENECT2_THREADING_STDLIB
Expand Down
7 changes: 7 additions & 0 deletions src/packet_pipeline.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,13 @@ static RgbPacketProcessor *getDefaultRgbPacketProcessor()
{
#if defined(LIBFREENECT2_WITH_VT_SUPPORT)
return new VTRgbPacketProcessor();
#elif defined(LIBFREENECT2_WITH_VAAPI_SUPPORT)
RgbPacketProcessor *vaapi = new VaapiRgbPacketProcessor();
if (vaapi->good())
return vaapi;
else
delete vaapi;
return new TurboJpegRgbPacketProcessor();
#elif defined(LIBFREENECT2_WITH_TURBOJPEG_SUPPORT)
return new TurboJpegRgbPacketProcessor();
#else
Expand Down

0 comments on commit 52c5a61

Please sign in to comment.