summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYuqing Zhu <b54851@freescale.com>2016-01-28 17:02:48 +0800
committerRichard Purdie <richard.purdie@linuxfoundation.org>2016-01-31 13:29:49 +0000
commit2394b15ee0c928be5fff93e4f4cd34193a94196d (patch)
tree04888d2d01555909c6ff3098a3582ec10717f9d4
parent2724908252c844c4540340c3bef48284f5b12d08 (diff)
downloadpoky-2394b15ee0c928be5fff93e4f4cd34193a94196d.tar.gz
gstreamer1.0-plugins-base: Add video crop supporting when convert frame
Getting thumbnail will use convertframe to convert video frame to desired video format and size. But haven't process crop meta on the video buffer. Need to add video crop support. (From OE-Core rev: 078987cd3ad68acdb68e9d40d9021b96ffec6c09) Signed-off-by: Yuqing Zhu <b54851@freescale.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rwxr-xr-xmeta/recipes-multimedia/gstreamer/gstreamer1.0-plugins-base/0005-convertframe-Support-video-crop-when-convert-frame.patch143
-rw-r--r--meta/recipes-multimedia/gstreamer/gstreamer1.0-plugins-base_1.6.3.bb1
2 files changed, 144 insertions, 0 deletions
diff --git a/meta/recipes-multimedia/gstreamer/gstreamer1.0-plugins-base/0005-convertframe-Support-video-crop-when-convert-frame.patch b/meta/recipes-multimedia/gstreamer/gstreamer1.0-plugins-base/0005-convertframe-Support-video-crop-when-convert-frame.patch
new file mode 100755
index 0000000000..096a6f4cba
--- /dev/null
+++ b/meta/recipes-multimedia/gstreamer/gstreamer1.0-plugins-base/0005-convertframe-Support-video-crop-when-convert-frame.patch
@@ -0,0 +1,143 @@
1From 5be6ed00aad028d9cbb4e0c63af0be69d335c71e Mon Sep 17 00:00:00 2001
2From: Song Bing <b06498@freescale.com>
3Date: Fri, 11 Dec 2015 21:42:00 +0800
4Subject: [PATCH] convertframe: Support video crop when convert frame
5
6Get thumbnail will user convertframe to convert video frame to
7desired video format and size. But haven't process crop meta on
8the video buffer. Add support video crop.
9
10https://bugzilla.gnome.org/show_bug.cgi?id=759329
11
12Upstream-Status: Backport [1.7.1]
13
14---
15 gst-libs/gst/video/convertframe.c | 65 +++++++++++++++++++++++++++++++++------
16 1 file changed, 56 insertions(+), 9 deletions(-)
17
18diff --git a/gst-libs/gst/video/convertframe.c b/gst-libs/gst/video/convertframe.c
19index aa9c3d3..942a51e 100644
20--- a/gst-libs/gst/video/convertframe.c
21+++ b/gst-libs/gst/video/convertframe.c
22@@ -110,12 +110,23 @@ fail:
23 static GstElement *
24 build_convert_frame_pipeline (GstElement ** src_element,
25 GstElement ** sink_element, const GstCaps * from_caps,
26- const GstCaps * to_caps, GError ** err)
27+ GstVideoCropMeta * cmeta, const GstCaps * to_caps, GError ** err)
28 {
29- GstElement *src = NULL, *csp = NULL, *vscale = NULL;
30- GstElement *sink = NULL, *encoder = NULL, *pipeline;
31+ GstElement *vcrop = NULL, *csp = NULL, *csp2 = NULL, *vscale = NULL;
32+ GstElement *src = NULL, *sink = NULL, *encoder = NULL, *pipeline;
33+ GstVideoInfo info;
34 GError *error = NULL;
35
36+ if (cmeta) {
37+ if (!create_element ("videocrop", &vcrop, &error)) {
38+ g_warning
39+ ("build_convert_frame_pipeline: Buffer has crop metadata but videocrop element is not found. Cropping will be disabled");
40+ } else {
41+ if (!create_element ("videoconvert", &csp2, &error))
42+ goto no_elements;
43+ }
44+ }
45+
46 /* videoscale is here to correct for the pixel-aspect-ratio for us */
47 GST_DEBUG ("creating elements");
48 if (!create_element ("appsrc", &src, &error) ||
49@@ -133,15 +144,42 @@ build_convert_frame_pipeline (GstElement ** src_element,
50
51 GST_DEBUG ("adding elements");
52 gst_bin_add_many (GST_BIN (pipeline), src, csp, vscale, sink, NULL);
53+ if (vcrop)
54+ gst_bin_add_many (GST_BIN (pipeline), vcrop, csp2, NULL);
55
56 /* set caps */
57 g_object_set (src, "caps", from_caps, NULL);
58+ if (vcrop) {
59+ gst_video_info_from_caps (&info, from_caps);
60+ g_object_set (vcrop, "left", cmeta->x, NULL);
61+ g_object_set (vcrop, "top", cmeta->y, NULL);
62+ g_object_set (vcrop, "right", GST_VIDEO_INFO_WIDTH (&info) - cmeta->width,
63+ NULL);
64+ g_object_set (vcrop, "bottom",
65+ GST_VIDEO_INFO_HEIGHT (&info) - cmeta->height, NULL);
66+ GST_DEBUG ("crop meta [x,y,width,height]: %d %d %d %d", cmeta->x, cmeta->y,
67+ cmeta->width, cmeta->height);
68+ }
69 g_object_set (sink, "caps", to_caps, NULL);
70
71 /* FIXME: linking is still way too expensive, profile this properly */
72- GST_DEBUG ("linking src->csp");
73- if (!gst_element_link_pads (src, "src", csp, "sink"))
74- goto link_failed;
75+ if (vcrop) {
76+ GST_DEBUG ("linking src->csp2");
77+ if (!gst_element_link_pads (src, "src", csp2, "sink"))
78+ goto link_failed;
79+
80+ GST_DEBUG ("linking csp2->vcrop");
81+ if (!gst_element_link_pads (csp2, "src", vcrop, "sink"))
82+ goto link_failed;
83+
84+ GST_DEBUG ("linking vcrop->csp");
85+ if (!gst_element_link_pads (vcrop, "src", csp, "sink"))
86+ goto link_failed;
87+ } else {
88+ GST_DEBUG ("linking src->csp");
89+ if (!gst_element_link_pads (src, "src", csp, "sink"))
90+ goto link_failed;
91+ }
92
93 GST_DEBUG ("linking csp->vscale");
94 if (!gst_element_link_pads_full (csp, "src", vscale, "sink",
95@@ -193,8 +231,12 @@ no_elements:
96 {
97 if (src)
98 gst_object_unref (src);
99+ if (vcrop)
100+ gst_object_unref (vcrop);
101 if (csp)
102 gst_object_unref (csp);
103+ if (csp2)
104+ gst_object_unref (csp2);
105 if (vscale)
106 gst_object_unref (vscale);
107 if (sink)
108@@ -209,7 +251,11 @@ no_elements:
109 no_pipeline:
110 {
111 gst_object_unref (src);
112+ if (vcrop)
113+ gst_object_unref (vcrop);
114 gst_object_unref (csp);
115+ if (csp2)
116+ gst_object_unref (csp2);
117 gst_object_unref (vscale);
118 gst_object_unref (sink);
119
120@@ -282,7 +328,8 @@ gst_video_convert_sample (GstSample * sample, const GstCaps * to_caps,
121 }
122
123 pipeline =
124- build_convert_frame_pipeline (&src, &sink, from_caps, to_caps_copy, &err);
125+ build_convert_frame_pipeline (&src, &sink, from_caps,
126+ gst_buffer_get_video_crop_meta (buf), to_caps_copy, &err);
127 if (!pipeline)
128 goto no_pipeline;
129
130@@ -646,8 +693,8 @@ gst_video_convert_sample_async (GstSample * sample,
131 }
132
133 pipeline =
134- build_convert_frame_pipeline (&src, &sink, from_caps, to_caps_copy,
135- &error);
136+ build_convert_frame_pipeline (&src, &sink, from_caps,
137+ gst_buffer_get_video_crop_meta (buf), to_caps_copy, &error);
138 if (!pipeline)
139 goto no_pipeline;
140
141--
1422.5.0
143
diff --git a/meta/recipes-multimedia/gstreamer/gstreamer1.0-plugins-base_1.6.3.bb b/meta/recipes-multimedia/gstreamer/gstreamer1.0-plugins-base_1.6.3.bb
index 95a012eb81..b9ed3f41be 100644
--- a/meta/recipes-multimedia/gstreamer/gstreamer1.0-plugins-base_1.6.3.bb
+++ b/meta/recipes-multimedia/gstreamer/gstreamer1.0-plugins-base_1.6.3.bb
@@ -10,6 +10,7 @@ SRC_URI = " \
10 file://0003-ssaparse-enhance-SSA-text-lines-parsing.patch \ 10 file://0003-ssaparse-enhance-SSA-text-lines-parsing.patch \
11 file://0004-subparse-set-need_segment-after-sink-pad-received-GS.patch \ 11 file://0004-subparse-set-need_segment-after-sink-pad-received-GS.patch \
12 file://encodebin-Need-more-buffers-in-output-queue-for-bett.patch \ 12 file://encodebin-Need-more-buffers-in-output-queue-for-bett.patch \
13 file://0005-convertframe-Support-video-crop-when-convert-frame.patch \
13" 14"
14 15
15SRC_URI[md5sum] = "3ddde0ad598ef69f58d6a2e87f8b460f" 16SRC_URI[md5sum] = "3ddde0ad598ef69f58d6a2e87f8b460f"