Add support for dynamic detection of supported codecs
H.264 and H.265 support is still not supported upstream, so it makes sense to autodetect each codec and only enable those that are supported. Signed-off-by: Ezequiel Garcia <ezequiel@collabora.com>
This commit is contained in:
@@ -76,6 +76,45 @@ if test "$USE_DRM" = "yes"; then
|
|||||||
CPPFLAGS="$saved_CPPFLAGS"
|
CPPFLAGS="$saved_CPPFLAGS"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
AC_MSG_CHECKING([for MPEG2 support])
|
||||||
|
AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
|
||||||
|
#include <linux/videodev2.h>
|
||||||
|
#ifndef V4L2_PIX_FMT_MPEG2_SLICE
|
||||||
|
# error macro not defined
|
||||||
|
#endif
|
||||||
|
]])], [WITH_MPEG2="yes"], [WITH_MPEG2="no"])
|
||||||
|
AC_MSG_RESULT([$WITH_MPEG2])
|
||||||
|
AM_CONDITIONAL([WITH_MPEG2], [test "$WITH_MPEG2" = "yes"])
|
||||||
|
if test "$WITH_MPEG2" = "yes"; then
|
||||||
|
AC_DEFINE([WITH_MPEG2], [1], [MPEG2 support detected])
|
||||||
|
fi
|
||||||
|
|
||||||
|
AC_MSG_CHECKING([for H.264 support])
|
||||||
|
AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
|
||||||
|
#include <linux/videodev2.h>
|
||||||
|
#ifndef V4L2_PIX_FMT_H264_SLICE
|
||||||
|
# error macro not defined
|
||||||
|
#endif
|
||||||
|
]])], [WITH_H264="yes"], [WITH_H264="no"])
|
||||||
|
AC_MSG_RESULT([$WITH_H264])
|
||||||
|
AM_CONDITIONAL([WITH_H264], [test "$WITH_H264" = "yes"])
|
||||||
|
if test "$WITH_H264" = "yes"; then
|
||||||
|
AC_DEFINE([WITH_H264], [1], [H.264 support detected])
|
||||||
|
fi
|
||||||
|
|
||||||
|
AC_MSG_CHECKING([for H.265 support])
|
||||||
|
AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
|
||||||
|
#include <linux/videodev2.h>
|
||||||
|
#ifndef V4L2_PIX_FMT_HEVC_SLICE
|
||||||
|
# error macro not defined
|
||||||
|
#endif
|
||||||
|
]])], [WITH_H265="yes"], [WITH_H265="no"])
|
||||||
|
AC_MSG_RESULT([$WITH_H265])
|
||||||
|
AM_CONDITIONAL([WITH_H265], [test "$WITH_H265" = "yes"])
|
||||||
|
if test "$WITH_H265" = "yes"; then
|
||||||
|
AC_DEFINE([WITH_H265], [1], [H.265 support detected])
|
||||||
|
fi
|
||||||
|
|
||||||
VA_VERSION=`$PKG_CONFIG --modversion libva`
|
VA_VERSION=`$PKG_CONFIG --modversion libva`
|
||||||
VA_MAJOR_VERSION=`echo "$VA_VERSION" | cut -d'.' -f1`
|
VA_MAJOR_VERSION=`echo "$VA_VERSION" | cut -d'.' -f1`
|
||||||
VA_MINOR_VERSION=`echo "$VA_VERSION" | cut -d'.' -f2`
|
VA_MINOR_VERSION=`echo "$VA_VERSION" | cut -d'.' -f2`
|
||||||
@@ -109,4 +148,7 @@ echo $PACKAGE configuration summary:
|
|||||||
echo
|
echo
|
||||||
echo VA-API version ................... : $VA_VERSION_STR
|
echo VA-API version ................... : $VA_VERSION_STR
|
||||||
echo VA-API drivers path .............. : $LIBVA_DRIVERS_PATH
|
echo VA-API drivers path .............. : $LIBVA_DRIVERS_PATH
|
||||||
|
echo H.264 support .................... : $WITH_H264
|
||||||
|
echo H.265 support .................... : $WITH_H265
|
||||||
|
echo MPEG2 support .................... : $WITH_MPEG2
|
||||||
echo
|
echo
|
||||||
|
|||||||
+13
-2
@@ -5,8 +5,19 @@ backend_ldflags = -module -avoid-version -no-undefined -Wl,--no-undefined
|
|||||||
backend_libs = -lpthread -ldl $(DRM_LIBS) $(LIBVA_DEPS_LIBS)
|
backend_libs = -lpthread -ldl $(DRM_LIBS) $(LIBVA_DEPS_LIBS)
|
||||||
|
|
||||||
backend_c = request.c object_heap.c config.c surface.c context.c buffer.c \
|
backend_c = request.c object_heap.c config.c surface.c context.c buffer.c \
|
||||||
mpeg2.c picture.c subpicture.c image.c v4l2.c video.c media.c utils.c \
|
picture.c subpicture.c image.c v4l2.c video.c media.c utils.c
|
||||||
h264.c h265.c
|
|
||||||
|
if WITH_MPEG2
|
||||||
|
backend_c += mpeg2.c
|
||||||
|
endif
|
||||||
|
|
||||||
|
if WITH_H264
|
||||||
|
backend_c += h264.c
|
||||||
|
endif
|
||||||
|
|
||||||
|
if WITH_H265
|
||||||
|
backend_c += h265.c
|
||||||
|
endif
|
||||||
|
|
||||||
backend_s = tiled_yuv.S
|
backend_s = tiled_yuv.S
|
||||||
|
|
||||||
|
|||||||
@@ -36,6 +36,8 @@
|
|||||||
#include "utils.h"
|
#include "utils.h"
|
||||||
#include "v4l2.h"
|
#include "v4l2.h"
|
||||||
|
|
||||||
|
#include "autoconfig.h"
|
||||||
|
|
||||||
VAStatus RequestCreateConfig(VADriverContextP context, VAProfile profile,
|
VAStatus RequestCreateConfig(VADriverContextP context, VAProfile profile,
|
||||||
VAEntrypoint entrypoint,
|
VAEntrypoint entrypoint,
|
||||||
VAConfigAttrib *attributes, int attributes_count,
|
VAConfigAttrib *attributes, int attributes_count,
|
||||||
@@ -111,6 +113,7 @@ VAStatus RequestQueryConfigProfiles(VADriverContextP context,
|
|||||||
unsigned int index = 0;
|
unsigned int index = 0;
|
||||||
bool found;
|
bool found;
|
||||||
|
|
||||||
|
#ifdef WITH_MPEG2
|
||||||
found = v4l2_find_format(driver_data->video_fd,
|
found = v4l2_find_format(driver_data->video_fd,
|
||||||
V4L2_BUF_TYPE_VIDEO_OUTPUT,
|
V4L2_BUF_TYPE_VIDEO_OUTPUT,
|
||||||
V4L2_PIX_FMT_MPEG2_SLICE);
|
V4L2_PIX_FMT_MPEG2_SLICE);
|
||||||
@@ -118,7 +121,10 @@ VAStatus RequestQueryConfigProfiles(VADriverContextP context,
|
|||||||
profiles[index++] = VAProfileMPEG2Simple;
|
profiles[index++] = VAProfileMPEG2Simple;
|
||||||
profiles[index++] = VAProfileMPEG2Main;
|
profiles[index++] = VAProfileMPEG2Main;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef WITH_H264
|
||||||
|
found = v4l2_find_format(driver_data->video_fd,
|
||||||
found = v4l2_find_format(driver_data->video_fd,
|
found = v4l2_find_format(driver_data->video_fd,
|
||||||
V4L2_BUF_TYPE_VIDEO_OUTPUT,
|
V4L2_BUF_TYPE_VIDEO_OUTPUT,
|
||||||
V4L2_PIX_FMT_H264_SLICE);
|
V4L2_PIX_FMT_H264_SLICE);
|
||||||
@@ -129,12 +135,15 @@ VAStatus RequestQueryConfigProfiles(VADriverContextP context,
|
|||||||
profiles[index++] = VAProfileH264MultiviewHigh;
|
profiles[index++] = VAProfileH264MultiviewHigh;
|
||||||
profiles[index++] = VAProfileH264StereoHigh;
|
profiles[index++] = VAProfileH264StereoHigh;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef WITH_H265
|
||||||
found = v4l2_find_format(driver_data->video_fd,
|
found = v4l2_find_format(driver_data->video_fd,
|
||||||
V4L2_BUF_TYPE_VIDEO_OUTPUT,
|
V4L2_BUF_TYPE_VIDEO_OUTPUT,
|
||||||
V4L2_PIX_FMT_HEVC_SLICE);
|
V4L2_PIX_FMT_HEVC_SLICE);
|
||||||
if (found && index < (V4L2_REQUEST_MAX_CONFIG_ATTRIBUTES - 1))
|
if (found && index < (V4L2_REQUEST_MAX_CONFIG_ATTRIBUTES - 1))
|
||||||
profiles[index++] = VAProfileHEVCMain;
|
profiles[index++] = VAProfileHEVCMain;
|
||||||
|
#endif
|
||||||
|
|
||||||
*profiles_count = index;
|
*profiles_count = index;
|
||||||
|
|
||||||
|
|||||||
@@ -41,6 +41,8 @@
|
|||||||
#include "utils.h"
|
#include "utils.h"
|
||||||
#include "v4l2.h"
|
#include "v4l2.h"
|
||||||
|
|
||||||
|
#include "autoconfig.h"
|
||||||
|
|
||||||
VAStatus RequestCreateContext(VADriverContextP context, VAConfigID config_id,
|
VAStatus RequestCreateContext(VADriverContextP context, VAConfigID config_id,
|
||||||
int picture_width, int picture_height, int flags,
|
int picture_width, int picture_height, int flags,
|
||||||
VASurfaceID *surfaces_ids, int surfaces_count,
|
VASurfaceID *surfaces_ids, int surfaces_count,
|
||||||
@@ -86,11 +88,15 @@ VAStatus RequestCreateContext(VADriverContextP context, VAConfigID config_id,
|
|||||||
memset(&context_object->dpb, 0, sizeof(context_object->dpb));
|
memset(&context_object->dpb, 0, sizeof(context_object->dpb));
|
||||||
|
|
||||||
switch (config_object->profile) {
|
switch (config_object->profile) {
|
||||||
|
|
||||||
|
#ifdef WITH_MPEG2
|
||||||
case VAProfileMPEG2Simple:
|
case VAProfileMPEG2Simple:
|
||||||
case VAProfileMPEG2Main:
|
case VAProfileMPEG2Main:
|
||||||
pixelformat = V4L2_PIX_FMT_MPEG2_SLICE;
|
pixelformat = V4L2_PIX_FMT_MPEG2_SLICE;
|
||||||
break;
|
break;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef WITH_H264
|
||||||
case VAProfileH264Main:
|
case VAProfileH264Main:
|
||||||
case VAProfileH264High:
|
case VAProfileH264High:
|
||||||
case VAProfileH264ConstrainedBaseline:
|
case VAProfileH264ConstrainedBaseline:
|
||||||
@@ -98,10 +104,13 @@ VAStatus RequestCreateContext(VADriverContextP context, VAConfigID config_id,
|
|||||||
case VAProfileH264StereoHigh:
|
case VAProfileH264StereoHigh:
|
||||||
pixelformat = V4L2_PIX_FMT_H264_SLICE;
|
pixelformat = V4L2_PIX_FMT_H264_SLICE;
|
||||||
break;
|
break;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef WITH_H265
|
||||||
case VAProfileHEVCMain:
|
case VAProfileHEVCMain:
|
||||||
pixelformat = V4L2_PIX_FMT_HEVC_SLICE;
|
pixelformat = V4L2_PIX_FMT_HEVC_SLICE;
|
||||||
break;
|
break;
|
||||||
|
#endif
|
||||||
|
|
||||||
default:
|
default:
|
||||||
status = VA_STATUS_ERROR_UNSUPPORTED_PROFILE;
|
status = VA_STATUS_ERROR_UNSUPPORTED_PROFILE;
|
||||||
|
|||||||
@@ -47,6 +47,8 @@
|
|||||||
#include "utils.h"
|
#include "utils.h"
|
||||||
#include "v4l2.h"
|
#include "v4l2.h"
|
||||||
|
|
||||||
|
#include "autoconfig.h"
|
||||||
|
|
||||||
static VAStatus codec_store_buffer(struct request_data *driver_data,
|
static VAStatus codec_store_buffer(struct request_data *driver_data,
|
||||||
VAProfile profile,
|
VAProfile profile,
|
||||||
struct object_surface *surface_object,
|
struct object_surface *surface_object,
|
||||||
@@ -71,13 +73,16 @@ static VAStatus codec_store_buffer(struct request_data *driver_data,
|
|||||||
|
|
||||||
case VAPictureParameterBufferType:
|
case VAPictureParameterBufferType:
|
||||||
switch (profile) {
|
switch (profile) {
|
||||||
|
#ifdef WITH_MPEG2
|
||||||
case VAProfileMPEG2Simple:
|
case VAProfileMPEG2Simple:
|
||||||
case VAProfileMPEG2Main:
|
case VAProfileMPEG2Main:
|
||||||
memcpy(&surface_object->params.mpeg2.picture,
|
memcpy(&surface_object->params.mpeg2.picture,
|
||||||
buffer_object->data,
|
buffer_object->data,
|
||||||
sizeof(surface_object->params.mpeg2.picture));
|
sizeof(surface_object->params.mpeg2.picture));
|
||||||
break;
|
break;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef WITH_H264
|
||||||
case VAProfileH264Main:
|
case VAProfileH264Main:
|
||||||
case VAProfileH264High:
|
case VAProfileH264High:
|
||||||
case VAProfileH264ConstrainedBaseline:
|
case VAProfileH264ConstrainedBaseline:
|
||||||
@@ -87,12 +92,15 @@ static VAStatus codec_store_buffer(struct request_data *driver_data,
|
|||||||
buffer_object->data,
|
buffer_object->data,
|
||||||
sizeof(surface_object->params.h264.picture));
|
sizeof(surface_object->params.h264.picture));
|
||||||
break;
|
break;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef WITH_H265
|
||||||
case VAProfileHEVCMain:
|
case VAProfileHEVCMain:
|
||||||
memcpy(&surface_object->params.h265.picture,
|
memcpy(&surface_object->params.h265.picture,
|
||||||
buffer_object->data,
|
buffer_object->data,
|
||||||
sizeof(surface_object->params.h265.picture));
|
sizeof(surface_object->params.h265.picture));
|
||||||
break;
|
break;
|
||||||
|
#endif
|
||||||
|
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
@@ -101,6 +109,7 @@ static VAStatus codec_store_buffer(struct request_data *driver_data,
|
|||||||
|
|
||||||
case VASliceParameterBufferType:
|
case VASliceParameterBufferType:
|
||||||
switch (profile) {
|
switch (profile) {
|
||||||
|
#ifdef WITH_H264
|
||||||
case VAProfileH264Main:
|
case VAProfileH264Main:
|
||||||
case VAProfileH264High:
|
case VAProfileH264High:
|
||||||
case VAProfileH264ConstrainedBaseline:
|
case VAProfileH264ConstrainedBaseline:
|
||||||
@@ -110,12 +119,15 @@ static VAStatus codec_store_buffer(struct request_data *driver_data,
|
|||||||
buffer_object->data,
|
buffer_object->data,
|
||||||
sizeof(surface_object->params.h264.slice));
|
sizeof(surface_object->params.h264.slice));
|
||||||
break;
|
break;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef WITH_H265
|
||||||
case VAProfileHEVCMain:
|
case VAProfileHEVCMain:
|
||||||
memcpy(&surface_object->params.h265.slice,
|
memcpy(&surface_object->params.h265.slice,
|
||||||
buffer_object->data,
|
buffer_object->data,
|
||||||
sizeof(surface_object->params.h265.slice));
|
sizeof(surface_object->params.h265.slice));
|
||||||
break;
|
break;
|
||||||
|
#endif
|
||||||
|
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
@@ -124,6 +136,7 @@ static VAStatus codec_store_buffer(struct request_data *driver_data,
|
|||||||
|
|
||||||
case VAIQMatrixBufferType:
|
case VAIQMatrixBufferType:
|
||||||
switch (profile) {
|
switch (profile) {
|
||||||
|
#ifdef WITH_MPEG2
|
||||||
case VAProfileMPEG2Simple:
|
case VAProfileMPEG2Simple:
|
||||||
case VAProfileMPEG2Main:
|
case VAProfileMPEG2Main:
|
||||||
memcpy(&surface_object->params.mpeg2.iqmatrix,
|
memcpy(&surface_object->params.mpeg2.iqmatrix,
|
||||||
@@ -131,7 +144,9 @@ static VAStatus codec_store_buffer(struct request_data *driver_data,
|
|||||||
sizeof(surface_object->params.mpeg2.iqmatrix));
|
sizeof(surface_object->params.mpeg2.iqmatrix));
|
||||||
surface_object->params.mpeg2.iqmatrix_set = true;
|
surface_object->params.mpeg2.iqmatrix_set = true;
|
||||||
break;
|
break;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef WITH_H264
|
||||||
case VAProfileH264Main:
|
case VAProfileH264Main:
|
||||||
case VAProfileH264High:
|
case VAProfileH264High:
|
||||||
case VAProfileH264ConstrainedBaseline:
|
case VAProfileH264ConstrainedBaseline:
|
||||||
@@ -141,13 +156,16 @@ static VAStatus codec_store_buffer(struct request_data *driver_data,
|
|||||||
buffer_object->data,
|
buffer_object->data,
|
||||||
sizeof(surface_object->params.h264.matrix));
|
sizeof(surface_object->params.h264.matrix));
|
||||||
break;
|
break;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef WITH_H265
|
||||||
case VAProfileHEVCMain:
|
case VAProfileHEVCMain:
|
||||||
memcpy(&surface_object->params.h265.iqmatrix,
|
memcpy(&surface_object->params.h265.iqmatrix,
|
||||||
buffer_object->data,
|
buffer_object->data,
|
||||||
sizeof(surface_object->params.h265.iqmatrix));
|
sizeof(surface_object->params.h265.iqmatrix));
|
||||||
surface_object->params.h265.iqmatrix_set = true;
|
surface_object->params.h265.iqmatrix_set = true;
|
||||||
break;
|
break;
|
||||||
|
#endif
|
||||||
|
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
@@ -169,13 +187,16 @@ static VAStatus codec_set_controls(struct request_data *driver_data,
|
|||||||
int rc;
|
int rc;
|
||||||
|
|
||||||
switch (profile) {
|
switch (profile) {
|
||||||
|
#ifdef WITH_MPEG2
|
||||||
case VAProfileMPEG2Simple:
|
case VAProfileMPEG2Simple:
|
||||||
case VAProfileMPEG2Main:
|
case VAProfileMPEG2Main:
|
||||||
rc = mpeg2_set_controls(driver_data, context, surface_object);
|
rc = mpeg2_set_controls(driver_data, context, surface_object);
|
||||||
if (rc < 0)
|
if (rc < 0)
|
||||||
return VA_STATUS_ERROR_OPERATION_FAILED;
|
return VA_STATUS_ERROR_OPERATION_FAILED;
|
||||||
break;
|
break;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef WITH_H264
|
||||||
case VAProfileH264Main:
|
case VAProfileH264Main:
|
||||||
case VAProfileH264High:
|
case VAProfileH264High:
|
||||||
case VAProfileH264ConstrainedBaseline:
|
case VAProfileH264ConstrainedBaseline:
|
||||||
@@ -185,12 +206,15 @@ static VAStatus codec_set_controls(struct request_data *driver_data,
|
|||||||
if (rc < 0)
|
if (rc < 0)
|
||||||
return VA_STATUS_ERROR_OPERATION_FAILED;
|
return VA_STATUS_ERROR_OPERATION_FAILED;
|
||||||
break;
|
break;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef WITH_H265
|
||||||
case VAProfileHEVCMain:
|
case VAProfileHEVCMain:
|
||||||
rc = h265_set_controls(driver_data, context, surface_object);
|
rc = h265_set_controls(driver_data, context, surface_object);
|
||||||
if (rc < 0)
|
if (rc < 0)
|
||||||
return VA_STATUS_ERROR_OPERATION_FAILED;
|
return VA_STATUS_ERROR_OPERATION_FAILED;
|
||||||
break;
|
break;
|
||||||
|
#endif
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return VA_STATUS_ERROR_UNSUPPORTED_PROFILE;
|
return VA_STATUS_ERROR_UNSUPPORTED_PROFILE;
|
||||||
|
|||||||
Reference in New Issue
Block a user