Return-Path: Received: by yocto-www.yoctoproject.org (Postfix, from userid 118) id 8508EE00BAA; Wed, 20 Jan 2016 05:30:50 -0800 (PST) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on yocto-www.yoctoproject.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,HTML_MESSAGE, SPF_HELO_PASS autolearn=ham version=3.3.1 X-Spam-HAM-Report: * -0.0 SPF_HELO_PASS SPF: HELO matches SPF record * -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% * [score: 0.0000] * 0.0 HTML_MESSAGE BODY: HTML included in message Received: from ptmx.org (ptmx.org [178.63.28.110]) by yocto-www.yoctoproject.org (Postfix) with ESMTP id C3E7CE00B9C for ; Wed, 20 Jan 2016 05:30:44 -0800 (PST) Received: from [10.1.14.248] (vpn.streamunlimited.com [91.114.0.140]) by ptmx.org (Postfix) with ESMTPSA id 0FC0D25472; Wed, 20 Jan 2016 14:30:41 +0100 (CET) To: Yuqing Zhu , "meta-freescale@yoctoproject.org" References: <1453109642-25548-1-git-send-email-b54851@freescale.com> <1453109642-25548-2-git-send-email-b54851@freescale.com> <569CF388.1020603@pseudoterminal.org> From: Carlos Rafael Giani Message-ID: <569F8BFE.6020908@pseudoterminal.org> Date: Wed, 20 Jan 2016 14:30:38 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.2.0 MIME-Version: 1.0 In-Reply-To: Subject: Re: [meta-fsl-arm][PATCH 1/3] gstreamer1.0-plugins-base: Make memory copy when video buffer's memory is read only X-BeenThere: meta-freescale@yoctoproject.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: Usage and development list for the meta-fsl-* layers List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 20 Jan 2016 13:30:50 -0000 Content-Type: multipart/alternative; boundary="------------020607050600010303060408" --------------020607050600010303060408 Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit I suppose this is caused by the elements in gst1.0-fsl-plugins creating buffers with read-only GstMemory blocks, right? Any reason why they are read only? I know these correspond to VPU framebuffers, but I do not see a reason why you want to prevent read-write access. With read write access, it is theoretically possible that some element like textoverlay writes into it. Without this access (and with your patch), it would then copy the entire buffer instead, which is not faster. So, what other reasons are there? On 01/20/2016 06:26 AM, Yuqing Zhu wrote: > Hi Carlos, > > Here is the bugzilla entry: https://bugzilla.gnome.org/show_bug.cgi?id=747495 > This bug is hardware specific, so we flag this patch as i.MX specific. > > > > B.R. > Yuqing Zhu > > -----Original Message----- > From: meta-freescale-bounces@yoctoproject.org [mailto:meta-freescale-bounces@yoctoproject.org] On Behalf Of Carlos Rafael Giani > Sent: Monday, January 18, 2016 10:16 PM > To: meta-freescale@yoctoproject.org > Subject: Re: [meta-freescale] [meta-fsl-arm][PATCH 1/3] gstreamer1.0-plugins-base: Make memory copy when video buffer's memory is read only > > Why is this flagged as i.MX specific? Nothing in this patch refers to i.MX details such as IPU, VPU etc. > > Also, the patch commit message needs a reference to a GStreamer bugzilla entry. > > On 01/18/2016 10:34 AM, Yuqing Zhu wrote: >> Since gst_buffer_make_writable just lookup the refcount to determine >> if a buffer is writable, and it will use _gst_buffer_copy() which >> don't perform a deep memory copy even if the flag of a memory is set >> to GST_MEMORY_FLAG_READONLY. So, we detect the memory flag and use >> gst_buffer_copy_region with GST_BUFFER_COPY_DEEP parameter to perform >> deep memory copy. if the allocator of a memory don't support mem_copy >> interface, the it will return NULL, if this case, we can use >> gst_buffer_make_writable() to get a shared memory buffer or the >> orignal buffer if the buffer's refcount is 1. >> >> Signed-off-by: Yuqing Zhu >> --- >> ...rlay-make-memory-copy-when-video-buffer-s.patch | 80 ++++++++++++++++++++++ >> .../gstreamer/gstreamer1.0-plugins-base_%.bbappend | 7 +- >> 2 files changed, 85 insertions(+), 2 deletions(-) >> create mode 100755 >> recipes-multimedia/gstreamer/gstreamer1.0-plugins-base/0001-basetextov >> erlay-make-memory-copy-when-video-buffer-s.patch >> >> diff --git >> a/recipes-multimedia/gstreamer/gstreamer1.0-plugins-base/0001-basetext >> overlay-make-memory-copy-when-video-buffer-s.patch >> b/recipes-multimedia/gstreamer/gstreamer1.0-plugins-base/0001-basetext >> overlay-make-memory-copy-when-video-buffer-s.patch >> new file mode 100755 >> index 0000000..eaff00f >> --- /dev/null >> +++ b/recipes-multimedia/gstreamer/gstreamer1.0-plugins-base/0001-base >> +++ textoverlay-make-memory-copy-when-video-buffer-s.patch >> @@ -0,0 +1,80 @@ >> +From 0092d07195aa5d950bc10dfb05bd9547f67028a3 Mon Sep 17 00:00:00 >> +2001 >> +From: Mingke Wang >> +Date: Fri, 16 Oct 2015 19:31:32 +0800 >> +Subject: [PATCH 1/9] basetextoverlay: make memory copy when video >> +buffer's memory is ready only >> + >> +1. since gst_buffer_make_writable just lookup the refcount to determine if >> + a buffer is writable, and it will use _gst_buffer_copy() which don't >> + perform a deep memory copy even if the flag of a memory is set to >> + GST_MEMORY_FLAG_READONLY. So, we detect the memory flag and use >> + gst_buffer_copy_region with GST_BUFFER_COPY_DEEP parameter to perform >> + deep memory copy. if the allocator of a memory don't support mem_copy >> + interface, the it will return NULL, if this case, we can use >> + gst_buffer_make_writable() to get a shared memory buffer or the orignal >> + buffer if the buffer's refcount is 1. >> + >> +Upstream-Status: Inappropriate [i.MX specific] >> + >> +Signed-off-by: Mingke Wang >> +--- >> + ext/pango/gstbasetextoverlay.c | 32 ++++++++++++++++++++++++++++++-- >> + 1 file changed, 30 insertions(+), 2 deletions(-) mode change 100644 >> +=> 100755 ext/pango/gstbasetextoverlay.c >> + >> +diff --git a/ext/pango/gstbasetextoverlay.c >> +b/ext/pango/gstbasetextoverlay.c old mode 100644 new mode 100755 >> +index bde4303..3e98aa1 >> +--- a/ext/pango/gstbasetextoverlay.c >> ++++ b/ext/pango/gstbasetextoverlay.c >> +@@ -2085,16 +2085,44 @@ gst_base_text_overlay_push_frame (GstBaseTextOverlay * overlay, >> + if (gst_pad_check_reconfigure (overlay->srcpad)) >> + gst_base_text_overlay_negotiate (overlay, NULL); >> + >> +- video_frame = gst_buffer_make_writable (video_frame); >> +- >> + if (overlay->attach_compo_to_buffer) { >> + GST_DEBUG_OBJECT (overlay, "Attaching text overlay image to >> +video buffer"); >> ++ video_frame = gst_buffer_make_writable (video_frame); >> + gst_buffer_add_video_overlay_composition_meta (video_frame, >> + overlay->composition); >> + /* FIXME: emulate shaded background box if want_shading=true */ >> + goto done; >> + } >> + >> ++ gint idx = 0; >> ++ gboolean mem_rdonly = FALSE; >> ++ GstMemory *mem; >> ++ guint n = gst_buffer_n_memory(video_frame); while ((idx < n) && >> ++ (mem = gst_buffer_get_memory(video_frame, idx++))) { >> ++ if (GST_MEMORY_IS_READONLY(mem)) { >> ++ gst_memory_unref (mem); >> ++ mem_rdonly = TRUE; >> ++ break; >> ++ } >> ++ gst_memory_unref (mem); >> ++ } >> ++ >> ++ if (mem_rdonly) { >> ++ GstBuffer *new_buf = gst_buffer_copy_region (video_frame, >> ++ GST_BUFFER_COPY_ALL | GST_BUFFER_COPY_DEEP, 0, -1); >> ++ >> ++ if (!new_buf) { >> ++ GST_WARNING_OBJECT(overlay, >> ++ "buffer memory read only, but copy memory failed"); >> ++ goto done; >> ++ } else { >> ++ gst_buffer_unref (video_frame); >> ++ video_frame = new_buf; >> ++ } >> ++ } else { >> ++ video_frame = gst_buffer_make_writable (video_frame); } >> ++ >> + if (!gst_video_frame_map (&frame, &overlay->info, video_frame, >> + GST_MAP_READWRITE)) >> + goto invalid_frame; >> +-- >> +1.9.1 >> + >> diff --git >> a/recipes-multimedia/gstreamer/gstreamer1.0-plugins-base_%.bbappend >> b/recipes-multimedia/gstreamer/gstreamer1.0-plugins-base_%.bbappend >> index ff4d77b..3e72175 100644 >> --- >> a/recipes-multimedia/gstreamer/gstreamer1.0-plugins-base_%.bbappend >> +++ b/recipes-multimedia/gstreamer/gstreamer1.0-plugins-base_%.bbappen >> +++ d >> @@ -1,7 +1,10 @@ >> FILESEXTRAPATHS_prepend := "${THISDIR}/${PN}:" >> >> -SRC_URI_append_mx6 = " file://gstplaybin-remove-flag-deinterlace.patch" >> -SRC_URI_append_mx7 = " file://gstplaybin-remove-flag-deinterlace.patch" >> +IMX_PATCHES = " file://gstplaybin-remove-flag-deinterlace.patch \ >> + >> +file://0001-basetextoverlay-make-memory-copy-when-video-buffer-s.patch \ " >> +SRC_URI_append_mx6 = "${IMX_PATCHES}" >> +SRC_URI_append_mx7 = "${IMX_PATCHES}" >> >> PACKAGE_ARCH_mx6 = "${MACHINE_SOCARCH}" >> PACKAGE_ARCH_mx7 = "${MACHINE_SOCARCH}" > -- > _______________________________________________ > meta-freescale mailing list > meta-freescale@yoctoproject.org > https://lists.yoctoproject.org/listinfo/meta-freescale --------------020607050600010303060408 Content-Type: text/html; charset=windows-1252 Content-Transfer-Encoding: 7bit
I suppose this is caused by the elements in gst1.0-fsl-plugins creating buffers with read-only GstMemory blocks, right?
Any reason why they are read only? I know these correspond to VPU framebuffers, but I do not see a reason why you want to prevent read-write access.
With read write access, it is theoretically possible that some element like textoverlay writes into it.
Without this access (and with your patch), it would then copy the entire buffer instead, which is not faster.
So, what other reasons are there?

