PDA

View Full Version : segfault with adding a QAbstractVideoFilter qml/c++



PeterVE
6th October 2016, 20:12
I am developing on a desktop as a host and the target is an iMX6 board. The OS for both is Ubuntu. I have ported the qmlvideofx example provided by Qt as a base application. From here, I want to add a QAbstractVideoFilter so that I can access the frames in the QMediaPlayer. I have two kits with this project, the Desktop Qt GCC 64bit (host) and an apalis-imx6 (target).

.h


#ifndef VIDEOFILTERTOSATELLITE_H
#define VIDEOFILTERTOSATELLITE_H

#include <QObject>
#include <QAbstractVideoFilter>
#include <QVideoFilterRunnable>
#include <QDebug>
#include <QSize>

class VideoFilterToSatellite;

class VideoFilterToSatelliteRunnable : public QVideoFilterRunnable
{
public:
VideoFilterToSatelliteRunnable ( VideoFilterToSatellite* parent = 0 );
~VideoFilterToSatelliteRunnable ();

QVideoFrame run ( QVideoFrame *input,
const QVideoSurfaceFormat &surfaceFormat,
RunFlags flags ) Q_DECL_OVERRIDE;
private:
VideoFilterToSatellite* m_filterParent;
};

class VideoFilterToSatellite : public QAbstractVideoFilter
{
Q_OBJECT
public:
explicit VideoFilterToSatellite ( QAbstractVideoFilter *parent = 0 );
QVideoFilterRunnable* createFilterRunnable ();
};

#endif // VIDEOFILTERTOSATELLITE_H


.cpp


#include "VideoFilterToSatellite.h"

VideoFilterToSatellite::VideoFilterToSatellite ( QAbstractVideoFilter *parent )
: QAbstractVideoFilter ( parent ) {}

QVideoFilterRunnable* VideoFilterToSatellite::createFilterRunnable ()
{
return reinterpret_cast<QVideoFilterRunnable*>( new VideoFilterToSatelliteRunnable ( this ) );
}

VideoFilterToSatelliteRunnable::VideoFilterToSatel liteRunnable ( VideoFilterToSatellite* parent )
: m_filterParent ( parent ) {}

VideoFilterToSatelliteRunnable::~VideoFilterToSate lliteRunnable() {}

QVideoFrame VideoFilterToSatelliteRunnable::run ( QVideoFrame *input,
const QVideoSurfaceFormat &surfaceFormat,
RunFlags flags )
{
Q_UNUSED ( surfaceFormat );
Q_UNUSED ( flags );

if (!input->isValid())
return *input;

// future work

return *input;
}

.pro


TEMPLATE = app
TARGET = MCS_Host

QT += qml quick multimedia network
CONFIG += c++11
CONFIG += qml_debug

SOURCES += main.cpp \
filereader.cpp \
NetworkServer.cpp \
NetworkThread.cpp \
VideoFilterToSatellite.cpp

RESOURCES += qml.qrc

# Additional import path used to resolve QML modules in Qt Creator's code model
QML_IMPORT_PATH =

# Default rules for deployment.
qnx: target.path = /tmp/$${TARGET}/bin
else: unix:!android: target.path = /opt/$${TARGET}/bin
!isEmpty(target.path): INSTALLS += target

HEADERS += \
filereader.h \
NetworkServer.h \
NetworkThread.h \
trace.h \
VideoFilterToSatellite.h

main.cpp


... includes ...
#include "VideoFilterToSatellite.h"

int main(int argc, char *argv[])
{
qputenv ( "QT_IM_MODULE", QByteArray ( "qtvirtualkeyboard" ) );

qSetMessagePattern ( "\033[34m%{function}[%{line}]:\033[0m %{message}" );

QGuiApplication app ( argc, argv );
qmlRegisterType<VideoFilterToSatellite>("VideoFilter.ToSatellite", 1, 0, "VideoFilterToSatellite" );

QQuickView viewer;

viewer.setSource ( QUrl ( QLatin1String ( "qrc:/qml/qmlvideofx/Main.qml" ) ) );

viewer.show ();

// Delay invocation of init until the event loop has started, to work around
// a GL context issue on Harmattan: without this, we get the following error
// when the first ShaderEffectItem is created:
// "QGLShaderProgram::addShader: Program and shader are not associated with same context"
QMetaObject::invokeMethod ( rootObject, "init", Qt::QueuedConnection );

return app.exec();
}


If I run this code on the desktop, it all works. If I run it on the target, it immediately segfaults in dl-debug.c on line 46 dl_debug_initialize. If I take out the filter, everything works on both platforms. I am missing something and am unsure where to go from here. Thanks for any pointers.

anda_skoa
7th October 2016, 10:41
Have you tried without the unneccessary reinterpret_cast?

Also, since you are delaying some form of init for some reason, might it not also be better to delay the QML loading as well?
Maybe until after init has been done?

Not saying this could cause the difference between platforms, but it looks weird.

Cheers,
_

PeterVE
7th October 2016, 13:56
Thank you anda_skoa for your feedback. I put the cast in there because QtCreator was giving me a warning at one point. The init delay as well as 99% of this entire app is from "qmlvideofx" example from Qt/Examples. I removed both the cast and the delay and the issue persists. While I can't nail this down, I am thinking it has something to do with the compile/linker differences. I am examining the "Project" tab difference right now. I'm probably wrong, but it seems like the right direction.

anda_skoa
7th October 2016, 18:21
ABI differences would also be my guess, e.g. different compiler or different flags that change binary layout, etc.

Cheers,
_