Skip to content

Commit

Permalink
fix no opengl build
Browse files Browse the repository at this point in the history
  • Loading branch information
wang-bin committed Aug 31, 2015
1 parent ed4fc0b commit 9fe6c04
Show file tree
Hide file tree
Showing 19 changed files with 98 additions and 47 deletions.
2 changes: 1 addition & 1 deletion QtAV.pro
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ OptionalDepends = \
avresample \
avdevice
# QtOpenGL module. In Qt5 we can disable it and still have opengl support
!no-gl:!no-widgets {
contains(QT_CONFIG, opengl):!no-gl:!no-widgets {
greaterThan(QT_MAJOR_VERSION, 4):qtHaveModule(opengl):!config_gl {
GL=config_gl done_config_gl
cache(CONFIG, add, GL)
Expand Down
7 changes: 6 additions & 1 deletion examples/player/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -126,12 +126,17 @@ int main(int argc, char *argv[])
}
qDebug("vo: %s", vo.toUtf8().constData());
vo = vo.toLower();
if (vo != QLatin1String("opengl") && vo != QLatin1String("gl") && vo != QLatin1String("d2d") && vo != QLatin1String("gdi") && vo != QLatin1String("xv") && vo != QLatin1String("qt"))
if (vo != QLatin1String("opengl") && vo != QLatin1String("gl") && vo != QLatin1String("d2d") && vo != QLatin1String("gdi") && vo != QLatin1String("xv") && vo != QLatin1String("qt")) {
#ifndef QT_NO_OPENGL
#ifdef Q_OS_ANDROID
vo = "opengl"; // qglwidget is not suitable for android
#else
vo = QString::fromLatin1("gl");
#endif
#else
vo = QString::fromLatin1("qt");
#endif //QT_NO_OPENGL
}
QString title = QString::fromLatin1("QtAV %1 [email protected]").arg(QtAV_Version_String_Long());
#ifndef QT_NO_OPENGL
VideoRendererId vid = VideoRendererId_GLWidget2;
Expand Down
6 changes: 2 additions & 4 deletions src/QtAV/OpenGLVideo.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

#ifndef QTAV_OPENGLVIDEO_H
#define QTAV_OPENGLVIDEO_H

#ifndef QT_NO_OPENGL
#include <QtAV/QtAV_Global.h>
#include <QtAV/VideoFormat.h>
#include <QtCore/QHash>
Expand All @@ -30,10 +30,8 @@
#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
#include <QtGui/QOpenGLContext>
#else
#if !defined(QT_NO_OPENGL)
#include <QtOpenGL/QGLContext>
#define QOpenGLContext QGLContext
#endif //!defined(QT_NO_OPENGL)
#endif
class QColor;

Expand Down Expand Up @@ -94,5 +92,5 @@ private slots:


} //namespace QtAV

#endif //QT_NO_OPENGL
#endif // QTAV_OPENGLVIDEO_H
4 changes: 2 additions & 2 deletions src/QtAV/OpenGLWindowRenderer.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

#ifndef QTAV_OPENGLWINDOWRENDERER_H
#define QTAV_OPENGLWINDOWRENDERER_H

#ifndef QT_NO_OPENGL
#include <QtGui/QOpenGLWindow>
#include <QtAV/OpenGLRendererBase.h>

Expand Down Expand Up @@ -51,5 +51,5 @@ class Q_AV_EXPORT OpenGLWindowRenderer : public QOpenGLWindow, public OpenGLRend
typedef OpenGLWindowRenderer VideoRendererOpenGLWindow;

} //namespace QtAV

