Skip to content

Commit

Permalink
configure: Cleanup setup for drm, opengl, egl and v4l2
Browse files Browse the repository at this point in the history
- remove the opengl_video and opengl_themepainter defines. They serve no
purpose (in fact the using_opengl define serves no purpose as configure
will fail without OpenGL and we will get no video without it)

- add a drm test. This is more extensive than FFmpeg's as we have
patched FFmpeg to use a more recent DRM define and need DRM support for
DRM PRIME with V4L2.
- V4L2 Prime support now depends on v4l2 and libdrm
- remove previous hackish attempt to fix FFmpeg build

- MythDRMPRIMEInterop is now built by default as it has no dependencies
on drm or egl.

- NOTE there are a host of conditionals in libmythtv.pro for hardware
acceleration support (e.g. vdpau, vaapi, nvdec etc) that should in
theory be split between requiring OpenGL and the decode only code that
does not. In practice, OpenGL will always be available.
  • Loading branch information
mark-kendall committed Nov 12, 2019
1 parent 2af9cdc commit 78dff97
Show file tree
Hide file tree
Showing 15 changed files with 111 additions and 206 deletions.
23 changes: 9 additions & 14 deletions mythtv/configure
Expand Up @@ -1970,8 +1970,6 @@ MYTHTV_CONFIG_LIST='
mheg
mmal
opengl
opengl_video
opengl_themepainter
egl
qtwebkit
qtscript
Expand All @@ -1990,6 +1988,7 @@ MYTHTV_CONFIG_LIST='
debugtype
systemd_notify
systemd_journal
drm
'

MYTHTV_HAVE_LIST='
Expand Down Expand Up @@ -2036,6 +2035,7 @@ USING_LIST='
opengl
opengles
egl
drm
vaapi
nvdec
vdpau
Expand Down Expand Up @@ -2602,10 +2602,8 @@ mythtranscode_deps="backend frontend"
opengl_deps_any="agl_h GL_gl_h EGL_egl_h GLES2_gl2_h darwin windows x11"
opengles_deps="GLES2_gl2_h"
egl_deps="EGL_egl_h"
opengl_video_deps="opengl"
opengl_themepainter_deps="opengl"
v4l2_deps="linux_videodev2_h"
v4l2prime_deps="v4l2"
v4l2prime_deps="v4l2 drm"
v4l1_deps="backend v4l2 linux_videodev_h"
xrandr_deps="x11"
asi_deps="backend"
Expand Down Expand Up @@ -2765,8 +2763,6 @@ enable mythtranscode
enable opengl
enable opengles
enable egl
enable opengl_video
enable opengl_themepainter
enable symbol_visibility
enable v4l1
enable v4l2
Expand Down Expand Up @@ -4893,6 +4889,7 @@ case $target_os in
enable libudev
enable libuuid
enable pic
enable drm
if [ x`uname -m` = x"armv7l" ]; then
disable vaapi
fi
Expand Down Expand Up @@ -6003,6 +6000,9 @@ enabled egl && { check_lib EGL EGL/egl.h eglGetProcAddress "-lEGL" ||
}
}

enabled drm && use_pkg_config libdrm libdrm xf86drm.h drmGetVersion || disable drm
enabled drm && check_cpp_condition drm_fourcc.h 'defined(DRM_FORMAT_MOD_LINEAR)' || disable drm

if enabled libmpeg2external; then
check_lib libmpeg2external mpeg2dec/mpeg2.h mpeg2_init -lmpeg2 || disable libmpeg2external
if disabled libmpeg2external; then
Expand Down Expand Up @@ -7186,7 +7186,7 @@ if enabled mmal; then
ffopts="$ffopts --enable-mmal"
fi

if enabled v4l2; then
if enabled drm; then
ffopts="$ffopts --enable-libdrm"
fi

Expand Down Expand Up @@ -7225,10 +7225,6 @@ if ! grep "^CONFIG_NVDEC=yes$" external/FFmpeg/ffbuild/config.mak ; then
disable nvdec
fi

# If ffmpeg disabled libdrm then disable v4l2prime
if ! grep "^CONFIG_LIBDRM=yes$" external/FFmpeg/ffbuild/config.mak ; then
disable v4l2prime
fi
if test "$quiet" != "yes"; then