On 01/20/2016 06:26 AM, Yuqing Zhu wrote:
Hi Carlos,
  
      Here is the bugzilla entry: https://bugzilla.gnome.org/show_bug.cgi?id=747495
      This bug is hardware specific, so we flag this patch as i.MX specific.



B.R.
Yuqing Zhu

-----Original Message-----
From: meta-freescale-bounces@yoctoproject.org [mailto:meta-freescale-bounces@yoctoproject.org] On Behalf Of Carlos Rafael Giani
Sent: Monday, January 18, 2016 10:16 PM
To: meta-freescale@yoctoproject.org
Subject: Re: [meta-freescale] [meta-fsl-arm][PATCH 1/3] gstreamer1.0-plugins-base: Make memory copy when video buffer's memory is read only

Why is this flagged as i.MX specific? Nothing in this patch refers to i.MX details such as IPU, VPU etc.

Also, the patch commit message needs a reference to a GStreamer bugzilla entry.

On 01/18/2016 10:34 AM, Yuqing Zhu wrote:
Since gst_buffer_make_writable just lookup the refcount to determine 
if a buffer is writable, and it will use _gst_buffer_copy() which 
don't perform a deep memory copy even if the flag of a memory is set 
to GST_MEMORY_FLAG_READONLY. So, we detect the memory flag and use 
gst_buffer_copy_region with GST_BUFFER_COPY_DEEP parameter to perform 
deep memory copy. if the allocator of a memory don't support mem_copy 
interface, the it will return NULL, if this case, we can use
gst_buffer_make_writable() to get a shared memory buffer or the 
orignal buffer if the buffer's refcount is 1.

