Add patches for gstreamer1.0-plugins-base 1.6
v2 cover Add patches for gstreamer1.0-plugins-base 1.6
---Fix IMXCameraApp image time cannot display issue.
---Make memory copy when video buffer's memory is read only.
Yuqing Zhu (2):
gstreamer1.0-plugins-base: Fix IMXCameraApp image time cannot display
issue.
gstreamer1.0-plugins-base: Make memory copy when video buffer's memory
is read only
...-Linux_MX6QP_ARD-IMXCameraApp-When-Enable.patch | 58 +++++++++++++++ ...rlay-make-memory-copy-when-video-buffer-s.patch | 82 ++++++++++++++++++++++ .../gstreamer/gstreamer1.0-plugins-base_%.bbappend | 9 ++- 3 files changed, 147 insertions(+), 2 deletions(-) create mode 100755 recipes-multimedia/gstreamer/gstreamer1.0-plugins-base/0001-MMFMWK-7030-Linux_MX6QP_ARD-IMXCameraApp-When-Enable.patch create mode 100755 recipes-multimedia/gstreamer/gstreamer1.0-plugins-base/0002-basetextoverlay-make-memory-copy-when-video-buffer-s.patch
Signature · 1 line
1.9.1
PATCH v2 1/2 gstreamer1.0-plugins-base: Fix IMXCameraApp image time cannot display issue.
IMXCameraApp: When Enabled "save time to image" item, preview, find the time can not display completely.
As IPU need 8 pixels alignment, add one workaround in base text overlay to generate 8 pixels alignment text video buffer. The side effect should cause all text a little smaller.
--- ...-Linux_MX6QP_ARD-IMXCameraApp-When-Enable.patch | 58 ++++++++++++++++++++++ .../gstreamer/gstreamer1.0-plugins-base_%.bbappend | 8 ++- 2 files changed, 64 insertions(+), 2 deletions(-) create mode 100755 recipes-multimedia/gstreamer/gstreamer1.0-plugins-base/0001-MMFMWK-7030-Linux_MX6QP_ARD-IMXCameraApp-When-Enable.patch
recipes-multimedia/gstreamer/gstreamer1.0-plugins-base/0001-MMFMWK-7030-Linux_MX6QP_ARD-IMXCameraApp-When-Enable.patch new file +58 -0
@@ -0,0 +1,58 @@ +From f19e83a1a69a3dbbeb16dc4bcee3fb87317bb65b Mon Sep 17 00:00:00 2001 +From: Song Bing <[email protected]> +Date: Mon, 11 Jan 2016 14:51:17 +0800 +Subject: [PATCH] MMFMWK-7030 [Linux_MX6QP_ARD]IMXCameraApp:When Enabled "save + time to image" item, preview, find the time can not display + completely. 100% + +As IPU need 8 pixels alignment, add one workaround in base text overlay +to generate 8 pixels alignment text video buffer. The side effect should +cause all text a little smaller. + +Upstream-Status: Inappropriate [i.MX specific] + +Signed-off-by: Song Bing [email protected] +--- + ext/pango/gstbasetextoverlay.c | 12 ++++++++++-- + 1 file changed, 10 insertions(+), 2 deletions(-) + +diff --git a/ext/pango/gstbasetextoverlay.c b/ext/pango/gstbasetextoverlay.c +index 3e98aa1..de64c92 100755 +--- a/ext/pango/gstbasetextoverlay.c ++++ b/ext/pango/gstbasetextoverlay.c +@@ -1545,7 +1545,7 @@ gst_base_text_overlay_render_pangocairo (GstBaseTextOverlay * overlay, + gint unscaled_width, unscaled_height; + gint width, height; + gboolean full_width = FALSE; +- double scalef = 1.0; ++ double scalef = 1.0, scalefx, scalefy; + double a, r, g, b; + gdouble shadow_offset = 0.0; + gdouble outline_offset = 0.0; +@@ -1673,6 +1673,14 @@ gst_base_text_overlay_render_pangocairo (GstBaseTextOverlay * overlay, + height = ceil (height * overlay->render_scale); + scalef *= overlay->render_scale; + ++ /* i.MX special, will cause text a little small */ ++ scalefx = scalef * ((gdouble)GST_ROUND_DOWN_8 (width)) / width; ++ scalefy = scalef * ((gdouble)GST_ROUND_DOWN_8 (height)) / height; ++ width = GST_ROUND_DOWN_8 (width); ++ height = GST_ROUND_DOWN_8 (height); ++ GST_DEBUG_OBJECT (overlay, "Rendering with width %d and height %d " ++ , width, height); ++ + if (width <= 0 || height <= 0) { + g_mutex_unlock (GST_BASE_TEXT_OVERLAY_GET_CLASS (overlay)->pango_lock); + GST_DEBUG_OBJECT (overlay, +@@ -1689,7 +1697,7 @@ gst_base_text_overlay_render_pangocairo (GstBaseTextOverlay * overlay, + /* Prepare the transformation matrix. Note that the transformation happens + * in reverse order. So for horizontal text, we will translate and then + * scale. This is important to understand which scale shall be used. */ +- cairo_matrix_init_scale (&cairo_matrix, scalef, scalef); ++ cairo_matrix_init_scale (&cairo_matrix, scalefx, scalefy); + + if (overlay->use_vertical_render) { + gint tmp; +-- +1.7.9.5 +
recipes-multimedia/gstreamer/gstreamer1.0-plugins-base_%.bbappend +6 -2
@@ -1,7 +1,11 @@ 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-MMFMWK-7030-Linux_MX6QP_ARD-IMXCameraApp-When-Enable.patch \ +" + +SRC_URI_append_mx6 = "${IMX_PATCHES}" +SRC_URI_append_mx7 = "${IMX_PATCHES}" PACKAGE_ARCH_mx6 = "${MACHINE_SOCARCH}" PACKAGE_ARCH_mx7 = "${MACHINE_SOCARCH}"
Signature · 1 line
1.9.1
PATCH v2 2/2 gstreamer1.0-plugins-base: Make memory copy when video buffer's memory is read only
In reply to Yuqing ZhuThe VPU decoder need the output framebuffer as a reference buffer for decoding. The output buffer shouldn’t be changed, if we blend the subtitle on the buffer directly, then the decoded video frame will have artificial jitter around the subtitle.
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, then 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.
--- ...rlay-make-memory-copy-when-video-buffer-s.patch | 82 ++++++++++++++++++++++ .../gstreamer/gstreamer1.0-plugins-base_%.bbappend | 1 + 2 files changed, 83 insertions(+) create mode 100755 recipes-multimedia/gstreamer/gstreamer1.0-plugins-base/0002-basetextoverlay-make-memory-copy-when-video-buffer-s.patch
recipes-multimedia/gstreamer/gstreamer1.0-plugins-base/0002-basetextoverlay-make-memory-copy-when-video-buffer-s.patch new file +82 -0
@@ -0,0 +1,82 @@ +From 0092d07195aa5d950bc10dfb05bd9547f67028a3 Mon Sep 17 00:00:00 2001 +From: Mingke Wang <[email protected]> +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. + +https://bugzilla.gnome.org/show_bug.cgi?id=747495 + +Upstream-Status: Inappropriate [i.MX specific] + +Signed-off-by: Mingke Wang <[email protected]> +--- + 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 +
recipes-multimedia/gstreamer/gstreamer1.0-plugins-base_%.bbappend +1 -0
@@ -2,6 +2,7 @@ FILESEXTRAPATHS_prepend := "${THISDIR}/${PN}:" IMX_PATCHES = " file://gstplaybin-remove-flag-deinterlace.patch \ file://0001-MMFMWK-7030-Linux_MX6QP_ARD-IMXCameraApp-When-Enable.patch \ + file://0002-basetextoverlay-make-memory-copy-when-video-buffer-s.patch \ " SRC_URI_append_mx6 = "${IMX_PATCHES}"
Signature · 1 line
1.9.1
Re: [meta-fsl-arm][PATCH v2 1/2] gstreamer1.0-plugins-base: Fix IMXCameraApp image time cannot display issue.
In reply to Yuqing ZhuAs said in the previous submission, I think this patch is acceptable, and a good example of something truly i.MX specific.
Since 8/16-pixel alignments aren't exactly uncommon, I think this should be turned into a solution that can be upstreamed and is applicable to many other GStreamer plugins that generate video frames. However, at least for now, we can live with this patch.
Quoted 96 lines · Yuqing Zhu
IMXCameraApp: When Enabled "save time to image" item, preview, find the time can not display completely.
As IPU need 8 pixels alignment, add one workaround in base text overlay to generate 8 pixels alignment text video buffer. The side effect should cause all text a little smaller.
Signed-off-by Yuqing Zhu <[email protected]>--- ...-Linux_MX6QP_ARD-IMXCameraApp-When-Enable.patch | 58 ++++++++++++++++++++++ .../gstreamer/gstreamer1.0-plugins-base_%.bbappend | 8 ++- 2 files changed, 64 insertions(+), 2 deletions(-)create mode 100755
recipes-multimedia/gstreamer/gstreamer1.0-plugins-base/0001-MMFMWK-7030-Linux_MX6QP_ARD-IMXCameraApp-When-Enable.patchrecipes-multimedia/gstreamer/gstreamer1.0-plugins-base/0001-MMFMWK-7030-Linux_MX6QP_ARD-IMXCameraApp-When-Enable.patch new file +58
-0@@ -0,0 +1,58 @@ +From f19e83a1a69a3dbbeb16dc4bcee3fb87317bb65b Mon Sep 17 00:00:00 2001 +From: Song Bing <[email protected]> +Date: Mon, 11 Jan 2016 14:51:17 +0800 +Subject: [PATCH] MMFMWK-7030 [Linux_MX6QP_ARD]IMXCameraApp:When Enabled "save + time to image" item, preview, find the time can not display + completely. 100% + +As IPU need 8 pixels alignment, add one workaround in base text overlay +to generate 8 pixels alignment text video buffer. The side effect should +cause all text a little smaller. + +Upstream-Status: Inappropriate [i.MX specific] + +Signed-off-by: Song Bing [email protected] +--- + ext/pango/gstbasetextoverlay.c | 12 ++++++++++-- + 1 file changed, 10 insertions(+), 2 deletions(-) + +diff --git a/ext/pango/gstbasetextoverlay.c b/ext/pango/gstbasetextoverlay.c +index 3e98aa1..de64c92 100755 +--- a/ext/pango/gstbasetextoverlay.c ++++ b/ext/pango/gstbasetextoverlay.c +@@ -1545,7 +1545,7 @@ gst_base_text_overlay_render_pangocairo (GstBaseTextOverlay * overlay, + gint unscaled_width, unscaled_height; + gint width, height; + gboolean full_width = FALSE; +- double scalef = 1.0; ++ double scalef = 1.0, scalefx, scalefy; + double a, r, g, b; + gdouble shadow_offset = 0.0; + gdouble outline_offset = 0.0; +@@ -1673,6 +1673,14 @@ gst_base_text_overlay_render_pangocairo (GstBaseTextOverlay * overlay, + height = ceil (height * overlay->render_scale); + scalef *= overlay->render_scale; + ++ /* i.MX special, will cause text a little small */ ++ scalefx = scalef * ((gdouble)GST_ROUND_DOWN_8 (width)) / width; ++ scalefy = scalef * ((gdouble)GST_ROUND_DOWN_8 (height)) / height; ++ width = GST_ROUND_DOWN_8 (width); ++ height = GST_ROUND_DOWN_8 (height); ++ GST_DEBUG_OBJECT (overlay, "Rendering with width %d and height %d " ++ , width, height); ++ + if (width <= 0 || height <= 0) { + g_mutex_unlock (GST_BASE_TEXT_OVERLAY_GET_CLASS (overlay)->pango_lock); + GST_DEBUG_OBJECT (overlay, +@@ -1689,7 +1697,7 @@ gst_base_text_overlay_render_pangocairo (GstBaseTextOverlay * overlay, + /* Prepare the transformation matrix. Note that the transformation happens + * in reverse order. So for horizontal text, we will translate and then + * scale. This is important to understand which scale shall be used. */ +- cairo_matrix_init_scale (&cairo_matrix, scalef, scalef); ++ cairo_matrix_init_scale (&cairo_matrix, scalefx, scalefy); + + if (overlay->use_vertical_render) { + gint tmp; +-- +1.7.9.5 +recipes-multimedia/gstreamer/gstreamer1.0-plugins-base_%.bbappend +6
-2@@ -1,7 +1,11 @@ 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-MMFMWK-7030-Linux_MX6QP_ARD-IMXCameraApp-When-Enable.patch \ +" + +SRC_URI_append_mx6 = "${IMX_PATCHES}" +SRC_URI_append_mx7 = "${IMX_PATCHES}" PACKAGE_ARCH_mx6 = "${MACHINE_SOCARCH}" PACKAGE_ARCH_mx7 = "${MACHINE_SOCARCH}"
Re: [meta-fsl-arm][PATCH v2 2/2] gstreamer1.0-plugins-base: Make memory copy when video buffer's memory is read only
In reply to Yuqing ZhuI do see the reason behind the patch. As you explained earlier, the VPU's output buffers are re-used as references, so they should not be modified.
Before I give this patch an Ack however, I need to know if the suggestions from https://bugzilla.gnome.org/show_bug.cgi?id=747495 regarding the NO_SHARE flag were tried out. They seem less invasive to me while accomplishing the same end result.
Quoted 121 lines · Yuqing Zhu
The VPU decoder need the output framebuffer as a reference buffer for decoding. The output buffer shouldn’t be changed, if we blend the subtitle on the buffer directly, then the decoded video frame will have artificial jitter around the subtitle.
Since
gst_buffer_make_writablejust 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 toGST_MEMORY_FLAG_READONLY. So, we detect the memory flag and usegst_buffer_copy_regionwithGST_BUFFER_COPY_DEEPparameter to perform deep memory copy. if the allocator of a memory don't supportmem_copyinterface, then it will return NULL, if this case, we can usegst_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 <[email protected]>--- ...rlay-make-memory-copy-when-video-buffer-s.patch | 82 ++++++++++++++++++++++ .../gstreamer/gstreamer1.0-plugins-base_%.bbappend | 1 + 2 files changed, 83 insertions(+)create mode 100755
recipes-multimedia/gstreamer/gstreamer1.0-plugins-base/0002-basetextoverlay-make-memory-copy-when-video-buffer-s.patchrecipes-multimedia/gstreamer/gstreamer1.0-plugins-base/0002-basetextoverlay-make-memory-copy-when-video-buffer-s.patch new file +82
-0@@ -0,0 +1,82 @@ +From 0092d07195aa5d950bc10dfb05bd9547f67028a3 Mon Sep 17 00:00:00 2001 +From: Mingke Wang <[email protected]> +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. + +https://bugzilla.gnome.org/show_bug.cgi?id=747495 + +Upstream-Status: Inappropriate [i.MX specific] + +Signed-off-by: Mingke Wang <[email protected]> +--- + 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 +recipes-multimedia/gstreamer/gstreamer1.0-plugins-base_%.bbappend +1
-0@@ -2,6 +2,7 @@ FILESEXTRAPATHS_prepend := "${THISDIR}/${PN}:" IMX_PATCHES = " file://gstplaybin-remove-flag-deinterlace.patch \ file://0001-MMFMWK-7030-Linux_MX6QP_ARD-IMXCameraApp-When-Enable.patch \ + file://0002-basetextoverlay-make-memory-copy-when-video-buffer-s.patch \ " SRC_URI_append_mx6 = "${IMX_PATCHES}"