]> code.ossystems Code Review - meta-freescale.git/blob
2dc3b12dc539fb69f34bc9e4db6c7c07bed13813
[meta-freescale.git] /
1 From 8272d5c9e32d2ae26ce28dcbf9a7962bc18f2338 Mon Sep 17 00:00:00 2001
2 From: Carlos Rafael Giani <dv@pseudoterminal.org>
3 Date: Thu, 10 Aug 2017 11:29:41 +0200
4 Subject: [PATCH] qmlglsink: Retain the previous frame to avoid flickering
5  artifacts
6
7 With some GstGL uploaders - especially the ones based on DMABUF - it is
8 possible that flickering artifacts can occur with qmlglsink. This happens
9 because upstream writes into the dmabuf at the same time when the frame
10 in that dmabuf is being painted on screen. By retaining the gstbuffer for
11 one more frame, this is avoided, since the gstbuffer is not released back
12 into the upstream dmabuf buffer pool until the frame is drawn.
13
14 https://bugzilla.gnome.org/show_bug.cgi?id=786133
15 ---
16  ext/qt/gstqsgtexture.cc | 7 +++++++
17  ext/qt/gstqsgtexture.h  | 1 +
18  2 files changed, 8 insertions(+)
19
20 diff --git a/ext/qt/gstqsgtexture.cc b/ext/qt/gstqsgtexture.cc
21 index 7391806..46d73bb 100644
22 --- a/ext/qt/gstqsgtexture.cc
23 +++ b/ext/qt/gstqsgtexture.cc
24 @@ -46,6 +46,7 @@ GstQSGTexture::GstQSGTexture ()
25  
26    gst_video_info_init (&this->v_info);
27    this->buffer_ = NULL;
28 +  this->previous_buffer_ = NULL;
29    this->qt_context_ = NULL;
30    this->sync_buffer_ = gst_buffer_new ();
31    this->dummy_tex_id_ = 0;
32 @@ -54,6 +55,7 @@ GstQSGTexture::GstQSGTexture ()
33  GstQSGTexture::~GstQSGTexture ()
34  {
35    gst_buffer_replace (&this->buffer_, NULL);
36 +  gst_buffer_replace (&this->previous_buffer_, NULL);
37    gst_buffer_replace (&this->sync_buffer_, NULL);
38    if (this->dummy_tex_id_ && QOpenGLContext::currentContext ()) {
39      QOpenGLContext::currentContext ()->functions ()->glDeleteTextures (1,
40 @@ -75,6 +77,11 @@ gboolean
41  GstQSGTexture::setBuffer (GstBuffer * buffer)
42  {
43    GST_LOG ("%p setBuffer %" GST_PTR_FORMAT, this, buffer);
44 +
45 +  /* Retain the current buffer for one frame to prevent
46 +   * releasing the buffer while it is being drawn */
47 +  gst_buffer_replace (&this->previous_buffer_, this->buffer_);
48 +
49    /* FIXME: update more state here */
50    if (!gst_buffer_replace (&this->buffer_, buffer))
51      return FALSE;
52 diff --git a/ext/qt/gstqsgtexture.h b/ext/qt/gstqsgtexture.h
53 index fdabe93..d2685f8 100644
54 --- a/ext/qt/gstqsgtexture.h
55 +++ b/ext/qt/gstqsgtexture.h
56 @@ -48,6 +48,7 @@ public:
57  
58  private:
59      GstBuffer * buffer_;
60 +    GstBuffer * previous_buffer_;
61      GstBuffer * sync_buffer_;
62      GstGLContext * qt_context_;
63      GstMemory * mem_;
64 -- 
65 2.7.4
66