diff options
author | Yuqing Zhu <b54851@freescale.com> | 2015-08-10 11:41:36 +0800 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2015-09-01 21:19:35 +0100 |
commit | bdf4d19dc39d8ee860201ca68e30ebf203016a41 (patch) | |
tree | 1aa3f60929ea44ef3b8f8fe130193f3c4e6ba00a | |
parent | 29ef78c85ad669b3971bf45674b0edff07fa1219 (diff) | |
download | poky-bdf4d19dc39d8ee860201ca68e30ebf203016a41.tar.gz |
gstreamer1.0-plugins-base: Fix output buffer can't writable after frame_map() issue
-Add GST_VIDEO_FRAME_MAP_FLAG_NO_REF
This makes sure that the buffer is not reffed another time when
storing it in the GstVideoFrame, keeping it writable if it was writable.
-Use new GST_VIDEO_FRAME_MAP_FLAG_NO_REF to replace the old one because it's kind of ugly.
-Don't ref buffers twice when mapping
(From OE-Core master rev: a618f60675dbcc6568d6b9bdee015456cef78a77)
(From OE-Core rev: b75f09af7c4bfa023299c4f82bd6c3f781b93354)
Signed-off-by: Yuqing Zhu <b54851@freescale.com>
Signed-off-by: Ross Burton <ross.burton@intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
4 files changed, 185 insertions, 0 deletions
diff --git a/meta/recipes-multimedia/gstreamer/gstreamer1.0-plugins-base/0001-video-frame-Don-t-ref-buffers-twice-when-mapping.patch b/meta/recipes-multimedia/gstreamer/gstreamer1.0-plugins-base/0001-video-frame-Don-t-ref-buffers-twice-when-mapping.patch new file mode 100644 index 0000000000..3db4724fe6 --- /dev/null +++ b/meta/recipes-multimedia/gstreamer/gstreamer1.0-plugins-base/0001-video-frame-Don-t-ref-buffers-twice-when-mapping.patch | |||
@@ -0,0 +1,26 @@ | |||
1 | From 269f642c45d85cfd630ed490478e6bd6b71a767f Mon Sep 17 00:00:00 2001 | ||
2 | From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= <sebastian@centricular.com> | ||
3 | Date: Tue, 16 Sep 2014 01:07:18 +0300 | ||
4 | Subject: [PATCH] video-frame: Don't ref buffers twice when mapping | ||
5 | |||
6 | Upstream-Status: Backport [1.5.1] | ||
7 | --- | ||
8 | gst-libs/gst/video/video-frame.c | 2 +- | ||
9 | 1 file changed, 1 insertion(+), 1 deletion(-) | ||
10 | |||
11 | diff --git a/gst-libs/gst/video/video-frame.c b/gst-libs/gst/video/video-frame.c | ||
12 | index 01f23c0..8a9ae96 100644 | ||
13 | --- a/gst-libs/gst/video/video-frame.c | ||
14 | +++ b/gst-libs/gst/video/video-frame.c | ||
15 | @@ -105,7 +105,7 @@ gst_video_frame_map_id (GstVideoFrame * frame, GstVideoInfo * info, | ||
16 | frame->data[i] = frame->map[0].data + info->offset[i]; | ||
17 | } | ||
18 | } | ||
19 | - frame->buffer = gst_buffer_ref (buffer); | ||
20 | + frame->buffer = buffer; | ||
21 | if ((flags & GST_VIDEO_FRAME_MAP_FLAG_NO_REF) == 0) | ||
22 | gst_buffer_ref (frame->buffer); | ||
23 | |||
24 | -- | ||
25 | 1.7.9.5 | ||
26 | |||
diff --git a/meta/recipes-multimedia/gstreamer/gstreamer1.0-plugins-base/0002-video-frame-Add-GST_VIDEO_FRAME_MAP_FLAG_NO_REF.patch b/meta/recipes-multimedia/gstreamer/gstreamer1.0-plugins-base/0002-video-frame-Add-GST_VIDEO_FRAME_MAP_FLAG_NO_REF.patch new file mode 100644 index 0000000000..c465b5ceed --- /dev/null +++ b/meta/recipes-multimedia/gstreamer/gstreamer1.0-plugins-base/0002-video-frame-Add-GST_VIDEO_FRAME_MAP_FLAG_NO_REF.patch | |||
@@ -0,0 +1,87 @@ | |||
1 | From 40a293d44d1aeccf5eb8e86f23a0b13666111c5c Mon Sep 17 00:00:00 2001 | ||
2 | From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= <sebastian@centricular.com> | ||
3 | Date: Fri, 12 Sep 2014 14:39:16 +0300 | ||
4 | Subject: [PATCH 2/3] video-frame: Add GST_VIDEO_FRAME_MAP_FLAG_NO_REF | ||
5 | |||
6 | This makes sure that the buffer is not reffed another time when | ||
7 | storing it in the GstVideoFrame, keeping it writable if it was | ||
8 | writable. | ||
9 | |||
10 | Upstream-Status: Backport [1.5.1] | ||
11 | https://bugzilla.gnome.org/show_bug.cgi?id=736118 | ||
12 | --- | ||
13 | gst-libs/gst/video/video-frame.c | 9 ++++++++- | ||
14 | gst-libs/gst/video/video-frame.h | 18 ++++++++++++++++++ | ||
15 | 2 files changed, 26 insertions(+), 1 deletion(-) | ||
16 | |||
17 | diff --git a/gst-libs/gst/video/video-frame.c b/gst-libs/gst/video/video-frame.c | ||
18 | index 537cf70..01f23c0 100644 | ||
19 | --- a/gst-libs/gst/video/video-frame.c | ||
20 | +++ b/gst-libs/gst/video/video-frame.c | ||
21 | @@ -106,6 +106,9 @@ gst_video_frame_map_id (GstVideoFrame * frame, GstVideoInfo * info, | ||
22 | } | ||
23 | } | ||
24 | frame->buffer = gst_buffer_ref (buffer); | ||
25 | + if ((flags & GST_VIDEO_FRAME_MAP_FLAG_NO_REF) == 0) | ||
26 | + gst_buffer_ref (frame->buffer); | ||
27 | + | ||
28 | frame->meta = meta; | ||
29 | |||
30 | /* buffer flags enhance the frame flags */ | ||
31 | @@ -189,11 +192,13 @@ gst_video_frame_unmap (GstVideoFrame * frame) | ||
32 | GstBuffer *buffer; | ||
33 | GstVideoMeta *meta; | ||
34 | gint i; | ||
35 | + GstMapFlags flags; | ||
36 | |||
37 | g_return_if_fail (frame != NULL); | ||
38 | |||
39 | buffer = frame->buffer; | ||
40 | meta = frame->meta; | ||
41 | + flags = frame->map[0].flags; | ||
42 | |||
43 | if (meta) { | ||
44 | for (i = 0; i < frame->info.finfo->n_planes; i++) { | ||
45 | @@ -202,7 +207,9 @@ gst_video_frame_unmap (GstVideoFrame * frame) | ||
46 | } else { | ||
47 | gst_buffer_unmap (buffer, &frame->map[0]); | ||
48 | } | ||
49 | - gst_buffer_unref (buffer); | ||
50 | + | ||
51 | + if ((flags & GST_VIDEO_FRAME_MAP_FLAG_NO_REF) == 0) | ||
52 | + gst_buffer_unref (frame->buffer); | ||
53 | } | ||
54 | |||
55 | /** | ||
56 | diff --git a/gst-libs/gst/video/video-frame.h b/gst-libs/gst/video/video-frame.h | ||
57 | index 627fab0..f8e6304 100644 | ||
58 | --- a/gst-libs/gst/video/video-frame.h | ||
59 | +++ b/gst-libs/gst/video/video-frame.h | ||
60 | @@ -149,6 +149,24 @@ typedef enum { | ||
61 | GST_VIDEO_BUFFER_FLAG_LAST = (GST_BUFFER_FLAG_LAST << 8) | ||
62 | } GstVideoBufferFlags; | ||
63 | |||
64 | +/** | ||
65 | + * GstVideoBufferFlags: | ||
66 | + * @GST_VIDEO_FRAME_MAP_FLAG_NO_REF: Don't take another reference of the buffer and store it in | ||
67 | + * the GstVideoFrame. This makes sure that the buffer stays | ||
68 | + * writable while the frame is mapped, but requires that the | ||
69 | + * buffer reference stays valid until the frame is unmapped again. | ||
70 | + * @GST_VIDEO_FRAME_MAP_FLAG_LAST: Offset to define more flags | ||
71 | + * | ||
72 | + * Additional mapping flags for gst_video_frame_map(). | ||
73 | + * | ||
74 | + * Since: 1.6 | ||
75 | + */ | ||
76 | +typedef enum { | ||
77 | + GST_VIDEO_FRAME_MAP_FLAG_NO_REF = (GST_MAP_FLAG_LAST << 0), | ||
78 | + GST_VIDEO_FRAME_MAP_FLAG_LAST = (GST_MAP_FLAG_LAST << 8) | ||
79 | + /* 8 more flags possible afterwards */ | ||
80 | +} GstVideoFrameMapFlags; | ||
81 | + | ||
82 | G_END_DECLS | ||
83 | |||
84 | #endif /* __GST_VIDEO_FRAME_H__ */ | ||
85 | -- | ||
86 | 1.7.9.5 | ||
87 | |||
diff --git a/meta/recipes-multimedia/gstreamer/gstreamer1.0-plugins-base/0003-videofilter-Use-new-GST_VIDEO_FRAME_MAP_FLAG_NO_REF.patch b/meta/recipes-multimedia/gstreamer/gstreamer1.0-plugins-base/0003-videofilter-Use-new-GST_VIDEO_FRAME_MAP_FLAG_NO_REF.patch new file mode 100644 index 0000000000..132bf06f75 --- /dev/null +++ b/meta/recipes-multimedia/gstreamer/gstreamer1.0-plugins-base/0003-videofilter-Use-new-GST_VIDEO_FRAME_MAP_FLAG_NO_REF.patch | |||
@@ -0,0 +1,69 @@ | |||
1 | From 3a7cdcdfc9c5b0d20394fe51b3b8cda23931ca6d Mon Sep 17 00:00:00 2001 | ||
2 | From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= <sebastian@centricular.com> | ||
3 | Date: Fri, 12 Sep 2014 14:41:01 +0300 | ||
4 | Subject: [PATCH 3/3] videofilter: Use new GST_VIDEO_FRAME_MAP_FLAG_NO_REF | ||
5 | |||
6 | Upstream-Status: Backport [1.5.1] | ||
7 | https://bugzilla.gnome.org/show_bug.cgi?id=736118 | ||
8 | --- | ||
9 | gst-libs/gst/video/gstvideofilter.c | 23 ++++------------------- | ||
10 | 1 file changed, 4 insertions(+), 19 deletions(-) | ||
11 | |||
12 | diff --git a/gst-libs/gst/video/gstvideofilter.c b/gst-libs/gst/video/gstvideofilter.c | ||
13 | index e1fa2c1..874b2e8 100644 | ||
14 | --- a/gst-libs/gst/video/gstvideofilter.c | ||
15 | +++ b/gst-libs/gst/video/gstvideofilter.c | ||
16 | @@ -260,23 +260,15 @@ gst_video_filter_transform (GstBaseTransform * trans, GstBuffer * inbuf, | ||
17 | if (fclass->transform_frame) { | ||
18 | GstVideoFrame in_frame, out_frame; | ||
19 | |||
20 | - if (!gst_video_frame_map (&in_frame, &filter->in_info, inbuf, GST_MAP_READ)) | ||
21 | + if (!gst_video_frame_map (&in_frame, &filter->in_info, inbuf, | ||
22 | + GST_MAP_READ | GST_VIDEO_FRAME_MAP_FLAG_NO_REF)) | ||
23 | goto invalid_buffer; | ||
24 | |||
25 | if (!gst_video_frame_map (&out_frame, &filter->out_info, outbuf, | ||
26 | - GST_MAP_WRITE)) | ||
27 | + GST_MAP_WRITE | GST_VIDEO_FRAME_MAP_FLAG_NO_REF)) | ||
28 | goto invalid_buffer; | ||
29 | |||
30 | - /* GstVideoFrame has another reference, so the buffer looks unwriteable, | ||
31 | - * meaning that we can't attach any metas or anything to it. Other | ||
32 | - * map() functions like gst_buffer_map() don't get another reference | ||
33 | - * of the buffer and expect the buffer reference to be kept until | ||
34 | - * the buffer is unmapped again. */ | ||
35 | - gst_buffer_unref (inbuf); | ||
36 | - gst_buffer_unref (outbuf); | ||
37 | res = fclass->transform_frame (filter, &in_frame, &out_frame); | ||
38 | - gst_buffer_ref (inbuf); | ||
39 | - gst_buffer_ref (outbuf); | ||
40 | |||
41 | gst_video_frame_unmap (&out_frame); | ||
42 | gst_video_frame_unmap (&in_frame); | ||
43 | @@ -317,7 +309,7 @@ gst_video_filter_transform_ip (GstBaseTransform * trans, GstBuffer * buf) | ||
44 | GstVideoFrame frame; | ||
45 | GstMapFlags flags; | ||
46 | |||
47 | - flags = GST_MAP_READ; | ||
48 | + flags = GST_MAP_READ | GST_VIDEO_FRAME_MAP_FLAG_NO_REF; | ||
49 | |||
50 | if (!gst_base_transform_is_passthrough (trans)) | ||
51 | flags |= GST_MAP_WRITE; | ||
52 | @@ -325,14 +317,7 @@ gst_video_filter_transform_ip (GstBaseTransform * trans, GstBuffer * buf) | ||
53 | if (!gst_video_frame_map (&frame, &filter->in_info, buf, flags)) | ||
54 | goto invalid_buffer; | ||
55 | |||
56 | - /* GstVideoFrame has another reference, so the buffer looks unwriteable, | ||
57 | - * meaning that we can't attach any metas or anything to it. Other | ||
58 | - * map() functions like gst_buffer_map() don't get another reference | ||
59 | - * of the buffer and expect the buffer reference to be kept until | ||
60 | - * the buffer is unmapped again. */ | ||
61 | - gst_buffer_unref (buf); | ||
62 | res = fclass->transform_frame_ip (filter, &frame); | ||
63 | - gst_buffer_ref (buf); | ||
64 | |||
65 | gst_video_frame_unmap (&frame); | ||
66 | } else { | ||
67 | -- | ||
68 | 1.7.9.5 | ||
69 | |||
diff --git a/meta/recipes-multimedia/gstreamer/gstreamer1.0-plugins-base_1.4.5.bb b/meta/recipes-multimedia/gstreamer/gstreamer1.0-plugins-base_1.4.5.bb index 88c3254fc6..9c31391587 100644 --- a/meta/recipes-multimedia/gstreamer/gstreamer1.0-plugins-base_1.4.5.bb +++ b/meta/recipes-multimedia/gstreamer/gstreamer1.0-plugins-base_1.4.5.bb | |||
@@ -11,6 +11,9 @@ SRC_URI += "file://do-not-change-eos-event-to-gap-event-if.patch \ | |||
11 | file://fix-id3demux-utf16-to-utf8-issue.patch \ | 11 | file://fix-id3demux-utf16-to-utf8-issue.patch \ |
12 | file://handle-audio-video-decoder-error.patch \ | 12 | file://handle-audio-video-decoder-error.patch \ |
13 | file://videobuffer_updata_alignment_update.patch \ | 13 | file://videobuffer_updata_alignment_update.patch \ |
14 | file://0002-video-frame-Add-GST_VIDEO_FRAME_MAP_FLAG_NO_REF.patch \ | ||
15 | file://0001-video-frame-Don-t-ref-buffers-twice-when-mapping.patch \ | ||
16 | file://0003-videofilter-Use-new-GST_VIDEO_FRAME_MAP_FLAG_NO_REF.patch \ | ||
14 | " | 17 | " |
15 | 18 | ||
16 | SRC_URI[md5sum] = "357165af625c0ca353ab47c5d843920e" | 19 | SRC_URI[md5sum] = "357165af625c0ca353ab47c5d843920e" |