#endif //QT_NO_OPENGL
#endif // QTAV_OPENGLWINDOWRENDERER_H
4 changes: 1 addition & 3 deletions src/ShaderManager.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/******************************************************************************
QtAV: Media play library based on Qt and FFmpeg
Copyright (C) 2014 Wang Bin <[email protected]>
Copyright (C) 2014-2015 Wang Bin <[email protected]>
* This file is part of QtAV
Expand All @@ -27,10 +27,8 @@
#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
#include <QtGui/QOpenGLContext>
#else
#if !defined(QT_NO_OPENGL)
#include <QtOpenGL/QGLContext>
#define QOpenGLContext QGLContext
#endif //!defined(QT_NO_OPENGL)
#endif

namespace QtAV {
Expand Down
4 changes: 4 additions & 0 deletions src/codec/video/SurfaceInteropCUDA.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -113,9 +113,11 @@ void* SurfaceInteropCUDA::map(SurfaceType type, const VideoFormat &fmt, void *ha
if (m_index < 0)
return 0;
if (type == GLTextureSurface) {
#ifndef QT_NO_OPENGL
// FIXME: to strong ref may delay the delete and cuda resource maybe already destoryed after strong ref is finished
if (m_resource.toStrongRef()->map(m_index, m_param, *((GLuint*)handle), w, h, H, plane))
return handle;
#endif //QT_NO_OPENGL
} else if (type == HostMemorySurface) {
return m_resource.toStrongRef()->mapToHost(fmt, handle, m_index, m_param, w, h, H);
}
Expand All @@ -126,8 +128,10 @@ void SurfaceInteropCUDA::unmap(void *handle)
{
if (m_resource.isNull())
return;
#ifndef QT_NO_OPENGL
// FIXME: to strong ref may delay the delete and cuda resource maybe already destoryed after strong ref is finished
m_resource.toStrongRef()->unmap(*((GLuint*)handle));
#endif
}
} //namespace cuda
} //namespace QtAV
Expand Down
3 changes: 2 additions & 1 deletion src/codec/video/SurfaceInteropCUDA.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
#include <QtCore/QWeakPointer>
#include "QtAV/SurfaceInterop.h"
#include "utils/OpenGLHelper.h"
#ifndef QT_NO_OPENGL
#ifdef Q_OS_WIN
// no need to check qt4 because no ANGLE there
#if QTAV_HAVE(EGL_CAPI) // always use dynamic load
Expand All @@ -38,7 +39,7 @@
#if defined(QT_OPENGL_DYNAMIC) || !defined(QT_OPENGL_ES_2)
#define QTAV_HAVE_CUDA_GL 1
#endif

#endif //QT_NO_OPENGL
namespace QtAV {
namespace cuda {

Expand Down
1 change: 0 additions & 1 deletion src/codec/video/VideoDecoderCUDA.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@
#include "cuda/cuda_api.h"
#include "utils/Logger.h"
#include "SurfaceInteropCUDA.h"
#include "utils/OpenGLHelper.h"

//decode error if not floating context

Expand Down
28 changes: 19 additions & 9 deletions src/codec/video/VideoDecoderVAAPI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,10 @@ const codec_profile_t* findProfileEntry(AVCodecID codec, int profile)
return 0;
}

class VideoDecoderVAAPIPrivate Q_DECL_FINAL: public VideoDecoderFFmpegHWPrivate, protected VAAPI_DRM, protected VAAPI_X11, protected VAAPI_GLX
class VideoDecoderVAAPIPrivate Q_DECL_FINAL: public VideoDecoderFFmpegHWPrivate, protected VAAPI_DRM, protected VAAPI_X11
#ifndef QT_NO_OPENGL
, protected VAAPI_GLX
#endif //QT_NO_OPENGL
, protected X11_API
{
DPTR_DECLARE_PUBLIC(VideoDecoderVAAPI)
Expand All @@ -155,18 +158,19 @@ class VideoDecoderVAAPIPrivate Q_DECL_FINAL: public VideoDecoderFFmpegHWPrivate,
{
if (VAAPI_DRM::isLoaded())
display_type = VideoDecoderVAAPI::DRM;
if (VAAPI_GLX::isLoaded())
#ifndef QT_NO_OPENGL
if (VAAPI_GLX::isLoaded()) {
display_type = VideoDecoderVAAPI::GLX;
if (VAAPI_X11::isLoaded())
copy_mode = VideoDecoderFFmpegHW::ZeroCopy;
}
#endif //QT_NO_OPENGL
if (VAAPI_X11::isLoaded()) {
display_type = VideoDecoderVAAPI::X11;
if (display_type == VideoDecoderVAAPI::DRM) {
copy_mode = VideoDecoderFFmpegHW::OptimizedCopy;
} else {
#ifndef QT_NO_OPENGL
#if VA_X11_INTEROP
copy_mode = VideoDecoderFFmpegHW::ZeroCopy;
#else
copy_mode = VideoDecoderFFmpegHW::OptimizedCopy;
#endif //VA_X11_INTEROP
#endif //QT_NO_OPENGL
}
drm_fd = -1;
display_x11 = 0;
Expand Down Expand Up @@ -471,6 +475,7 @@ bool VideoDecoderVAAPIPrivate::open()
display_type = VideoDecoderVAAPI::X11;
} else if (dt == VideoDecoderVAAPI::GLX) {
qDebug("vaGetDisplay GLX...............");
#ifndef QT_NO_OPENGL
if (!VAAPI_GLX::isLoaded())
continue;
// TODO: lock
Expand All @@ -485,6 +490,9 @@ bool VideoDecoderVAAPIPrivate::open()
}
disp = vaGetDisplayGLX(display_x11);
display_type = VideoDecoderVAAPI::GLX;
#else
qWarning("No OpenGL support in Qt");
#endif //QT_NO_OPENGL
}
if (disp)
break;
Expand Down Expand Up @@ -549,10 +557,12 @@ bool VideoDecoderVAAPIPrivate::open()
//vaCreateConfig(display, pe->va_profile, VAEntrypointVLD, NULL, 0, &config_id)
VA_ENSURE_TRUE(vaCreateConfig(disp, pe->va_profile, VAEntrypointVLD, &attrib, 1, &config_id), false);
supports_derive = false;
#ifndef QT_NO_OPENGL
if (display_type == VideoDecoderVAAPI::GLX)
interop_res = InteropResourcePtr(new GLXInteropResource());
#endif //QT_NO_OPENGL
#if VA_X11_INTEROP
else if (display_type == VideoDecoderVAAPI::X11)
if (display_type == VideoDecoderVAAPI::X11)
interop_res = InteropResourcePtr(new X11InteropResource());
#endif //VA_X11_INTEROP
return true;
Expand Down
32 changes: 21 additions & 11 deletions src/libQtAV.pro
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,11 @@ greaterThan(QT_MAJOR_VERSION, 4) {
QT *= gui-private #dxva+egl
DEFINES *= QTAV_HAVE_GUI_PRIVATE=1
}
CONFIG *= config_opengl
greaterThan(QT_MINOR_VERSION, 3) {
CONFIG *= config_openglwindow
contains(QT_CONFIG, opengl) {
CONFIG *= config_opengl
greaterThan(QT_MINOR_VERSION, 3) {
CONFIG *= config_openglwindow
}
}
} else {
config_gl: QT += opengl
Expand Down Expand Up @@ -192,10 +194,12 @@ CONFIG += config_cuda #config_dllapi config_dllapi_cuda
#CONFIG += config_cuda_link
config_cuda {
DEFINES += QTAV_HAVE_CUDA=1
HEADERS += cuda/dllapi/nv_inc.h cuda/helper_cuda.h \
codec/video/SurfaceInteropCUDA.h
SOURCES += codec/video/VideoDecoderCUDA.cpp \
codec/video/SurfaceInteropCUDA.cpp
HEADERS += cuda/dllapi/nv_inc.h cuda/helper_cuda.h
SOURCES += codec/video/VideoDecoderCUDA.cpp
#contains(QT_CONFIG, opengl) {
HEADERS += codec/video/SurfaceInteropCUDA.h
SOURCES += codec/video/SurfaceInteropCUDA.cpp
#}
INCLUDEPATH += $$PWD/cuda cuda/dllapi
config_dllapi:config_dllapi_cuda {
DEFINES += QTAV_HAVE_DLLAPI_CUDA=1
Expand All @@ -215,15 +219,21 @@ include(../depends/dllapi/src/libdllapi.pri)
}
config_dxva {
DEFINES *= QTAV_HAVE_DXVA=1
SOURCES += codec/video/VideoDecoderDXVA.cpp
contains(QT_CONFIG, opengl) {
HEADERS += codec/video/SurfaceInteropDXVA.h
SOURCES += codec/video/VideoDecoderDXVA.cpp \
codec/video/SurfaceInteropDXVA.cpp
SOURCES += codec/video/SurfaceInteropDXVA.cpp
}
LIBS += -lole32
}
config_vaapi* {
DEFINES *= QTAV_HAVE_VAAPI=1
SOURCES += codec/video/VideoDecoderVAAPI.cpp vaapi/vaapi_helper.cpp vaapi/SurfaceInteropVAAPI.cpp
HEADERS += vaapi/vaapi_helper.h vaapi/SurfaceInteropVAAPI.h
SOURCES += codec/video/VideoDecoderVAAPI.cpp vaapi/vaapi_helper.cpp
HEADERS += vaapi/vaapi_helper.h
#contains(QT_CONFIG, opengl) {
HEADERS += vaapi/SurfaceInteropVAAPI.h
SOURCES += vaapi/SurfaceInteropVAAPI.cpp
#}
LIBS += -lva #dynamic load va-glx va-x11 using dllapi
}
config_libcedarv {
Expand Down
8 changes: 6 additions & 2 deletions src/output/video/GraphicsItemRenderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
#include "QtAVWidgets/GraphicsItemRenderer.h"
#include "QtAV/private/QPainterRenderer_p.h"
#include "QtAV/FilterContext.h"
#define QTAV_HAVE_OPENGL (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0) || defined(QT_OPENGL_LIB))
#define QTAV_HAVE_OPENGL (!defined QT_NO_OPENGL && (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0) || defined(QT_OPENGL_LIB)))
#if QTAV_HAVE(OPENGL)
#include "QtAV/OpenGLVideo.h"
#else
Expand Down Expand Up @@ -114,8 +114,8 @@ bool GraphicsItemRenderer::isSupported(VideoFormat::PixelFormat pixfmt) const

bool GraphicsItemRenderer::receiveFrame(const VideoFrame& frame)
{
DPTR_D(GraphicsItemRenderer);
#if QTAV_HAVE(OPENGL)
DPTR_D(GraphicsItemRenderer);
if (isOpenGL()) {
d.video_frame = frame;
if (d.checkGL())
Expand Down Expand Up @@ -225,6 +225,7 @@ bool GraphicsItemRenderer::onSetBrightness(qreal b)
{
if (!isOpenGL())
return false;
Q_UNUSED(b);
#if QTAV_HAVE(OPENGL)
d_func().glv.setBrightness(b);
update();
Expand All @@ -237,6 +238,7 @@ bool GraphicsItemRenderer::onSetContrast(qreal c)
{
if (!isOpenGL())
return false;
Q_UNUSED(c);
#if QTAV_HAVE(OPENGL)
d_func().glv.setContrast(c);
update();
Expand All @@ -249,6 +251,7 @@ bool GraphicsItemRenderer::onSetHue(qreal h)
{
if (!isOpenGL())
return false;
Q_UNUSED(h);
#if QTAV_HAVE(OPENGL)
d_func().glv.setHue(h);
update();
Expand All @@ -261,6 +264,7 @@ bool GraphicsItemRenderer::onSetSaturation(qreal s)
{
if (!isOpenGL())
return false;
Q_UNUSED(s);
#if QTAV_HAVE(OPENGL)
d_func().glv.setSaturation(s);
update();
Expand Down
8 changes: 7 additions & 1 deletion src/output/video/VideoRendererTypes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@
#include <cstdlib>
#include "QtAV/private/prepost.h"
#if QT_VERSION >= QT_VERSION_CHECK(5, 4, 0)
#ifndef QT_NO_OPENGL
#include "QtAV/OpenGLWindowRenderer.h"
#endif //QT_NO_OPENGL
#endif
#include "QtAV/private/factory.h"
#include "QtAV/private/mkid.h"
Expand All @@ -36,6 +38,7 @@ FACTORY_DEFINE(VideoRenderer)
VideoRendererId VideoRendererId_OpenGLWindow = mkid::id32base36_6<'Q', 'O', 'G', 'L', 'W', 'w'>::value;

#if QT_VERSION >= QT_VERSION_CHECK(5, 4, 0)
#ifndef QT_NO_OPENGL
FACTORY_REGISTER_ID_AUTO(VideoRenderer, OpenGLWindow, "OpenGLWindow")

void RegisterVideoRendererOpenGLWindow_Man()
Expand All @@ -47,12 +50,15 @@ VideoRendererId OpenGLWindowRenderer::id() const
{
return VideoRendererId_OpenGLWindow;
}
#endif
#endif //QT_NO_OPENGL
#endif //qt5.4.0

void VideoRenderer_RegisterAll()
{
#if QT_VERSION >= QT_VERSION_CHECK(5, 4, 0)
#ifndef QT_NO_OPENGL
RegisterVideoRendererOpenGLWindow_Man();
#endif //QT_NO_OPENGL
#endif
}
}//namespace QtAV
10 changes: 9 additions & 1 deletion src/utils/OpenGLHelper.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@

#include "QtAV/VideoFormat.h"
#include <qglobal.h>
#ifndef QT_NO_OPENGL
#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
#include <QtGui/QOpenGLBuffer>
#include <QtGui/QOpenGLContext>
Expand Down Expand Up @@ -130,5 +131,12 @@ GLint GetGLInternalFormat(GLint data_format, int bpp);

} //namespace OpenGLHelper
} //namespace QtAV

#else
namespace QtAV {
namespace OpenGLHelper {
#define DYGL(f) f
inline bool isOpenGLES() {return false;}
} //namespace OpenGLHelper
} //namespace QtAV
#endif //QT_NO_OPENGL
#endif // QTAV_OPENGLHELPER_H
4 changes: 2 additions & 2 deletions src/vaapi/SurfaceInteropVAAPI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ void* SurfaceInteropVAAPI::mapToHost(const VideoFormat &format, void *handle, in
*f = frame;
return f;
}

#ifndef QT_NO_OPENGL
surface_glx_ptr GLXInteropResource::surfaceGLX(const display_ptr &dpy, GLuint tex)
{
surface_glx_ptr glx = glx_surfaces[tex];
Expand All @@ -163,7 +163,7 @@ bool GLXInteropResource::map(const surface_ptr& surface, GLuint tex, int w, int
VAWARN(vaSyncSurface(surface->vadisplay(), surface->get()));
return true;
}

#endif //QT_NO_OPENGL
#if VA_X11_INTEROP
X11InteropResource::glXReleaseTexImage_t X11InteropResource::glXReleaseTexImage = 0;
X11InteropResource::glXBindTexImage_t X11InteropResource::glXBindTexImage = 0;
Expand Down
Loading

0 comments on commit 9fe6c04

Please sign in to comment.