mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-06-07 16:08:51 +00:00
qmlgl: Can't use frame info if we don't have a frame
Fixes segfault accessing vinfo in: GST_VIDEO_FRAME_N_PLANES (&this->v_frame) Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/5148>
This commit is contained in:
parent
223a0e3b27
commit
14503a7d08
2 changed files with 6 additions and 5 deletions
|
@ -82,7 +82,7 @@ public:
|
||||||
program()->setUniformValue(m_id_opacity, state.opacity());
|
program()->setUniformValue(m_id_opacity, state.opacity());
|
||||||
|
|
||||||
GstQSGMaterial *mat = static_cast<GstQSGMaterial *>(newMaterial);
|
GstQSGMaterial *mat = static_cast<GstQSGMaterial *>(newMaterial);
|
||||||
mat->bind(this);
|
mat->bind(this, this->v_format);
|
||||||
}
|
}
|
||||||
|
|
||||||
char const *const *attributeNames() const override
|
char const *const *attributeNames() const override
|
||||||
|
@ -378,7 +378,7 @@ GstQSGMaterial::getBuffer (gboolean * was_bound)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
GstQSGMaterial::bind(GstQSGMaterialShader *shader)
|
GstQSGMaterial::bind(GstQSGMaterialShader *shader, GstVideoFormat v_format)
|
||||||
{
|
{
|
||||||
const GstGLFuncs *gl;
|
const GstGLFuncs *gl;
|
||||||
GstGLContext *context, *qt_context;
|
GstGLContext *context, *qt_context;
|
||||||
|
@ -473,12 +473,13 @@ out:
|
||||||
if (G_UNLIKELY (use_dummy_tex)) {
|
if (G_UNLIKELY (use_dummy_tex)) {
|
||||||
QOpenGLContext *qglcontext = QOpenGLContext::currentContext ();
|
QOpenGLContext *qglcontext = QOpenGLContext::currentContext ();
|
||||||
QOpenGLFunctions *funcs = qglcontext->functions ();
|
QOpenGLFunctions *funcs = qglcontext->functions ();
|
||||||
|
const GstVideoFormatInfo *finfo = gst_video_format_get_info (v_format);
|
||||||
|
|
||||||
/* Create dummy texture if not already present.
|
/* Create dummy texture if not already present.
|
||||||
* Use the Qt OpenGL functions instead of the GstGL ones,
|
* Use the Qt OpenGL functions instead of the GstGL ones,
|
||||||
* since we are using the Qt OpenGL context here, and we must
|
* since we are using the Qt OpenGL context here, and we must
|
||||||
* be able to delete the texture in the destructor. */
|
* be able to delete the texture in the destructor. */
|
||||||
for (int i = GST_VIDEO_FRAME_N_PLANES (&this->v_frame) - 1; i >= 0; i--) {
|
for (int i = finfo->n_planes - 1; i >= 0; i--) {
|
||||||
shader->program()->setUniformValue(shader->tex_uniforms[i], i);
|
shader->program()->setUniformValue(shader->tex_uniforms[i], i);
|
||||||
funcs->glActiveTexture(GL_TEXTURE0 + i);
|
funcs->glActiveTexture(GL_TEXTURE0 + i);
|
||||||
|
|
||||||
|
@ -491,7 +492,7 @@ out:
|
||||||
const int tex_sidelength = 64;
|
const int tex_sidelength = 64;
|
||||||
|
|
||||||
std::vector < guint8 > dummy_data (tex_sidelength * tex_sidelength * 4, 0);
|
std::vector < guint8 > dummy_data (tex_sidelength * tex_sidelength * 4, 0);
|
||||||
switch (GST_VIDEO_FRAME_FORMAT (&this->v_frame)) {
|
switch (v_format) {
|
||||||
case GST_VIDEO_FORMAT_RGBA:
|
case GST_VIDEO_FORMAT_RGBA:
|
||||||
case GST_VIDEO_FORMAT_BGRA:
|
case GST_VIDEO_FORMAT_BGRA:
|
||||||
case GST_VIDEO_FORMAT_RGB:
|
case GST_VIDEO_FORMAT_RGB:
|
||||||
|
|
|
@ -46,7 +46,7 @@ public:
|
||||||
GstBuffer * getBuffer (gboolean * was_bound);
|
GstBuffer * getBuffer (gboolean * was_bound);
|
||||||
bool compatibleWith(GstVideoInfo *v_info);
|
bool compatibleWith(GstVideoInfo *v_info);
|
||||||
|
|
||||||
void bind(GstQSGMaterialShader *);
|
void bind(GstQSGMaterialShader *, GstVideoFormat);
|
||||||
|
|
||||||
/* QSGMaterial */
|
/* QSGMaterial */
|
||||||
QSGMaterialShader *createShader() const override;
|
QSGMaterialShader *createShader() const override;
|
||||||
|
|
Loading…
Reference in a new issue