echo
Expand Down Expand Up @@ -7403,13 +7399,12 @@ if enabled x11 ; then
echo "VAAPI support ${vaapi-no}"
echo "NVDEC support ${nvdec-no}"
fi
echo "DRM support ${drm-no}"
echo "Video4Linux codecs ${v4l2-no} (DRM ${v4l2prime-no})"
echo "MMAL decoder support ${mmal-no}"
echo "OpenGL support ${opengl-no}"
echo "OpenGL ES 2.0 ${opengles-no}"
echo "EGL support ${egl-no}"
echo "OpenGL video ${opengl_video-no}"
echo "OpenGL ThemePainter ${opengl_themepainter-no}"
if test x"$target_os" = x"mingw32" ; then
echo "Windows (Direct3D) yes"
echo "DXVA2 support ${dxva2-no}"
Expand Down
4 changes: 0 additions & 4 deletions mythtv/external/FFmpeg/libavcodec/v4l2_buffers.c
Expand Up @@ -301,10 +301,6 @@ static void v4l2_free_buffer(void *opaque, uint8_t *data)
}
}

#ifndef DRM_FORMAT_MOD_LINEAR
#define DRM_FORMAT_MOD_LINEAR fourcc_mod_code(NONE, 0)
#endif

static int v4l2_buffer_export_drm(V4L2Buffer* avbuf)
{
struct v4l2_exportbuffer expbuf;
Expand Down
63 changes: 29 additions & 34 deletions mythtv/libs/libmythtv/libmythtv.pro
Expand Up @@ -374,16 +374,6 @@ using_frontend {
SOURCES += decoders/privatedecoder.cpp
SOURCES += decoders/mythcodeccontext.cpp

using_mmal {
HEADERS += decoders/mythmmalcontext.h opengl/mythmmalinterop.h
SOURCES += decoders/mythmmalcontext.cpp opengl/mythmmalinterop.cpp
LIBS += -L/opt/vc/lib -lmmal -lvcsm
LIBS += -lEGL
DEFINES += USING_MMAL
# Raspbian
QMAKE_CXXFLAGS += -isystem /opt/vc/include
}

using_libass {
DEFINES += USING_LIBASS
LIBS += -lass
Expand Down Expand Up @@ -454,43 +444,55 @@ using_frontend {

using_x11:DEFINES += USING_X11

using_vdpau {
DEFINES += USING_VDPAU
HEADERS += opengl/mythvdpauinterop.h
HEADERS += decoders/mythvdpaucontext.h
HEADERS += decoders/mythvdpauhelper.h
SOURCES += opengl/mythvdpauinterop.cpp
SOURCES += decoders/mythvdpaucontext.cpp
SOURCES += decoders/mythvdpauhelper.cpp
LIBS += -lvdpau
}

using_opengl {
DEFINES += USING_OPENGL
using_opengles: DEFINES += USING_OPENGLES
}

using_opengl_video {
DEFINES += USING_OPENGL_VIDEO
HEADERS += opengl/mythopenglvideo.h
HEADERS += opengl/mythvideooutopengl.h
HEADERS += opengl/mythopenglvideoshaders.h
HEADERS += opengl/mythopenglinterop.h
HEADERS += opengl/mythvideotexture.h
HEADERS += opengl/mythegldefs.h
HEADERS += opengl/mythdrmprimeinterop.h
SOURCES += opengl/mythopenglvideo.cpp
SOURCES += opengl/mythvideooutopengl.cpp
SOURCES += opengl/mythopenglinterop.cpp
SOURCES += opengl/mythvideotexture.cpp
SOURCES += opengl/mythdrmprimeinterop.cpp
}

using_mmal {
HEADERS += decoders/mythmmalcontext.h opengl/mythmmalinterop.h
SOURCES += decoders/mythmmalcontext.cpp opengl/mythmmalinterop.cpp
LIBS += -L/opt/vc/lib -lmmal -lvcsm
LIBS += -lEGL
DEFINES += USING_MMAL
# Raspbian
QMAKE_CXXFLAGS += -isystem /opt/vc/include
}

using_v4l2prime {
DEFINES += USING_V4L2PRIME
}

using_vdpau {
DEFINES += USING_VDPAU
HEADERS += opengl/mythvdpauinterop.h
HEADERS += decoders/mythvdpaucontext.h
HEADERS += decoders/mythvdpauhelper.h
SOURCES += opengl/mythvdpauinterop.cpp
SOURCES += decoders/mythvdpaucontext.cpp
SOURCES += decoders/mythvdpauhelper.cpp
LIBS += -lvdpau
}

using_vaapi:using_opengl_video {
using_vaapi:using_opengl {
DEFINES += USING_VAAPI
HEADERS += decoders/mythvaapicontext.h opengl/mythvaapiinterop.h
SOURCES += decoders/mythvaapicontext.cpp opengl/mythvaapiinterop.cpp
HEADERS += opengl/mythvaapidrminterop.h opengl/mythvaapiglxinterop.h
SOURCES += opengl/mythvaapidrminterop.cpp opengl/mythvaapiglxinterop.cpp
LIBS += -lva -lva-x11 -lva-glx -lEGL
LIBS += -lva -lva-x11 -lva-glx -lva-drm
}

using_nvdec {
Expand Down Expand Up @@ -678,13 +680,6 @@ using_backend {
HEADERS += decoders/mythv4l2m2mcontext.h
SOURCES += decoders/mythv4l2m2mcontext.cpp
DEFINES += USING_V4L2

using_v4l2prime:using_opengl_video {
DEFINES += USING_V4L2PRIME
HEADERS += opengl/mythdrmprimeinterop.h
SOURCES += opengl/mythdrmprimeinterop.cpp
LIBS += -ldrm
}
}

# Support for cable boxes that provide Firewire out
Expand Down
14 changes: 7 additions & 7 deletions mythtv/libs/libmythtv/mythvideoout.cpp
Expand Up @@ -14,7 +14,7 @@
#ifdef _WIN32
#include "videoout_d3d.h"
#endif
#ifdef USING_OPENGL_VIDEO
#ifdef USING_OPENGL
#include "mythvideooutopengl.h"
#endif
#include "mythvideooutnull.h"
Expand All @@ -34,9 +34,9 @@ void MythVideoOutput::GetRenderOptions(RenderOptions &Options)
VideoOutputD3D::GetRenderOptions(Options);
#endif

#ifdef USING_OPENGL_VIDEO
#ifdef USING_OPENGL
MythVideoOutputOpenGL::GetRenderOptions(Options);
#endif // USING_OPENGL_VIDEO
#endif // USING_OPENGL
}

/**
Expand Down Expand Up @@ -65,9 +65,9 @@ MythVideoOutput *MythVideoOutput::Create(const QString &Decoder, MythCodecID
renderers += VideoOutputD3D::GetAllowedRenderers(CodecID, VideoDispDim);
#endif

#ifdef USING_OPENGL_VIDEO
#ifdef USING_OPENGL
renderers += MythVideoOutputOpenGL::GetAllowedRenderers(CodecID, VideoDispDim);
#endif // USING_OPENGL_VIDEO
#endif // USING_OPENGL
}

LOG(VB_PLAYBACK, LOG_INFO, LOC + QString("Allowed renderers: %1").arg(renderers.join(",")));
Expand Down Expand Up @@ -114,10 +114,10 @@ MythVideoOutput *MythVideoOutput::Create(const QString &Decoder, MythCodecID
vo = new VideoOutputD3D();
#endif // _WIN32

#ifdef USING_OPENGL_VIDEO
#ifdef USING_OPENGL
else if (renderer.contains("opengl"))
vo = new MythVideoOutputOpenGL(renderer);
#endif // USING_OPENGL_VIDEO
#endif // USING_OPENGL

if (vo)
vo->m_dbDisplayProfile = vprof;
Expand Down
68 changes: 4 additions & 64 deletions mythtv/libs/libmythtv/opengl/mythopenglinterop.cpp
Expand Up @@ -26,9 +26,7 @@
#ifdef USING_MMAL
#include "mythmmalinterop.h"
#endif
#ifdef USING_V4L2PRIME
#include "mythdrmprimeinterop.h"
#endif

#define LOC QString("OpenGLInterop: ")

Expand All @@ -53,34 +51,8 @@ QStringList MythOpenGLInterop::GetAllowedRenderers(MythCodecID CodecId)
QStringList result;
if (codec_sw_copy(CodecId))
return result;
#ifdef USING_VAAPI
else if (codec_is_vaapi(CodecId) && (GetInteropType(CodecId) != Unsupported))
result << "opengl-hw";
#endif
#ifdef USING_VTB
else if (codec_is_vtb(CodecId) && (GetInteropType(CodecId) != Unsupported))
result << "opengl-hw";
#endif
#ifdef USING_MEDIACODEC
else if (codec_is_mediacodec(CodecId) /*&& (GetInteropType(CodecId) != Unsupported)*/)
result << "opengl-hw";
#endif
#ifdef USING_VDPAU
else if (codec_is_vdpau_hw(CodecId) && (GetInteropType(CodecId) != Unsupported))
result << "opengl-hw";
#endif
#ifdef USING_NVDEC
else if (codec_is_nvdec(CodecId) && (GetInteropType(CodecId) != Unsupported))
result << "opengl-hw";
#endif
#ifdef USING_MMAL
else if (codec_is_mmal(CodecId) && (GetInteropType(CodecId) != Unsupported))
result << "opengl-hw";
#endif
#ifdef USING_V4L2PRIME
else if (codec_is_v4l2(CodecId) && (GetInteropType(CodecId) != Unsupported))
if (GetInteropType(CodecId) != Unsupported)
result << "opengl-hw";
#endif
return result;
}

Expand Down Expand Up @@ -131,10 +103,8 @@ MythOpenGLInterop::Type MythOpenGLInterop::GetInteropType(MythCodecID CodecId)
if (codec_is_mmal(CodecId))
supported = MythMMALInterop::GetInteropType(CodecId);
#endif
#ifdef USING_V4L2PRIME
if (codec_is_v4l2(CodecId))
supported = MythDRMPRIMEInterop::GetInteropType(CodecId);
#endif

if (Unsupported == supported)
LOG(VB_GENERAL, LOG_WARNING, LOC + QString("No render support for codec '%1'").arg(toString(CodecId)));
Expand All @@ -153,44 +123,14 @@ vector<MythVideoTexture*> MythOpenGLInterop::Retrieve(MythRenderOpenGL *Context,
if (!(Context && Frame))
return result;

MythOpenGLInterop* interop = nullptr;
bool validhwframe = Frame->priv[1];
bool validhwcodec = false;
#ifdef USING_VTB
if ((Frame->codec == FMT_VTB) && (Frame->pix_fmt == AV_PIX_FMT_VIDEOTOOLBOX))
validhwcodec = true;
#endif
#ifdef USING_VAAPI
if ((Frame->codec == FMT_VAAPI) && (Frame->pix_fmt == AV_PIX_FMT_VAAPI))
validhwcodec = true;
#endif
#ifdef USING_MEDIACODEC
if ((Frame->codec == FMT_MEDIACODEC) && (Frame->pix_fmt == AV_PIX_FMT_MEDIACODEC))
validhwcodec = true;
#endif
#ifdef USING_VDPAU
if ((Frame->codec == FMT_VDPAU) && (Frame->pix_fmt == AV_PIX_FMT_VDPAU))
validhwcodec = true;
#endif
#ifdef USING_NVDEC
if ((Frame->codec == FMT_NVDEC) && (Frame->pix_fmt == AV_PIX_FMT_CUDA))
validhwcodec = true;
#endif
#ifdef USING_MMAL
if ((Frame->codec == FMT_MMAL) && (Frame->pix_fmt == AV_PIX_FMT_MMAL))
validhwcodec = true;
#endif
#ifdef USING_V4L2PRIME
if ((Frame->codec == FMT_DRMPRIME) && (Frame->pix_fmt == AV_PIX_FMT_DRM_PRIME))
validhwcodec = true;
#endif

if (!(validhwframe && validhwcodec))
if (!(Frame->priv[1] && format_is_hw(Frame->codec) &&
(Frame->codec == PixelFormatToFrameType(static_cast<AVPixelFormat>(Frame->pix_fmt)))))
{
LOG(VB_GENERAL, LOG_WARNING, LOC + "Not a valid hardware frame");
return result;
}

MythOpenGLInterop* interop = nullptr;
if ((Frame->codec == FMT_VTB) || (Frame->codec == FMT_MEDIACODEC) ||
(Frame->codec == FMT_MMAL) || (Frame->codec == FMT_DRMPRIME))
{
Expand Down

0 comments on commit 78dff97

Please sign in to comment.