Signed-off-by: Yuqing Zhu <b54851@freescale.com>
---
  ...rlay-make-memory-copy-when-video-buffer-s.patch | 80 ++++++++++++++++++++++
  .../gstreamer/gstreamer1.0-plugins-base_%.bbappend |  7 +-
  2 files changed, 85 insertions(+), 2 deletions(-)
  create mode 100755 
recipes-multimedia/gstreamer/gstreamer1.0-plugins-base/0001-basetextov
erlay-make-memory-copy-when-video-buffer-s.patch

diff --git 
a/recipes-multimedia/gstreamer/gstreamer1.0-plugins-base/0001-basetext
overlay-make-memory-copy-when-video-buffer-s.patch 
b/recipes-multimedia/gstreamer/gstreamer1.0-plugins-base/0001-basetext
overlay-make-memory-copy-when-video-buffer-s.patch
new file mode 100755
index 0000000..eaff00f
--- /dev/null
+++ b/recipes-multimedia/gstreamer/gstreamer1.0-plugins-base/0001-base
+++ textoverlay-make-memory-copy-when-video-buffer-s.patch
@@ -0,0 +1,80 @@
+From 0092d07195aa5d950bc10dfb05bd9547f67028a3 Mon Sep 17 00:00:00 
+2001
+From: Mingke Wang <mingke.wang@freescale.com>
+Date: Fri, 16 Oct 2015 19:31:32 +0800
+Subject: [PATCH 1/9] basetextoverlay: make memory copy when video 
+buffer's  memory is ready only
+
+1. since gst_buffer_make_writable just lookup the refcount to determine if
+   a buffer is writable, and it will use _gst_buffer_copy() which don't
+   perform a deep memory copy even if the flag of a memory is set to
+   GST_MEMORY_FLAG_READONLY. So, we detect the memory flag and use
+   gst_buffer_copy_region with GST_BUFFER_COPY_DEEP parameter to perform
+   deep memory copy. if the allocator of a memory don't support mem_copy
+   interface, the it will return NULL, if this case, we can use
+   gst_buffer_make_writable() to get a shared memory buffer or the orignal
+   buffer if the buffer's refcount is 1.
+
+Upstream-Status: Inappropriate [i.MX specific]
+
+Signed-off-by: Mingke Wang <mingke.wang@freescale.com>
+---
+ ext/pango/gstbasetextoverlay.c | 32 ++++++++++++++++++++++++++++++--
+ 1 file changed, 30 insertions(+), 2 deletions(-)  mode change 100644 
+=> 100755 ext/pango/gstbasetextoverlay.c
+
+diff --git a/ext/pango/gstbasetextoverlay.c 
+b/ext/pango/gstbasetextoverlay.c old mode 100644 new mode 100755 
+index bde4303..3e98aa1
+--- a/ext/pango/gstbasetextoverlay.c
++++ b/ext/pango/gstbasetextoverlay.c
+@@ -2085,16 +2085,44 @@ gst_base_text_overlay_push_frame (GstBaseTextOverlay * overlay,
+   if (gst_pad_check_reconfigure (overlay->srcpad))
+     gst_base_text_overlay_negotiate (overlay, NULL);
+
+-  video_frame = gst_buffer_make_writable (video_frame);
+-
+   if (overlay->attach_compo_to_buffer) {
+     GST_DEBUG_OBJECT (overlay, "Attaching text overlay image to 
+video buffer");
++    video_frame = gst_buffer_make_writable (video_frame);
+     gst_buffer_add_video_overlay_composition_meta (video_frame,
+         overlay->composition);
+     /* FIXME: emulate shaded background box if want_shading=true */
+     goto done;
+   }
+
++  gint idx = 0;
++  gboolean mem_rdonly = FALSE;
++  GstMemory *mem;
++  guint n = gst_buffer_n_memory(video_frame);  while ((idx < n) && 
++ (mem = gst_buffer_get_memory(video_frame, idx++))) {
++    if (GST_MEMORY_IS_READONLY(mem)) {
++      gst_memory_unref (mem);
++      mem_rdonly = TRUE;
++      break;
++    }
++    gst_memory_unref (mem);
++  }
++
++  if (mem_rdonly) {
++    GstBuffer *new_buf = gst_buffer_copy_region (video_frame,
++        GST_BUFFER_COPY_ALL | GST_BUFFER_COPY_DEEP, 0, -1);
++
++    if (!new_buf) {
++      GST_WARNING_OBJECT(overlay,
++                "buffer memory read only, but copy memory failed");
++      goto done;
++    } else {
++      gst_buffer_unref (video_frame);
++      video_frame = new_buf;
++    }
++  } else {
++    video_frame = gst_buffer_make_writable (video_frame);  }
++
+   if (!gst_video_frame_map (&frame, &overlay->info, video_frame,
+           GST_MAP_READWRITE))
+     goto invalid_frame;
+--
+1.9.1
+
diff --git 
a/recipes-multimedia/gstreamer/gstreamer1.0-plugins-base_%.bbappend 
b/recipes-multimedia/gstreamer/gstreamer1.0-plugins-base_%.bbappend
index ff4d77b..3e72175 100644
--- 
a/recipes-multimedia/gstreamer/gstreamer1.0-plugins-base_%.bbappend
+++ b/recipes-multimedia/gstreamer/gstreamer1.0-plugins-base_%.bbappen
+++ d
@@ -1,7 +1,10 @@
  FILESEXTRAPATHS_prepend := "${THISDIR}/${PN}:"
  
-SRC_URI_append_mx6 = " file://gstplaybin-remove-flag-deinterlace.patch"
-SRC_URI_append_mx7 = " file://gstplaybin-remove-flag-deinterlace.patch"
+IMX_PATCHES = " file://gstplaybin-remove-flag-deinterlace.patch \
+                
+file://0001-basetextoverlay-make-memory-copy-when-video-buffer-s.patch \ "
+SRC_URI_append_mx6 = "${IMX_PATCHES}"
+SRC_URI_append_mx7 = "${IMX_PATCHES}"
  
  PACKAGE_ARCH_mx6 = "${MACHINE_SOCARCH}"
  PACKAGE_ARCH_mx7 = "${MACHINE_SOCARCH}"
--
_______________________________________________
meta-freescale mailing list
meta-freescale@yoctoproject.org
https://lists.yoctoproject.org/listinfo/meta-freescale

--------------020607050600010303060408--